From 6d2c2a94df3ad11e4d35bc5e8820340c6b2eb02c Mon Sep 17 00:00:00 2001 From: baseplate-admin <61817579+baseplate-admin@users.noreply.github.com> Date: Fri, 10 May 2024 08:22:12 +0600 Subject: [PATCH] Add font directory testing --- tests/font/{ => font_dir}/Kokoro-Regular.ttf | Bin tests/font/test_font_render.py | 20 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) rename tests/font/{ => font_dir}/Kokoro-Regular.ttf (100%) diff --git a/tests/font/Kokoro-Regular.ttf b/tests/font/font_dir/Kokoro-Regular.ttf similarity index 100% rename from tests/font/Kokoro-Regular.ttf rename to tests/font/font_dir/Kokoro-Regular.ttf diff --git a/tests/font/test_font_render.py b/tests/font/test_font_render.py index c1a912e..d5142e7 100644 --- a/tests/font/test_font_render.py +++ b/tests/font/test_font_render.py @@ -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"] @@ -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( @@ -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"]