@@ -2646,25 +2646,25 @@ var Font = (function FontClosure() {
2646
2646
lastCharIndex = 255 ;
2647
2647
}
2648
2648
2649
- var unitsPerEm = override .unitsPerEm || PDF_GLYPH_SPACE_UNITS ;
2650
- var typoAscent = override .ascent || properties .ascent ;
2651
- var typoDescent = override .descent || properties .descent ;
2649
+ var bbox = properties .bbox || [0 , 0 , 0 , 0 ];
2650
+ var unitsPerEm = override .unitsPerEm ||
2651
+ 1 / (properties .fontMatrix || FONT_IDENTITY_MATRIX )[0 ];
2652
+
2653
+ // if the font units differ to the PDF glyph space units
2654
+ // then scale up the values
2655
+ var scale = properties .ascentScaled ? 1.0 :
2656
+ unitsPerEm / PDF_GLYPH_SPACE_UNITS ;
2657
+
2658
+ var typoAscent = override .ascent || Math .round (scale *
2659
+ (properties .ascent || bbox [3 ]));
2660
+ var typoDescent = override .descent || Math .round (scale *
2661
+ (properties .descent || bbox [1 ]));
2662
+ if (typoDescent > 0 && properties .descent > 0 && bbox [1 ] < 0 ) {
2663
+ typoDescent = -typoDescent ; // fixing incorrect descent
2664
+ }
2652
2665
var winAscent = override .yMax || typoAscent ;
2653
2666
var winDescent = -override .yMin || -typoDescent ;
2654
2667
2655
- // if there is a units per em value but no other override
2656
- // then scale the calculated ascent
2657
- if (unitsPerEm != PDF_GLYPH_SPACE_UNITS &&
2658
- 'undefined' == typeof (override .ascent )) {
2659
- // if the font units differ to the PDF glyph space units
2660
- // then scale up the values
2661
- typoAscent = Math .round (typoAscent * unitsPerEm / PDF_GLYPH_SPACE_UNITS );
2662
- typoDescent = Math .round (typoDescent * unitsPerEm /
2663
- PDF_GLYPH_SPACE_UNITS );
2664
- winAscent = typoAscent ;
2665
- winDescent = -typoDescent ;
2666
- }
2667
-
2668
2668
return '\x00\x03' + // version
2669
2669
'\x02\x24' + // xAvgCharWidth
2670
2670
'\x01\xF4' + // usWeightClass
@@ -5506,6 +5506,7 @@ var CFFParser = (function CFFParserClosure() {
5506
5506
// adjusting ascent/descent
5507
5507
properties .ascent = fontBBox [3 ];
5508
5508
properties .descent = fontBBox [1 ];
5509
+ properties .ascentScaled = true ;
5509
5510
}
5510
5511
5511
5512
var charset , encoding ;
0 commit comments