@@ -20,6 +20,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020You should have received a copy of the GNU Affero General Public License
2121along with this program. If not, see <https://www.gnu.org/licenses/>.
2222*/
23+ using System ;
2324using System . Collections . Generic ;
2425
2526namespace iText . IO . Font . Otf {
@@ -45,8 +46,8 @@ public override bool TransformOne(GlyphLine line) {
4546 GposValueRecord valueRecord = valueRecordMap . Get ( glyphCode ) ;
4647 if ( valueRecord != null ) {
4748 Glyph newGlyph = new Glyph ( line . Get ( line . idx ) ) ;
48- newGlyph . xAdvance += ( short ) valueRecord . XAdvance ;
49- newGlyph . yAdvance += ( short ) valueRecord . YAdvance ;
49+ newGlyph . SetXAdvance ( ( short ) ( newGlyph . GetXAdvance ( ) + valueRecord . XAdvance ) ) ;
50+ newGlyph . SetYAdvance ( ( short ) ( newGlyph . GetYAdvance ( ) + valueRecord . YAdvance ) ) ;
5051 line . Set ( line . idx , newGlyph ) ;
5152 positionApplied = true ;
5253 }
@@ -56,13 +57,32 @@ public override bool TransformOne(GlyphLine line) {
5657
5758 protected internal override void ReadSubTable ( int subTableLocation ) {
5859 openReader . rf . Seek ( subTableLocation ) ;
59- openReader . rf . ReadShort ( ) ;
60- int coverage = openReader . rf . ReadUnsignedShort ( ) ;
60+ int subTableFormat = openReader . rf . ReadShort ( ) ;
61+ int coverageOffset = openReader . rf . ReadUnsignedShort ( ) ;
6162 int valueFormat = openReader . rf . ReadUnsignedShort ( ) ;
62- GposValueRecord valueRecord = OtfReadCommon . ReadGposValueRecord ( openReader , valueFormat ) ;
63- IList < int > coverageGlyphIds = openReader . ReadCoverageFormat ( subTableLocation + coverage ) ;
64- foreach ( int ? glyphId in coverageGlyphIds ) {
65- valueRecordMap . Put ( ( int ) glyphId , valueRecord ) ;
63+ if ( subTableFormat == 1 ) {
64+ GposValueRecord valueRecord = OtfReadCommon . ReadGposValueRecord ( openReader , valueFormat ) ;
65+ IList < int > coverageGlyphIds = openReader . ReadCoverageFormat ( subTableLocation + coverageOffset ) ;
66+ foreach ( int ? glyphId in coverageGlyphIds ) {
67+ valueRecordMap . Put ( ( int ) glyphId , valueRecord ) ;
68+ }
69+ }
70+ else {
71+ if ( subTableFormat == 2 ) {
72+ int valueCount = openReader . rf . ReadUnsignedShort ( ) ;
73+ IList < GposValueRecord > valueRecords = new List < GposValueRecord > ( ) ;
74+ for ( int i = 0 ; i < valueCount ; i ++ ) {
75+ GposValueRecord valueRecord = OtfReadCommon . ReadGposValueRecord ( openReader , valueFormat ) ;
76+ valueRecords . Add ( valueRecord ) ;
77+ }
78+ IList < int > coverageGlyphIds = openReader . ReadCoverageFormat ( subTableLocation + coverageOffset ) ;
79+ for ( int i = 0 ; i < coverageGlyphIds . Count ; i ++ ) {
80+ valueRecordMap . Put ( ( int ) coverageGlyphIds [ i ] , valueRecords [ i ] ) ;
81+ }
82+ }
83+ else {
84+ throw new ArgumentException ( "Bad subtable format identifier: " + subTableFormat ) ;
85+ }
6686 }
6787 }
6888 }
0 commit comments