[merge] don't drop platformID=0 Unicode cmap subtables
instead treat them as equivalent to platformID=3 Windows Unicode subtables
This commit is contained in:
parent
2c3c74f108
commit
242ad6279d
@ -380,10 +380,18 @@ def _glyphsAreSame(glyphSet1, glyphSet2, glyph1, glyph2):
|
||||
g1.width == g2.width and
|
||||
(not hasattr(g1, 'height') or g1.height == g2.height))
|
||||
|
||||
# Valid (format, platformID, platEncID) triplets for cmap subtables containing
|
||||
# Unicode BMP-only and Unicode Full Repertoire semantics.
|
||||
# Cf. OpenType spec for "Platform specific encodings":
|
||||
# https://docs.microsoft.com/en-us/typography/opentype/spec/name
|
||||
class CmapUnicodePlatEncodings:
|
||||
BMP = {(4, 3, 1), (4, 0, 3), (4, 0, 4), (4, 0, 6)}
|
||||
FullRepertoire = {(12, 3, 10), (12, 0, 4), (12, 0, 6)}
|
||||
|
||||
@_add_method(ttLib.getTableClass('cmap'))
|
||||
def merge(self, m, tables):
|
||||
# TODO Handle format=14.
|
||||
# Only merges 4/3/1 and 12/3/10 subtables, ignores all other subtables
|
||||
# Only merge format 4 and 12 Unicode subtables, ignores all other subtables
|
||||
# If there is a format 12 table for the same font, ignore the format 4 table
|
||||
cmapTables = []
|
||||
for fontIdx,table in enumerate(tables):
|
||||
@ -391,10 +399,16 @@ def merge(self, m, tables):
|
||||
format12 = None
|
||||
for subtable in table.tables:
|
||||
properties = (subtable.format, subtable.platformID, subtable.platEncID)
|
||||
if properties == (4,3,1):
|
||||
if properties in CmapUnicodePlatEncodings.BMP:
|
||||
format4 = subtable
|
||||
elif properties == (12,3,10):
|
||||
elif properties in CmapUnicodePlatEncodings.FullRepertoire:
|
||||
format12 = subtable
|
||||
else:
|
||||
log.warning(
|
||||
"Dropped cmap subtable from font [%s]:\t"
|
||||
"format %2s, platformID %2s, platEncID %2s",
|
||||
fontIdx, subtable.format, subtable.platformID, subtable.platEncID
|
||||
)
|
||||
if format12 is not None:
|
||||
cmapTables.append((format12, fontIdx))
|
||||
elif format4 is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user