From 1754d11958b4a695f39038c8c05555050ea2e471 Mon Sep 17 00:00:00 2001 From: TakWolf Date: Tue, 2 Jul 2024 19:36:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/services/font_service.py | 3 +-- tools/services/info_service.py | 7 ++----- tools/services/template_service.py | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/services/font_service.py b/tools/services/font_service.py index 38cb92d2..39f2c672 100644 --- a/tools/services/font_service.py +++ b/tools/services/font_service.py @@ -203,8 +203,7 @@ def _get_sequence(self, width_mode: str) -> list[int]: else: sequence = set(self._glyph_file_registry['common']) sequence.update(self._glyph_file_registry[width_mode]) - sequence = list(sequence) - sequence.sort() + sequence = sorted(sequence) self._sequence_pool[width_mode] = sequence return sequence diff --git a/tools/services/info_service.py b/tools/services/info_service.py index 0e393de2..8d8f548b 100644 --- a/tools/services/info_service.py +++ b/tools/services/info_service.py @@ -23,9 +23,7 @@ def _get_unicode_chr_count_infos(alphabet: set[str]) -> list[tuple[UnicodeBlock, if not c.isprintable() and block.printable_count > 0: continue count_infos[block.code_start] += 1 - code_starts = list(count_infos) - code_starts.sort() - return [(unidata_blocks.get_block_by_code_point(code_start), count_infos[code_start]) for code_start in code_starts] + return [(unidata_blocks.get_block_by_code_point(code_start), count) for code_start, count in sorted(count_infos.items())] def _get_locale_chr_count_infos(alphabet: set[str], query_category_func: Callable[[str], str | None]) -> defaultdict[str, int]: @@ -153,8 +151,7 @@ def make_font_info(design_context: DesignContext, width_mode: str): def make_alphabet_txt(design_context: DesignContext, width_mode: str): - alphabet = list(design_context.get_alphabet(width_mode)) - alphabet.sort() + alphabet = sorted(design_context.get_alphabet(width_mode)) path_define.outputs_dir.mkdir(parents=True, exist_ok=True) file_path = path_define.outputs_dir.joinpath(f'alphabet-{design_context.font_config.font_size}px-{width_mode}.txt') diff --git a/tools/services/template_service.py b/tools/services/template_service.py index 866e45ad..9782b5ab 100644 --- a/tools/services/template_service.py +++ b/tools/services/template_service.py @@ -46,7 +46,7 @@ def make_alphabet_html(design_context: DesignContext, width_mode: str): _make_html('alphabet.html', f'alphabet-{design_context.font_config.font_size}px-{width_mode}.html', { 'font_config': design_context.font_config, 'width_mode': width_mode, - 'alphabet': ''.join(sorted([c for c in design_context.get_alphabet(width_mode) if ord(c) >= 128])), + 'alphabet': ''.join(sorted(c for c in design_context.get_alphabet(width_mode) if ord(c) >= 128)), })