Fixes creation of OS/2 table
This commit is contained in:
parent
bf0abd61d1
commit
aa93eac261
33
src/fonts.js
33
src/fonts.js
@ -2646,25 +2646,25 @@ var Font = (function FontClosure() {
|
|||||||
lastCharIndex = 255;
|
lastCharIndex = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
var unitsPerEm = override.unitsPerEm || PDF_GLYPH_SPACE_UNITS;
|
var bbox = properties.bbox || [0, 0, 0, 0];
|
||||||
var typoAscent = override.ascent || properties.ascent;
|
var unitsPerEm = override.unitsPerEm ||
|
||||||
var typoDescent = override.descent || properties.descent;
|
1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
|
||||||
|
|
||||||
|
// if the font units differ to the PDF glyph space units
|
||||||
|
// then scale up the values
|
||||||
|
var scale = properties.ascentScaled ? 1.0 :
|
||||||
|
unitsPerEm / PDF_GLYPH_SPACE_UNITS;
|
||||||
|
|
||||||
|
var typoAscent = override.ascent || Math.round(scale *
|
||||||
|
(properties.ascent || bbox[3]));
|
||||||
|
var typoDescent = override.descent || Math.round(scale *
|
||||||
|
(properties.descent || bbox[1]));
|
||||||
|
if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
|
||||||
|
typoDescent = -typoDescent; // fixing incorrect descent
|
||||||
|
}
|
||||||
var winAscent = override.yMax || typoAscent;
|
var winAscent = override.yMax || typoAscent;
|
||||||
var winDescent = -override.yMin || -typoDescent;
|
var winDescent = -override.yMin || -typoDescent;
|
||||||
|
|
||||||
// if there is a units per em value but no other override
|
|
||||||
// then scale the calculated ascent
|
|
||||||
if (unitsPerEm != PDF_GLYPH_SPACE_UNITS &&
|
|
||||||
'undefined' == typeof(override.ascent)) {
|
|
||||||
// if the font units differ to the PDF glyph space units
|
|
||||||
// then scale up the values
|
|
||||||
typoAscent = Math.round(typoAscent * unitsPerEm / PDF_GLYPH_SPACE_UNITS);
|
|
||||||
typoDescent = Math.round(typoDescent * unitsPerEm /
|
|
||||||
PDF_GLYPH_SPACE_UNITS);
|
|
||||||
winAscent = typoAscent;
|
|
||||||
winDescent = -typoDescent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '\x00\x03' + // version
|
return '\x00\x03' + // version
|
||||||
'\x02\x24' + // xAvgCharWidth
|
'\x02\x24' + // xAvgCharWidth
|
||||||
'\x01\xF4' + // usWeightClass
|
'\x01\xF4' + // usWeightClass
|
||||||
@ -5479,6 +5479,7 @@ var CFFParser = (function CFFParserClosure() {
|
|||||||
// adjusting ascent/descent
|
// adjusting ascent/descent
|
||||||
properties.ascent = fontBBox[3];
|
properties.ascent = fontBBox[3];
|
||||||
properties.descent = fontBBox[1];
|
properties.descent = fontBBox[1];
|
||||||
|
properties.ascentScaled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var charset, encoding;
|
var charset, encoding;
|
||||||
|
Loading…
Reference in New Issue
Block a user