Skip to content

Commit

Permalink
fix(freetype) fix underline calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Oct 21, 2021
1 parent c2d93f7 commit 76c8ee6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/extra/libs/freetype/lv_freetype.c
Expand Up @@ -264,8 +264,11 @@ static bool lv_ft_font_init_cache(lv_ft_info_t * info)
font->subpx = LV_FONT_SUBPX_NONE;
font->line_height = (face_size->face->size->metrics.height >> 6);
font->base_line = -(face_size->face->size->metrics.descender >> 6);
font->underline_position = face_size->face->underline_position;
font->underline_thickness = face_size->face->underline_thickness;

FT_Fixed scale = face_size->face->size->metrics.y_scale;
int8_t thickness = FT_MulFix(scale, face_size->face->underline_thickness) >> 6;
font->underline_position = FT_MulFix(scale, face_size->face->underline_position) >> 6;
font->underline_thickness = thickness < 1 ? 1 : thickness;

/* return to user */
info->font = font;
Expand Down Expand Up @@ -446,10 +449,13 @@ static bool lv_ft_font_init_nocache(lv_ft_info_t * info)
font->get_glyph_bitmap = get_glyph_bitmap_cb_nocache;
font->line_height = (face->size->metrics.height >> 6);
font->base_line = -(face->size->metrics.descender >> 6);
font->underline_position = face->underline_position;
font->underline_thickness = face->underline_thickness;
font->subpx = LV_FONT_SUBPX_NONE;

FT_Fixed scale = face->size->metrics.y_scale;
int8_t thickness = FT_MulFix(scale, face->underline_thickness) >> 6;
font->underline_position = FT_MulFix(scale, face->underline_position) >> 6;
font->underline_thickness = thickness < 1 ? 1 : thickness;

info->font = font;
return true;

Expand Down

0 comments on commit 76c8ee6

Please sign in to comment.