Skip to content

Commit

Permalink
remove assertions that glyph advance width > 0
Browse files Browse the repository at this point in the history
this will make zero-width glyphs disappear when rasterized via resvg to PNG, because anything outside viewbox gets clipped (#402). Thus, running maximum_color --bitmaps with a font that has such zero-width glyphs will produce invisible empty CBDT/sbix glyphs until that issue is resolved.
However, removing this assertions allows us to support zero-width glyphs in vector color formats like OT-SVG/COLR (cf. #421)
  • Loading branch information
anthrotype committed Aug 17, 2022
1 parent 3f9e921 commit 5406472
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
6 changes: 0 additions & 6 deletions src/nanoemoji/colr_to_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,9 @@ def glyph_region(ttfont: ttLib.TTFont, glyph_name: str) -> Rect:
def _view_box_and_transform(
ttfont: ttLib.TTFont, view_box_callback: ViewboxCallback, glyph_name: str
) -> Tuple[Rect, Affine2D]:

view_box = view_box_callback(glyph_name)
assert view_box.w > 0, f"0-width viewBox for {glyph_name}?!"

region = glyph_region(ttfont, glyph_name)
assert region.w > 0, f"0-width region for {glyph_name}?!"

font_to_vbox = map_font_space_to_viewbox(view_box, region)

return (view_box, font_to_vbox)


Expand Down
4 changes: 1 addition & 3 deletions src/nanoemoji/generate_svgs_from_colr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@

def _view_box(font: ttLib.TTFont, glyph_name: str) -> Rect:
# we want a viewbox that results in no scaling when translating from font-space
region = glyph_region(font, glyph_name)
assert region.w > 0, f"0-width region for {glyph_name}"
return region
return glyph_region(font, glyph_name)


def main(argv):
Expand Down

0 comments on commit 5406472

Please sign in to comment.