Skip to content

Commit

Permalink
修复字形位图原点计算
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Sep 3, 2024
1 parent 30702d1 commit 36f012b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/services/font_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ def _create_builder(self, width_mode: WidthMode, language_flavor: LanguageFlavor
if glyph_file.file_path in glyph_pool:
glyph = glyph_pool[glyph_file.file_path]
else:
horizontal_origin_y = math.floor((layout_param.ascent + layout_param.descent - glyph_file.height) / 2)
horizontal_origin_x = 0
horizontal_origin_y = (layout_param.ascent + layout_param.descent - glyph_file.height) // 2
vertical_origin_x = -math.ceil(glyph_file.width / 2)
vertical_origin_y = (self.font_size - glyph_file.height) // 2 - 1
glyph = Glyph(
name=glyph_file.glyph_name,
horizontal_origin=(horizontal_origin_x, horizontal_origin_y),
advance_width=glyph_file.width,
vertical_origin=(vertical_origin_x, vertical_origin_y),
advance_height=self.font_size,
horizontal_origin=(0, horizontal_origin_y),
vertical_origin_y=vertical_origin_y,
bitmap=glyph_file.bitmap.data,
)
glyph_pool[glyph_file.file_path] = glyph
Expand Down

0 comments on commit 36f012b

Please sign in to comment.