Skip to content

Commit

Permalink
glyph_name 添加前缀 u 以符合 adobe .fea 文件规范的要求
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Dec 11, 2024
1 parent 8bdb6f3 commit bf7d29d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pixel_font_knife/glyph_file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def glyph_name(self) -> str:
if self.code_point == -1:
return '.notdef'

name = f'{self.code_point:04X}'
name = f'u{self.code_point:04X}'
if len(self.flavors) > 0:
name = f'{name}-{self.flavors[0].upper()}'
return name
Expand Down
12 changes: 6 additions & 6 deletions tests/test_glyph_file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def test_glyph_file_3():
glyph_file = GlyphFile.load(Path('4E00.png'))
assert glyph_file.code_point == 0x4E00
assert len(glyph_file.flavors) == 0
assert glyph_file.glyph_name == '4E00'
assert glyph_file.glyph_name == 'u4E00'


def test_glyph_file_4():
glyph_file = GlyphFile.load(Path('4E00 A,b,C,b,a.png'))
assert glyph_file.code_point == 0x4E00
assert glyph_file.flavors == ['a', 'b', 'c']
assert glyph_file.glyph_name == '4E00-A'
assert glyph_file.glyph_name == 'u4E00-A'


def test_glyph_file_5(glyphs_dir: Path):
Expand Down Expand Up @@ -90,12 +90,12 @@ def test_context(glyphs_dir: Path):
assert group_6aa4.get_file('zh_tr') is group_6aa4.get_file('ko')

assert glyph_file_util.get_character_mapping(context) == {
0x4E11: '4E11',
0x6AA4: '6AA4',
0x4E11: 'u4E11',
0x6AA4: 'u6AA4',
}
assert glyph_file_util.get_character_mapping(context, 'zh_cn') == {
0x4E11: '4E11-ZH_CN',
0x6AA4: '6AA4',
0x4E11: 'u4E11-ZH_CN',
0x6AA4: 'u6AA4',
}

assert [glyph_file.file_path for glyph_file in glyph_file_util.get_glyph_sequence(context, [None, 'zh_cn', 'zh_hk'])] == [
Expand Down

0 comments on commit bf7d29d

Please sign in to comment.