test_dottedcircle.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import uharfbuzz as hb
  2. import gflanguages
  3. import pytest
  4. langs = gflanguages.LoadLanguages()
  5. xfail_langs = {"kkh_Lana": "Tai Tham encoding is over-differentiated (see L2/19-365)"}
  6. @pytest.fixture
  7. def hb_font():
  8. # Persuade Harfbuzz we have a font that supports
  9. # every codepoint.
  10. face = hb.Face(b"")
  11. font = hb.Font(face)
  12. funcs = hb.FontFuncs.create()
  13. funcs.set_nominal_glyph_func((lambda font, cp, data: cp), None)
  14. font.funcs = funcs
  15. return font
  16. @pytest.mark.parametrize("lang", langs.keys())
  17. def test_dotted_circle(lang, hb_font):
  18. if lang in xfail_langs:
  19. pytest.xfail("Language is expected to fail: " + xfail_langs[lang])
  20. item = langs[lang]
  21. samples = item.sample_text.ListFields()
  22. for sample_name, sample in sorted(samples, key=lambda x: len(x[1])):
  23. buf = hb.Buffer()
  24. buf.add_str(sample)
  25. buf.guess_segment_properties()
  26. hb.shape(hb_font, buf)
  27. ok = not any(info.codepoint == 0x25CC for info in buf.glyph_infos)
  28. assert ok, f"Dotted circle found in {sample} ({lang}.{sample_name.name})"