Ensure that Type0, i.e. composite, OpenType fonts with CFF tables are *not* treated as CFF fonts if their glyph mapping is non-default (issue 9915)

This particular code-path has been the source of *numerous* regressions to date, so hopefully this patch won't cause any more of those.

Fixes 9915.
This commit is contained in:
Jonas Jenwald 2018-07-27 16:33:30 +02:00
parent cfdb597e4a
commit 17eac2d48a

View File

@ -35,6 +35,7 @@ import {
getUnicodeForGlyph, getUnicodeRangeFor, mapSpecialUnicodeValues
} from './unicode';
import { FontRendererFactory } from './font_renderer';
import { IdentityCMap } from './cmap';
import { Stream } from './stream';
import { Type1Parser } from './type1_parser';
@ -2308,9 +2309,11 @@ var Font = (function FontClosure() {
var isTrueType = !tables['CFF '];
if (!isTrueType) {
// OpenType font (skip composite fonts with non-default CID to GID map).
if ((header.version === 'OTTO' &&
!(properties.composite && properties.cidToGidMap)) ||
const isComposite = properties.composite &&
((properties.cidToGidMap || []).length > 0 ||
!(properties.cMap instanceof IdentityCMap));
// OpenType font (skip composite fonts with non-default glyph mapping).
if ((header.version === 'OTTO' && !isComposite) ||
!tables['head'] || !tables['hhea'] || !tables['maxp'] ||
!tables['post']) {
// No major tables: throwing everything at `CFFFont`.