Skip to content

Commit

Permalink
Store width for all glyphs when font is not subset
Browse files Browse the repository at this point in the history
Some glyphs are not in the cmap table.

Fix #2180.
  • Loading branch information
liZe committed Jun 17, 2024
1 parent 76fca69 commit e8540e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions weasyprint/pdf/fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ def build_fonts_dictionary(pdf, fonts, compress, subset, options):
full_font = io.BytesIO(font.file_content)
ttfont = TTFont(full_font, fontNumber=font.index)
font_widths, cmap = {}, {}
for i, glyph in enumerate(ttfont.getGlyphSet().values()):
font_widths[i] = glyph.width * 1000 / font.upem
for letter, key in ttfont.getBestCmap().items():
glyph = ttfont.getGlyphID(key)
if glyph not in cmap:
cmap[glyph] = chr(letter)
width = ttfont.getGlyphSet()[key].width
font_widths[glyph] = width * 1000 / font.upem

to_unicode = pydyf.Stream([
b'/CIDInit /ProcSet findresource begin',
Expand Down

0 comments on commit e8540e7

Please sign in to comment.