Skip to content

Commit 5b7a092

Browse files
committed
Add test for get_missing_glyphs for encoding 3 and 4
1 parent 87aee52 commit 5b7a092

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

2.84 MB
Binary file not shown.
5.58 MB
Binary file not shown.

tests/font/test_name.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ def test_get_name_encoding():
105105

106106

107107
def test_get_decoded_name():
108-
# The string are from the font in this pack: https://github.com/libass/libass/issues/643#issuecomment-1476459274
109-
110-
# 微软简标宋 - PlatEncID 3.TTF
108+
# tests\fonts\微软简标宋 - PlatEncID 3.TTF
111109
name_record = NameRecord()
112110
name_record.nameID = 1
113111
name_record.string = b"\x00\xce\x00\xa2\x00\xc8\x00\xed\x00\xbc\x00\xf2\x00\xb1\x00\xea\x00\xcb\x00\xce"
@@ -116,7 +114,7 @@ def test_get_decoded_name():
116114
name_record.langID = 0
117115
Name.get_decoded_name_record(name_record) == "微软简标宋"
118116

119-
# 文鼎中特廣告體 - PlatEncID 4.ttf
117+
# tests\fonts\文鼎中特廣告體 - PlatEncID 4.ttf
120118
name_record = NameRecord()
121119
name_record.nameID = 1
122120
name_record.string = b"\x00\xa4\x00\xe5\x00\xb9\x00\xa9\x00\xa4\x00\xa4\x00\xaf\x00S\x00\xbc\x00s\x00\xa7\x00i\x00\xc5\x00\xe9"

tests/font/test_normal_font_face.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,32 @@ def test_font_get_missing_glyphs_cmap_encoding_2():
185185
assert missing_glyphs == {"é"}
186186

187187

188+
def test_font_get_missing_glyphs_cmap_encoding_3():
189+
font_cmap_encoding_3 = Path(os.path.join(os.path.dirname(dir_path), "file", "fonts", "微软简标宋 - PlatEncID 3.TTF"))
190+
font_file = FontFile.from_font_path(font_cmap_encoding_3)
191+
192+
assert len(font_file.font_faces) == 1
193+
font_face = font_file.font_faces[0]
194+
assert isinstance(font_face, NormalFontFace)
195+
196+
# Try "ヲ" since cp936 doesn't support this char
197+
missing_glyphs = font_face.get_missing_glyphs("AÉé㈤ヲ")
198+
assert missing_glyphs == {"É", "ヲ"}
199+
200+
201+
def test_font_get_missing_glyphs_cmap_encoding_4():
202+
font_cmap_encoding_4 = Path(os.path.join(os.path.dirname(dir_path), "file", "fonts", "文鼎中特廣告體 - PlatEncID 4.ttf"))
203+
font_file = FontFile.from_font_path(font_cmap_encoding_4)
204+
205+
assert len(font_file.font_faces) == 1
206+
font_face = font_file.font_faces[0]
207+
assert isinstance(font_face, NormalFontFace)
208+
209+
# Try "ヲ" since cp950 doesn't support this char
210+
missing_glyphs = font_face.get_missing_glyphs("é¥卷ヲ")
211+
assert missing_glyphs == {"é", "ヲ"}
212+
213+
188214
def test_font_get_missing_glyphs_cmap_legacy_arabic_simplified():
189215
font_path = Path(os.path.join(os.path.dirname(dir_path), "file", "fonts", "legacy-arabic-simplified-SimplifiedArabic.ttf"))
190216
font_file = FontFile.from_font_path(font_path)

0 commit comments

Comments
 (0)