mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-23 07:46:36 +08:00
fix(tiny_ttf): fix GPOS lookup list table address (#8251)
This commit is contained in:
@@ -13,7 +13,9 @@ except ImportError:
|
||||
|
||||
# Fonts that are excluded from the license check
|
||||
# Only add fonts that are known to be public domain or have a compatible license
|
||||
_EXCLUDED_FONTS = {}
|
||||
_EXCLUDED_FONTS = {
|
||||
"OpenTypeTest GPOS One",
|
||||
}
|
||||
|
||||
# Font name mapping to remove any style suffix
|
||||
_FONT_NAME_MAP = {
|
||||
@@ -27,10 +29,13 @@ _FONT_NAME_MAP = {
|
||||
def get_font_full_name(font_path: str) -> str:
|
||||
font = TTFont(font_path)
|
||||
name_records = font["name"].names
|
||||
fallback = None
|
||||
for record in name_records:
|
||||
if record.nameID == 1: # ID 1 corresponds to the font family name and will be used if full name doesn't exists
|
||||
fallback = record.toStr()
|
||||
if record.nameID == 4: # ID 4 corresponds to the full font name
|
||||
return record.toStr()
|
||||
return None
|
||||
return fallback
|
||||
|
||||
|
||||
def list_intree_fonts(path: str) -> List[Tuple[str, str]]:
|
||||
|
||||
@@ -2758,7 +2758,7 @@ static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo * info, i
|
||||
if(ttUSHORT(data, 2 + info->gpos) != 0) return 0; // Minor version 0
|
||||
|
||||
lookupListOffset = ttUSHORT(data, 8 + info->gpos);
|
||||
lookupList = lookupListOffset;
|
||||
lookupList = info->gpos + lookupListOffset;
|
||||
lookupCount = ttUSHORT(data, lookupList);
|
||||
|
||||
for(i = 0; i < lookupCount; ++i) {
|
||||
@@ -2876,7 +2876,7 @@ STBTT_DEF int stbtt_KernTableCheck(const stbtt_fontinfo * info)
|
||||
if(ttUSHORT(data, 2 + info->gpos) != 0) return 0; // Minor version 0
|
||||
|
||||
lookupListOffset = ttUSHORT(data, 8 + info->gpos);
|
||||
lookupList = lookupListOffset;
|
||||
lookupList = info->gpos + lookupListOffset;
|
||||
lookupCount = ttUSHORT(data, lookupList);
|
||||
|
||||
for(i = 0; i < lookupCount; ++i) {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
@@ -82,4 +82,36 @@ void test_tiny_ttf_kerning(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_tiny_ttf_gpos(void)
|
||||
{
|
||||
#if LV_USE_TINY_TTF && LV_TINY_TTF_FILE_SUPPORT
|
||||
lv_font_t * font_normal = lv_tiny_ttf_create_file("A:src/test_assets/test_gpos_one.ttf", 60);
|
||||
lv_font_t * font_none = lv_tiny_ttf_create_file("A:src/test_assets/test_gpos_one.ttf", 60);
|
||||
lv_font_set_kerning(font_none, LV_FONT_KERNING_NONE);
|
||||
|
||||
lv_obj_t * label_normal = lv_label_create(lv_screen_active());
|
||||
lv_label_set_long_mode(label_normal, LV_LABEL_LONG_WRAP);
|
||||
lv_label_set_text(label_normal, "ĄJ Ąg Ąģ Ąj Ąȷ Qȷ ąj ąȷ gȷ ģȷ ıȷ ųȷ vȷ Va Vá Vą Vf Vfl V.");
|
||||
lv_obj_set_style_text_font(label_normal, font_normal, LV_PART_MAIN);
|
||||
lv_obj_set_width(label_normal, 700);
|
||||
lv_obj_set_style_text_align(label_normal, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(label_normal, LV_ALIGN_CENTER, 0, -100);
|
||||
|
||||
lv_obj_t * label_none = lv_label_create(lv_screen_active());
|
||||
lv_label_set_long_mode(label_normal, LV_LABEL_LONG_WRAP);
|
||||
lv_label_set_text(label_none, "ĄJ Ąg Ąģ Ąj Ąȷ Qȷ ąj ąȷ gȷ ģȷ ıȷ ųȷ vȷ Va Vá Vą Vf Vfl V.");
|
||||
lv_obj_set_style_text_font(label_none, font_none, LV_PART_MAIN);
|
||||
lv_obj_set_width(label_none, 700);
|
||||
lv_obj_set_style_text_align(label_none, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(label_none, LV_ALIGN_CENTER, 0, 100);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("libs/tiny_ttf_3.png");
|
||||
|
||||
lv_tiny_ttf_destroy(font_normal);
|
||||
lv_tiny_ttf_destroy(font_none);
|
||||
#else
|
||||
TEST_IGNORE_MESSAGE("Ignoring test_tiny_ttf_gpos as it requires LV_USE_TINY_TTF && LV_TINY_TTF_FILE_SUPPORT");
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user