@@ -20,6 +20,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
20
You should have received a copy of the GNU Affero General Public License
21
21
along with this program. If not, see <https://www.gnu.org/licenses/>.
22
22
*/
23
+ using System ;
23
24
using System . Collections . Generic ;
24
25
25
26
namespace iText . IO . Font . Otf {
@@ -45,8 +46,8 @@ public override bool TransformOne(GlyphLine line) {
45
46
GposValueRecord valueRecord = valueRecordMap . Get ( glyphCode ) ;
46
47
if ( valueRecord != null ) {
47
48
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 ) ) ;
50
51
line . Set ( line . idx , newGlyph ) ;
51
52
positionApplied = true ;
52
53
}
@@ -56,13 +57,32 @@ public override bool TransformOne(GlyphLine line) {
56
57
57
58
protected internal override void ReadSubTable ( int subTableLocation ) {
58
59
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 ( ) ;
61
62
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
+ }
66
86
}
67
87
}
68
88
}
0 commit comments