]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
Add test for dotted circles in sample text
authorSimon Cozens <simon@simon-cozens.org>
Mon, 31 Oct 2022 11:13:45 +0000 (11:13 +0000)
committerSimon Cozens <simon@simon-cozens.org>
Mon, 31 Oct 2022 11:13:45 +0000 (11:13 +0000)
tests/test_dottedcircle.py [new file with mode: 0644]

diff --git a/tests/test_dottedcircle.py b/tests/test_dottedcircle.py
new file mode 100644 (file)
index 0000000..4594ac7
--- /dev/null
@@ -0,0 +1,30 @@
+import uharfbuzz as hb
+import gflanguages
+import pytest
+
+langs = gflanguages.LoadLanguages()
+
+
+@pytest.fixture
+def hb_font():
+    # Persuade Harfbuzz we have a font that supports
+    # every codepoint.
+    face = hb.Face(b"")
+    font = hb.Font(face)
+    funcs = hb.FontFuncs.create()
+    funcs.set_nominal_glyph_func((lambda font,cp,data: cp), None)
+    font.funcs = funcs
+    return font
+
+
+@pytest.mark.parametrize("lang", langs.keys())
+def test_dotted_circle(lang, hb_font):
+    item = langs[lang]
+    samples = [x for (_,x) in item.sample_text.ListFields()]
+    for sample in sorted(samples, key=lambda x:len(x)):
+        buf = hb.Buffer()
+        buf.add_str(sample)
+        buf.guess_segment_properties()
+        hb.shape(hb_font, buf)
+        ok = not any(info.codepoint == 0x25CC for info in buf.glyph_infos)
+        assert ok, f"Dotted circle found in {sample} ({lang})"