diff --git a/scripts/font_license_verify.py b/scripts/font_license_verify.py index 5a001f78fb..7b01f29ad1 100644 --- a/scripts/font_license_verify.py +++ b/scripts/font_license_verify.py @@ -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]]: diff --git a/src/libs/tiny_ttf/stb_truetype_htcw.h b/src/libs/tiny_ttf/stb_truetype_htcw.h index 1cd3e2abe9..d2dc388be0 100644 --- a/src/libs/tiny_ttf/stb_truetype_htcw.h +++ b/src/libs/tiny_ttf/stb_truetype_htcw.h @@ -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) { diff --git a/tests/ref_imgs/libs/tiny_ttf_3.png b/tests/ref_imgs/libs/tiny_ttf_3.png new file mode 100644 index 0000000000..6f830c3873 Binary files /dev/null and b/tests/ref_imgs/libs/tiny_ttf_3.png differ diff --git a/tests/ref_imgs_vg_lite/libs/tiny_ttf_3.png b/tests/ref_imgs_vg_lite/libs/tiny_ttf_3.png new file mode 100644 index 0000000000..ceb4f3400a Binary files /dev/null and b/tests/ref_imgs_vg_lite/libs/tiny_ttf_3.png differ diff --git a/tests/src/test_assets/test_gpos_one.ttf b/tests/src/test_assets/test_gpos_one.ttf new file mode 100644 index 0000000000..ea74dd0bef Binary files /dev/null and b/tests/src/test_assets/test_gpos_one.ttf differ diff --git a/tests/src/test_cases/libs/test_tiny_ttf.c b/tests/src/test_cases/libs/test_tiny_ttf.c index 2f82b765d2..55111d8958 100644 --- a/tests/src/test_cases/libs/test_tiny_ttf.c +++ b/tests/src/test_cases/libs/test_tiny_ttf.c @@ -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