mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use the endchar operator for glyphs that have been subsetted out instead of the empty string as some cff font renderers (adobe) have problems with empty strings
This commit is contained in:
parent
5729fdb0e5
commit
1873e95b38
@ -124,10 +124,11 @@ class Subset(object):
|
|||||||
charsets = Charsets(strings)
|
charsets = Charsets(strings)
|
||||||
charsets.extend(cff.charset[1:]) # .notdef is not included
|
charsets.extend(cff.charset[1:]) # .notdef is not included
|
||||||
|
|
||||||
|
endchar_operator = bytes(bytearray([14]))
|
||||||
for i in xrange(self.cff.num_glyphs):
|
for i in xrange(self.cff.num_glyphs):
|
||||||
cname = self.cff.charset.safe_lookup(i)
|
cname = self.cff.charset.safe_lookup(i)
|
||||||
ok = cname in keep_charnames
|
ok = cname in keep_charnames
|
||||||
cs = self.cff.char_strings[i] if ok else b''
|
cs = self.cff.char_strings[i] if ok else endchar_operator
|
||||||
char_strings.append(cs)
|
char_strings.append(cs)
|
||||||
if ok:
|
if ok:
|
||||||
self.charname_map[cname] = i
|
self.charname_map[cname] = i
|
||||||
|
@ -96,12 +96,7 @@ def subset(raw, individual_chars, ranges=()):
|
|||||||
subset_truetype(sfnt, character_map)
|
subset_truetype(sfnt, character_map)
|
||||||
elif b'CFF ' in sfnt:
|
elif b'CFF ' in sfnt:
|
||||||
# PostScript Outlines
|
# PostScript Outlines
|
||||||
from calibre.utils.config_base import tweaks
|
|
||||||
if tweaks['subset_cff_table']:
|
|
||||||
subset_postscript(sfnt, character_map)
|
subset_postscript(sfnt, character_map)
|
||||||
else:
|
|
||||||
raise UnsupportedFont('This font contains PostScript outlines, '
|
|
||||||
'subsetting not supported')
|
|
||||||
else:
|
else:
|
||||||
raise UnsupportedFont('This font does not contain TrueType '
|
raise UnsupportedFont('This font does not contain TrueType '
|
||||||
'or PostScript outlines')
|
'or PostScript outlines')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user