fix(freetpye): fix the problem of incomplete font drawing when setting with italic (#5807)

This commit is contained in:
Benign X
2024-03-07 12:38:25 +08:00
committed by GitHub
parent 87c57e3843
commit 11af91273e
3 changed files with 17 additions and 1 deletions
+9 -1
View File
@@ -20,6 +20,9 @@
#define ft_ctx LV_GLOBAL_DEFAULT()->ft_context
#define LV_FREETYPE_OUTLINE_REF_SIZE_DEF 128
/**< This value is from the FreeType's function `FT_GlyphSlot_Oblique` in `ftsynth.c` */
#define LV_FREETYPE_OBLIQUE_SLANT_DEF 0x5800
#if LV_FREETYPE_CACHE_FT_GLYPH_CNT <= 0
#error "LV_FREETYPE_CACHE_FT_GLYPH_CNT must be greater than 0"
#endif
@@ -244,12 +247,17 @@ void lv_freetype_italic_transform(FT_Face face)
LV_ASSERT_NULL(face);
FT_Matrix matrix;
matrix.xx = FT_INT_TO_F16DOT16(1);
matrix.xy = 0x5800;
matrix.xy = LV_FREETYPE_OBLIQUE_SLANT_DEF;
matrix.yx = 0;
matrix.yy = FT_INT_TO_F16DOT16(1);
FT_Set_Transform(face, &matrix, NULL);
}
int32_t lv_freetype_italic_transform_on_pos(lv_point_t point)
{
return point.x + FT_F16DOT16_TO_INT(point.y * LV_FREETYPE_OBLIQUE_SLANT_DEF);
}
const char * lv_freetype_get_pathname(FTC_FaceID face_id)
{
LV_ASSERT_NULL(face_id);
+7
View File
@@ -150,6 +150,13 @@ static bool freetype_glyph_create_cb(lv_freetype_glyph_cache_data_t * data, void
dsc_out->ofs_y = FT_F26DOT6_TO_INT(glyph->metrics.horiBearingY -
glyph->metrics.height); /*Y offset of the bitmap measured from the as line*/
dsc_out->format = LV_FONT_GLYPH_FORMAT_VECTOR;
/*Transform the glyph to italic if required*/
if(dsc->style & LV_FREETYPE_FONT_STYLE_ITALIC) {
dsc_out->box_w = lv_freetype_italic_transform_on_pos((lv_point_t) {
dsc_out->box_w, dsc_out->box_h
});
}
}
else if(dsc->render_mode == LV_FREETYPE_FONT_RENDER_MODE_BITMAP) {
FT_Bitmap * glyph_bitmap = &face->glyph->bitmap;
+1
View File
@@ -121,6 +121,7 @@ lv_freetype_context_t * lv_freetype_get_context(void);
FT_Size lv_freetype_lookup_size(const lv_freetype_font_dsc_t * dsc);
void lv_freetype_italic_transform(FT_Face face);
int32_t lv_freetype_italic_transform_on_pos(lv_point_t point);
const char * lv_freetype_get_pathname(FTC_FaceID face_id);