Skip to content

Commit

Permalink
调整字母表类型问题
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Jul 16, 2024
1 parent 4ff7dae commit 4f455e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tools/services/font_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from tools.configs.font import FontConfig


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

if font_config.fallback_lower_from_upper:
Expand All @@ -26,7 +26,7 @@ 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 = [chr(code_point) for code_point in context if code_point >= 0]
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
8 changes: 4 additions & 4 deletions tools/services/template_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def _make_html(template_name: str, file_path: Path, params: dict[str, object] |
logger.info("Make html: '{}'", file_path)


def make_alphabet_html(font_config: FontConfig, alphabet: list[str]):
def make_alphabet_html(font_config: FontConfig, alphabet: set[str]):
_make_html('alphabet.html', font_config.outputs_dir.joinpath('alphabet.html'), {
'font_config': font_config,
'alphabet': ''.join(alphabet),
'alphabet': ''.join(sorted(alphabet)),
})


def _handle_demo_html_element(alphabet: list[str], soup: bs4.BeautifulSoup, element: bs4.PageElement):
def _handle_demo_html_element(alphabet: set[str], soup: bs4.BeautifulSoup, element: bs4.PageElement):
if isinstance(element, bs4.element.Tag):
for child_element in list(element.contents):
_handle_demo_html_element(alphabet, soup, child_element)
Expand Down Expand Up @@ -75,7 +75,7 @@ def _handle_demo_html_element(alphabet: list[str], soup: bs4.BeautifulSoup, elem
tmp_parent.unwrap()


def make_demo_html(font_config: FontConfig, alphabet: list[str]):
def make_demo_html(font_config: FontConfig, alphabet: set[str]):
content_html = _environment.get_template('demo-content.html').render(font_config=font_config)
content_html = ''.join(line.strip() for line in content_html.split('\n'))
soup = bs4.BeautifulSoup(content_html, 'html.parser')
Expand Down

0 comments on commit 4f455e3

Please sign in to comment.