-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from moi15moi/Fallback-decode-name
Fallback decode name
- Loading branch information
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from font_collector.font_parser import FontParser | ||
from fontTools.ttLib.tables._n_a_m_e import NameRecord | ||
|
||
|
||
def test_fallback_encoding(): | ||
# The string are from the font in this pack: https://github.com/libass/libass/issues/643#issuecomment-1476459274 | ||
|
||
# 微软简标宋 - PlatEncID 3.TTF | ||
name_record = NameRecord() | ||
name_record.nameID = 1 | ||
name_record.string = b"\x00\xce\x00\xa2\x00\xc8\x00\xed\x00\xbc\x00\xf2\x00\xb1\x00\xea\x00\xcb\x00\xce" | ||
name_record.platformID = 3 | ||
name_record.platEncID = 3 | ||
name_record.langID = 0 | ||
FontParser.get_decoded_name(name_record) == "微软简标宋" | ||
|
||
# 文鼎中特廣告體 - PlatEncID 4.ttf | ||
name_record = NameRecord() | ||
name_record.nameID = 1 | ||
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" | ||
name_record.platformID = 3 | ||
name_record.platEncID = 4 | ||
name_record.langID = 0 | ||
FontParser.get_decoded_name(name_record) == "文鼎中特廣告體" |