Skip to content

Commit

Permalink
assert svg glyph converted from COLR has same dimension/horizontal po…
Browse files Browse the repository at this point in the history
…sitioning
  • Loading branch information
anthrotype committed Aug 18, 2022
1 parent bbdd273 commit cc38638
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/maximum_color_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import copy
from fontTools import ttLib
from nanoemoji.keep_glyph_names import keep_glyph_names
from picosvg.svg import SVG
from pathlib import Path
import pytest
import sys
Expand Down Expand Up @@ -143,3 +144,21 @@ def test_zero_advance_width_colrv1_to_svg():
assert maximum_font["COLR"].table.BaseGlyphList.BaseGlyphCount == 2
assert "SVG " in maximum_font
assert len(maximum_font["SVG "].docList) == 2

# check that 'acutecomb' still has 0 advance width
assert initial_font["hmtx"]["acutecomb"] == (0, 0)
# it has not been cropped away (has a non-empty bounding box)
doc = maximum_font["SVG "].docList[1]
assert doc.startGlyphID == doc.endGlyphID == maximum_font.getGlyphID("acutecomb")
svg = SVG.fromstring(doc.data)
shapes = list(svg.shapes())
assert len(shapes) == 1
bbox = shapes[0].bounding_box()
assert bbox.w > 0
assert bbox.h > 0
# its bbox matches the respective COLR ClipBox dimensions (quantized to 10)
clipBox = maximum_font["COLR"].table.ClipList.clips["acutecomb"]
assert abs(bbox.w - (clipBox.xMax - clipBox.xMin)) <= 10
assert abs(bbox.h - (clipBox.yMax - clipBox.yMin)) <= 10
# the SVG shape's horizontal positioning also matches the respective COLR glyph
assert abs(bbox.x - clipBox.xMin) <= 10

0 comments on commit cc38638

Please sign in to comment.