diff --git a/tools/services/font_service.py b/tools/services/font_service.py index 73b772d..dd59b5a 100644 --- a/tools/services/font_service.py +++ b/tools/services/font_service.py @@ -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: @@ -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 diff --git a/tools/services/template_service.py b/tools/services/template_service.py index 9e10c23..7e9cef2 100644 --- a/tools/services/template_service.py +++ b/tools/services/template_service.py @@ -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) @@ -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')