Skip to content

Commit c7adbb7

Browse files
committed
remove reserved codepoints; drop color fonts on subset
1 parent d07a6a7 commit c7adbb7

File tree

66 files changed

+14
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+14
-12
lines changed

fpdf/fonts.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,20 +368,13 @@ def __init__(self, fpdf, font_file_path, fontkey, style):
368368

369369
self.missing_glyphs = []
370370

371-
# include numbers in the subset! (if alias present)
372-
# ensure that alias is mapped 1-by-1 additionally (must be replaceable)
373-
sbarr = "\x00 \r\n"
374-
if fpdf.str_alias_nb_pages:
375-
sbarr += "0123456789"
376-
sbarr += fpdf.str_alias_nb_pages
377-
378371
self.name = re.sub("[ ()]", "", self.ttfont["name"].getBestFullName())
379372
self.up = round(post_table.underlinePosition * self.scale)
380373
self.ut = round(post_table.underlineThickness * self.scale)
381374
self.sp = round(os2_table.yStrikeoutPosition * self.scale)
382375
self.ss = round(os2_table.yStrikeoutSize * self.scale)
383376
self.emphasis = TextEmphasis.coerce(style)
384-
self.subset = SubsetMap(self, [ord(char) for char in sbarr])
377+
self.subset = SubsetMap(self)
385378

386379
def __repr__(self):
387380
return f"TTFFont(i={self.i}, fontkey={self.fontkey})"
@@ -574,14 +567,13 @@ class SubsetMap:
574567
the lowest possible representation.
575568
"""
576569

577-
def __init__(self, font: TTFFont, identities: List[int]):
570+
def __init__(self, font: TTFFont):
578571
super().__init__()
579572
self.font = font
580573
self._next = 0
581574

582-
# sort list to ease deletion once _next
583-
# becomes higher than first reservation
584-
self._reserved = sorted(identities)
575+
# 0x00 ".notdef" and 0x20 "space" are reserved
576+
self._reserved = [0x00, 0x20]
585577

586578
# Maps Glyph instances to character IDs (integers):
587579
self._char_id_per_glyph = {}

fpdf/output.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,16 @@ def _add_fonts(self):
720720
"hdmx", # Horizontal Device Metrics table, stores integer advance widths scaled to particular pixel sizes
721721
# for OpenType™ fonts with TrueType outlines
722722
"meta", # metadata table
723+
"sbix", # Apple's SBIX table, used for color bitmap glyphs
724+
"CBDT", # Color Bitmap Data Table
725+
"CBLC", # Color Bitmap Location Table
726+
"EBDT", # Embedded Bitmap Data Table
727+
"EBLC", # Embedded Bitmap Location Table
728+
"EBSC", # Embedded Bitmap Scaling Table
729+
"SVG ", # SVG table
730+
"CPAL", # Color Palette table
731+
"COLR", # Color table
732+
"fvar", # Font Variations table
723733
]
724734
subsetter = ftsubset.Subsetter(options)
725735
subsetter.populate(glyphs=glyph_names)

test/alias_with_text_shaping.pdf

-1.55 KB
Binary file not shown.

test/encryption/encrypt_fonts.pdf

-6.13 KB
Binary file not shown.
-1.77 KB
Binary file not shown.

test/fonts/add_font_unicode.pdf

-1.85 KB
Binary file not shown.
537 Bytes
Binary file not shown.
537 Bytes
Binary file not shown.
519 Bytes
Binary file not shown.
736 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)