@@ -22,6 +22,7 @@ This file is part of the iText (R) project.
22
22
*/
23
23
package com .itextpdf .io .font .otf ;
24
24
25
+ import java .util .ArrayList ;
25
26
import java .util .HashMap ;
26
27
import java .util .List ;
27
28
import java .util .Map ;
@@ -56,8 +57,8 @@ public boolean transformOne(GlyphLine line) {
56
57
GposValueRecord valueRecord = valueRecordMap .get (glyphCode );
57
58
if (valueRecord != null ) {
58
59
Glyph newGlyph = new Glyph (line .get (line .idx ));
59
- newGlyph .xAdvance += ( short )valueRecord .XAdvance ;
60
- newGlyph .yAdvance += ( short )valueRecord .YAdvance ;
60
+ newGlyph .setXAdvance (( short )( newGlyph . getXAdvance () + valueRecord .XAdvance )) ;
61
+ newGlyph .setYAdvance (( short )( newGlyph . getYAdvance () + valueRecord .YAdvance )) ;
61
62
line .set (line .idx , newGlyph );
62
63
positionApplied = true ;
63
64
}
@@ -68,13 +69,28 @@ public boolean transformOne(GlyphLine line) {
68
69
@ Override
69
70
protected void readSubTable (int subTableLocation ) throws java .io .IOException {
70
71
openReader .rf .seek (subTableLocation );
71
- openReader .rf .readShort ();
72
- int coverage = openReader .rf .readUnsignedShort ();
72
+ int subTableFormat = openReader .rf .readShort ();
73
+ int coverageOffset = openReader .rf .readUnsignedShort ();
73
74
int valueFormat = openReader .rf .readUnsignedShort ();
74
- GposValueRecord valueRecord = OtfReadCommon .readGposValueRecord (openReader , valueFormat );
75
- List <Integer > coverageGlyphIds = openReader .readCoverageFormat (subTableLocation + coverage );
76
- for (Integer glyphId : coverageGlyphIds ) {
77
- valueRecordMap .put ((int )glyphId , valueRecord );
75
+ if (subTableFormat == 1 ) {
76
+ GposValueRecord valueRecord = OtfReadCommon .readGposValueRecord (openReader , valueFormat );
77
+ List <Integer > coverageGlyphIds = openReader .readCoverageFormat (subTableLocation + coverageOffset );
78
+ for (Integer glyphId : coverageGlyphIds ) {
79
+ valueRecordMap .put ((int ) glyphId , valueRecord );
80
+ }
81
+ } else if (subTableFormat == 2 ) {
82
+ int valueCount = openReader .rf .readUnsignedShort ();
83
+ List <GposValueRecord > valueRecords = new ArrayList <>();
84
+ for (int i = 0 ; i < valueCount ; i ++) {
85
+ GposValueRecord valueRecord = OtfReadCommon .readGposValueRecord (openReader , valueFormat );
86
+ valueRecords .add (valueRecord );
87
+ }
88
+ List <Integer > coverageGlyphIds = openReader .readCoverageFormat (subTableLocation + coverageOffset );
89
+ for (int i = 0 ; i < coverageGlyphIds .size (); i ++) {
90
+ valueRecordMap .put ((int ) coverageGlyphIds .get (i ), valueRecords .get (i ));
91
+ }
92
+ } else {
93
+ throw new IllegalArgumentException ("Bad subtable format identifier: " + subTableFormat );
78
94
}
79
95
}
80
96
}
0 commit comments