Skip to content

Commit 4550ffe

Browse files
committed
Fixes fonts on linux
1 parent b1181c1 commit 4550ffe

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/fonts.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2938,6 +2938,7 @@ var Font = (function FontClosure() {
29382938
}
29392939
this.toFontChar = toFontChar;
29402940
}
2941+
var unitsPerEm = properties.unitsPerEm || 1000; // defaulting to 1000
29412942

29422943
var fields = {
29432944
// PostScript Font Program
@@ -2958,7 +2959,7 @@ var Font = (function FontClosure() {
29582959
'\x00\x00\x00\x00' + // checksumAdjustement
29592960
'\x5F\x0F\x3C\xF5' + // magicNumber
29602961
'\x00\x00' + // Flags
2961-
'\x03\xE8' + // unitsPerEM (defaulting to 1000)
2962+
safeString16(unitsPerEm) + // unitsPerEM
29622963
'\x00\x00\x00\x00\x9e\x0b\x7e\x27' + // creation date
29632964
'\x00\x00\x00\x00\x9e\x0b\x7e\x27' + // modifification date
29642965
'\x00\x00' + // xMin
@@ -4413,6 +4414,12 @@ var CFFParser = (function CFFParserClosure() {
44134414
var charStringOffset = topDict.getByName('CharStrings');
44144415
cff.charStrings = this.parseCharStrings(charStringOffset);
44154416

4417+
var fontMatrix = topDict.getByName('FontMatrix');
4418+
if (fontMatrix) {
4419+
// estimating unitsPerEM for the font
4420+
properties.unitsPerEm = 1 / fontMatrix[0];
4421+
}
4422+
44164423
var charset, encoding;
44174424
if (cff.isCIDFont) {
44184425
var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;

0 commit comments

Comments
 (0)