Merge pull request #2526 from yurydelendik/create-os2
Fixes creation of OS/2 table
This commit is contained in:
commit
3aea29c7aa
33
src/fonts.js
33
src/fonts.js
@ -2646,25 +2646,25 @@ var Font = (function FontClosure() {
|
||||
lastCharIndex = 255;
|
||||
}
|
||||
|
||||
var unitsPerEm = override.unitsPerEm || PDF_GLYPH_SPACE_UNITS;
|
||||
var typoAscent = override.ascent || properties.ascent;
|
||||
var typoDescent = override.descent || properties.descent;
|
||||
var bbox = properties.bbox || [0, 0, 0, 0];
|
||||
var unitsPerEm = override.unitsPerEm ||
|
||||
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 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
|
||||
'\x02\x24' + // xAvgCharWidth
|
||||
'\x01\xF4' + // usWeightClass
|
||||
@ -5506,6 +5506,7 @@ var CFFParser = (function CFFParserClosure() {
|
||||
// adjusting ascent/descent
|
||||
properties.ascent = fontBBox[3];
|
||||
properties.descent = fontBBox[1];
|
||||
properties.ascentScaled = true;
|
||||
}
|
||||
|
||||
var charset, encoding;
|
||||
|
Loading…
Reference in New Issue
Block a user