Skip to content

Commit

Permalink
Add font directory testing
Browse files Browse the repository at this point in the history
  • Loading branch information
baseplate-admin committed May 10, 2024
1 parent d5108b2 commit 6d2c2a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
File renamed without changes.
20 changes: 18 additions & 2 deletions tests/font/test_font_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

def test_with_system_font():
path = os.path.join(BASE_DIR, "ink.svg")
base = base64.b64encode(bytes(resvg_py.svg_to_bytes(svg_path=path))).decode("utf-8")
base = base64.b64encode(
bytes(resvg_py.svg_to_bytes(svg_path=path)),
).decode("utf-8")

assert base == output_dict["svg_font_output"]

Expand All @@ -32,7 +34,7 @@ def test_without_system_font():

def test_wtih_kokoro_font():
path = os.path.join(BASE_DIR, "ink.svg")
font = str(Path(BASE_DIR, "Kokoro-Regular.ttf"))
font = str(Path(BASE_DIR, "font_dir", "Kokoro-Regular.ttf"))
base = base64.b64encode(
bytes(
resvg_py.svg_to_bytes(
Expand All @@ -42,3 +44,17 @@ def test_wtih_kokoro_font():
).decode("utf-8")

assert base == output_dict["svg_with_kokoro_font_output"]


def test_font_directory():
path = os.path.join(BASE_DIR, "ink.svg")
font = str(Path(BASE_DIR, "font_dir"))
base = base64.b64encode(
bytes(
resvg_py.svg_to_bytes(
svg_path=path, skip_system_fonts=True, font_dirs=[font]
)
)
).decode("utf-8")

assert base == output_dict["svg_with_kokoro_font_output"]

0 comments on commit 6d2c2a9

Please sign in to comment.