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

+4-12
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

+10
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.
Binary file not shown.
537 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
199 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-138 Bytes
Binary file not shown.
297 Bytes
Binary file not shown.
59 Bytes
Binary file not shown.

test/fonts/fallback_font.pdf

-5.75 KB
Binary file not shown.
-17.9 KB
Binary file not shown.
Binary file not shown.

test/fonts/fonts_emoji_glyph.pdf

-2.4 KB
Binary file not shown.

test/fonts/fonts_otf.pdf

-6.13 KB
Binary file not shown.

test/fonts/fonts_remap_nb.pdf

-2.28 KB
Binary file not shown.

test/fonts/fonts_two_mappings.pdf

-3.43 KB
Binary file not shown.

test/fonts/render_en_dash.pdf

-1.96 KB
Binary file not shown.

test/fonts/thai_text.pdf

-2.27 KB
Binary file not shown.
-1.94 KB
Binary file not shown.
-2.18 KB
Binary file not shown.

test/html/html_heading_hebrew.pdf

-2.19 KB
Binary file not shown.

test/html/html_strikethrough.pdf

-2.23 KB
Binary file not shown.

test/html/html_ul_type.pdf

-2.19 KB
Binary file not shown.

test/html/issue_156.pdf

-3.76 KB
Binary file not shown.
-321 Bytes
Binary file not shown.
-1.79 KB
Binary file not shown.

test/table/table_with_ttf_font.pdf

-1.02 KB
Binary file not shown.
-2.9 KB
Binary file not shown.

test/text/cell_curfont_leak.pdf

-2.86 KB
Binary file not shown.
-3.99 KB
Binary file not shown.
-5.92 KB
Binary file not shown.
Binary file not shown.

test/text/multi_cell_char_spacing.pdf

-978 Bytes
Binary file not shown.

test/text/multi_cell_font_leakage.pdf

-3.31 KB
Binary file not shown.
-977 Bytes
Binary file not shown.

test/text/multi_cell_j_paragraphs.pdf

-1.99 KB
Binary file not shown.
Binary file not shown.
-5.31 KB
Binary file not shown.
Binary file not shown.

test/text/text_positioning.pdf

-778 Bytes
Binary file not shown.

test/text/varfrags_fonts.pdf

-1.77 KB
Binary file not shown.

test/text/write_font_stretching.pdf

-978 Bytes
Binary file not shown.

test/text_shaping/arabic.pdf

-1.39 KB
Binary file not shown.
-1.93 KB
Binary file not shown.
-1.44 KB
Binary file not shown.
-4.43 KB
Binary file not shown.
-2.35 KB
Binary file not shown.

test/text_shaping/features.pdf

-2.35 KB
Binary file not shown.
-5.39 KB
Binary file not shown.

test/text_shaping/kerning.pdf

-1.62 KB
Binary file not shown.

test/text_shaping/ligatures.pdf

-2.35 KB
Binary file not shown.
Binary file not shown.
-2.19 KB
Binary file not shown.

test/text_shaping/shaping_hindi.pdf

-2.17 KB
Binary file not shown.
-3.55 KB
Binary file not shown.
-1.64 KB
Binary file not shown.
Binary file not shown.
-4.81 KB
Binary file not shown.

0 commit comments

Comments
 (0)