1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-15 12:25:11 +03:00

Fixed font bitmap generation

This commit is contained in:
Raphael Coeffic 2021-05-30 12:21:22 +02:00
parent 703bb6c20e
commit da64a36fdd
8 changed files with 6 additions and 3 deletions

View file

@ -41,7 +41,7 @@ macro(add_truetype_font_target name size subset effect args)
OUTPUT ${target}.png ${target}.specs ${target}.lbm OUTPUT ${target}.png ${target}.specs ${target}.lbm
COMMAND ${PYTHON_EXECUTABLE} ${TOOLS_DIR}/build-font-bitmap.py --subset ${subset} --size ${size} --font ${font} --output ${target} COMMAND ${PYTHON_EXECUTABLE} ${TOOLS_DIR}/build-font-bitmap.py --subset ${subset} --size ${size} --font ${font} --output ${target}
COMMAND ${PYTHON_EXECUTABLE} ${UTILS_DIR}/bin2lbm.py ${target}.png ${target}.lbm COMMAND ${PYTHON_EXECUTABLE} ${UTILS_DIR}/bin2lbm.py ${target}.png ${target}.lbm
DEPENDS ${TOOLS_DIR}/build-font-bitmap.py ${TOOLS_DIR}/charset.py ${LIBOPENUI_TOOLS_DIR}/encode-bitmap.py ${RADIO_SRC_DIR}/translations/cn.h.txt ${RADIO_SRC_DIR}/fonts/extra_${size}px.png DEPENDS ${TOOLS_DIR}/build-font-bitmap.py ${TOOLS_DIR}/charset.py ${LIBOPENUI_TOOLS_DIR}/encode-bitmap.py
) )
add_custom_target(truetype_font_${name} DEPENDS ${target}.png ${target}.specs) add_custom_target(truetype_font_${name} DEPENDS ${target}.png ${target}.specs)
set(truetype_fonts_targets ${truetype_fonts_targets} truetype_font_${name}) set(truetype_fonts_targets ${truetype_fonts_targets} truetype_font_${name})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -7,6 +7,7 @@ import sys
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from charset import get_chars, special_chars, extra_chars, standard_chars, is_cjk_char from charset import get_chars, special_chars, extra_chars, standard_chars, is_cjk_char
EXTRA_BITMAP_MAX_WIDTH = 297
class FontBitmap: class FontBitmap:
def __init__(self, language, font_size, font_name, foreground, background): def __init__(self, language, font_size, font_name, foreground, background):
@ -17,7 +18,9 @@ class FontBitmap:
self.background = background self.background = background
self.font = self.load_font(font_name) self.font = self.load_font(font_name)
self.extra_bitmap = self.load_extra_bitmap() self.extra_bitmap = self.load_extra_bitmap()
#self.extra_bitmap = None self.extra_bitmap_width = EXTRA_BITMAP_MAX_WIDTH
if self.extra_bitmap is not None:
self.extra_bitmap_width = self.extra_bitmap.width
def load_extra_bitmap(self): def load_extra_bitmap(self):
try: try:
@ -63,7 +66,7 @@ class FontBitmap:
(_,baseline), (offset_x, offset_y) = self.font.font.getsize(self.chars) (_,baseline), (offset_x, offset_y) = self.font.font.getsize(self.chars)
(text_width, text_height) = self.get_text_dimensions(self.chars) (text_width, text_height) = self.get_text_dimensions(self.chars)
img_width = text_width + self.extra_bitmap.width img_width = text_width + self.extra_bitmap_width
image = Image.new("RGB", (img_width, text_height), self.background) image = Image.new("RGB", (img_width, text_height), self.background)
draw = ImageDraw.Draw(image) draw = ImageDraw.Draw(image)