Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Commit

Permalink
调整字体格式构建逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Jul 26, 2023
1 parent 7b0d5a4 commit 83368d1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions services/font_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os

from pixel_font_builder import FontBuilder, Glyph, StyleName, SerifMode, WidthMode
from pixel_font_builder.opentype import Flavor

from configs import path_define, FontConfig
from utils import fs_util, glyph_util
Expand Down Expand Up @@ -113,17 +114,19 @@ def make_font_files(font_config: FontConfig, character_mapping: dict[int, str],
fs_util.make_dirs(font_config.outputs_dir)

builder = _create_builder(font_config, character_mapping, glyph_file_paths)
otf_builder = builder.to_otf_builder()

otf_file_path = os.path.join(font_config.outputs_dir, f'{font_config.full_outputs_name}.otf')
otf_builder.save(otf_file_path)
builder.save_otf(otf_file_path)
logger.info("Make font file: '%s'", otf_file_path)
otf_builder.font.flavor = 'woff2'

woff2_file_path = os.path.join(font_config.outputs_dir, f'{font_config.full_outputs_name}.woff2')
otf_builder.save(woff2_file_path)
builder.save_otf(woff2_file_path, flavor=Flavor.WOFF2)
logger.info("Make font file: '%s'", woff2_file_path)

ttf_file_path = os.path.join(font_config.outputs_dir, f'{font_config.full_outputs_name}.ttf')
builder.save_ttf(ttf_file_path)
logger.info("Make font file: '%s'", ttf_file_path)

bdf_file_path = os.path.join(font_config.outputs_dir, f'{font_config.full_outputs_name}.bdf')
builder.save_bdf(bdf_file_path)
logger.info("Make font file: '%s'", bdf_file_path)

0 comments on commit 83368d1

Please sign in to comment.