[Text] fixup bounds and normalized form
This commit is contained in:
parent
89cdd23f00
commit
f34b9b2f5c
2 changed files with 37 additions and 4 deletions
|
|
@ -27,6 +27,33 @@ def test_text_to_polygons() -> None:
|
|||
assert len(set(char_x_means)) >= 2
|
||||
|
||||
|
||||
def test_text_bounds_and_normalized_form() -> None:
|
||||
pytest.importorskip("freetype")
|
||||
font_path = "/usr/share/fonts/truetype/dejavu/DejaVuMathTeXGyre.ttf"
|
||||
if not Path(font_path).exists():
|
||||
pytest.skip("Font file not found")
|
||||
|
||||
text = Text("Hi", height=10, font_path=font_path)
|
||||
_intrinsic, extrinsic, ctor = text.normalized_form(5)
|
||||
normalized = ctor()
|
||||
|
||||
assert extrinsic[1] == 2
|
||||
assert normalized.height == 5
|
||||
|
||||
bounds = text.get_bounds_single()
|
||||
assert bounds is not None
|
||||
assert numpy.isfinite(bounds).all()
|
||||
assert numpy.all(bounds[1] > bounds[0])
|
||||
|
||||
|
||||
def test_text_mirroring_affects_comparison() -> None:
|
||||
text = Text("A", height=10, font_path="dummy.ttf")
|
||||
mirrored = Text("A", height=10, font_path="dummy.ttf", mirrored=True)
|
||||
|
||||
assert text != mirrored
|
||||
assert (text < mirrored) != (mirrored < text)
|
||||
|
||||
|
||||
# 2. Manhattanization tests
|
||||
def test_manhattanize() -> None:
|
||||
pytest.importorskip("float_raster")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue