Skip to content

Commit

Permalink
升级依赖,并修复上下文加载
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Jul 10, 2024
1 parent 02dcd85 commit 51b7d44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pixel-font-builder==0.0.27
pixel-font-knife==0.0.3
pixel-font-knife==0.0.4
unidata-blocks==0.0.13
pillow==10.4.0
beautifulsoup4==4.12.3
Expand Down
22 changes: 4 additions & 18 deletions tools/services/font_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
from tools.configs.font import FontConfig


def _get_glyph_name(glyph_file: GlyphFile) -> str:
if glyph_file.code_point == -1:
return '.notdef'
else:
return f'{glyph_file.code_point:04X}'


def collect_glyph_files(font_config: FontConfig) -> tuple[list[str], dict[int, str], list[GlyphFile]]:
context = glyph_file_util.load_context(font_config.glyphs_dir)

Expand All @@ -33,16 +26,9 @@ def collect_glyph_files(font_config: FontConfig) -> tuple[list[str], dict[int, s
if code_point in context and fallback_code_point not in context:
context[fallback_code_point] = context[code_point]

alphabet = []
character_mapping = {}
glyph_sequence = []
for code_point, flavor_group in sorted(context.items()):
glyph_file = flavor_group.get_file()
if code_point != -1:
alphabet.append(chr(code_point))
character_mapping[code_point] = _get_glyph_name(glyph_file)
if glyph_file not in glyph_sequence:
glyph_sequence.append(glyph_file)
alphabet = [chr(code_point) for code_point in context if code_point >= 0]
character_mapping = glyph_file_util.get_character_mapping(context)
glyph_sequence = glyph_file_util.get_glyph_sequence(context)
return alphabet, character_mapping, glyph_sequence


Expand Down Expand Up @@ -79,7 +65,7 @@ def _create_builder(font_config: FontConfig, character_mapping: dict[int, str],
horizontal_origin_y = math.floor((font_config.ascent + font_config.descent - glyph_file.height) / 2)
vertical_origin_y = (font_config.font_size - glyph_file.height) // 2
builder.glyphs.append(Glyph(
name=_get_glyph_name(glyph_file),
name=glyph_file.glyph_name,
advance_width=glyph_file.width,
advance_height=font_config.font_size,
horizontal_origin=(0, horizontal_origin_y),
Expand Down

0 comments on commit 51b7d44

Please sign in to comment.