1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 15:48:06 +02:00

Add unique glyph names for CFF fonts.

Printing on MacOS was broken with the previous approach of just mapping
all the glyphs to notdef.
This commit is contained in:
Brendan Dahl 2019-02-26 15:57:46 -08:00
parent 9f9d87c3ce
commit 8a596ef5d5
3 changed files with 89 additions and 18 deletions

View file

@ -14,7 +14,7 @@
*/
import {
CFFCompiler, CFFFDSelect, CFFParser, CFFStrings
CFFCharset, CFFCompiler, CFFFDSelect, CFFParser, CFFStrings
} from '../../src/core/cff_parser';
import { SEAC_ANALYSIS_ENABLED } from '../../src/core/fonts';
import { Stream } from '../../src/core/stream';
@ -446,5 +446,35 @@ describe('CFFCompiler', function() {
]);
});
it('compiles charset of CID font', function() {
var charset = new CFFCharset();
var c = new CFFCompiler();
var numGlyphs = 7;
var out = c.compileCharset(charset, numGlyphs, new CFFStrings(), true);
// All CID charsets get turned into a simple format 2.
expect(out).toEqual([
2, // format
0, // cid (high)
0, // cid (low)
0, // nLeft (high)
numGlyphs - 1, // nLeft (low)
]);
});
it('compiles charset of non CID font', function() {
var charset = new CFFCharset(false, 0, ['space', 'exclam']);
var c = new CFFCompiler();
var numGlyphs = 3;
var out = c.compileCharset(charset, numGlyphs, new CFFStrings(), false);
// All non-CID fonts use a format 0 charset.
expect(out).toEqual([
0, // format
0, // sid of 'space' (high)
1, // sid of 'space' (low)
0, // sid of 'exclam' (high)
2, // sid of 'exclam' (low)
]);
});
// TODO a lot more compiler tests
});