From 17eac2d48a9597f96d4e3d36d4d075e465c5b298 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 27 Jul 2018 16:33:30 +0200 Subject: [PATCH] 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. --- src/core/fonts.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index 168444693..aff4ac513 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -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`.