-
Notifications
You must be signed in to change notification settings - Fork 682
Closed
Description
Hello,
We use harfbuzz inside of mobile application Galileo along with SDF renderer. Extremely satisfied by result.
Recently I've looked in profiler to find new bottlenecks and noticed that FT_Load_Glyph causes huge performance slow down on devices with slow internal memory (e.g. iPhone 6). It' takes up to 2 seconds to compute extents and load glyphs information. Mostly because FT_Load_Glyph is slow and calls to FT_Load_Glyph is not cached.
I suggest to use FreeType cache system instead of reading the same data over and over again. What do you think?
Lines 250 to 275 in 20e69c9
| static hb_bool_t | |
| hb_ft_get_glyph_v_origin (hb_font_t *font HB_UNUSED, | |
| void *font_data, | |
| hb_codepoint_t glyph, | |
| hb_position_t *x, | |
| hb_position_t *y, | |
| void *user_data HB_UNUSED) | |
| { | |
| const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; | |
| FT_Face ft_face = ft_font->ft_face; | |
| if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags))) | |
| return false; | |
| /* Note: FreeType's vertical metrics grows downward while other FreeType coordinates | |
| * have a Y growing upward. Hence the extra negation. */ | |
| *x = ft_face->glyph->metrics.horiBearingX - ft_face->glyph->metrics.vertBearingX; | |
| *y = ft_face->glyph->metrics.horiBearingY - (-ft_face->glyph->metrics.vertBearingY); | |
| if (font->x_scale < 0) | |
| *x = -*x; | |
| if (font->y_scale < 0) | |
| *y = -*y; | |
| return true; | |
| } |
Lines 294 to 322 in 20e69c9
| static hb_bool_t | |
| hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED, | |
| void *font_data, | |
| hb_codepoint_t glyph, | |
| hb_glyph_extents_t *extents, | |
| void *user_data HB_UNUSED) | |
| { | |
| const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; | |
| FT_Face ft_face = ft_font->ft_face; | |
| if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags))) | |
| return false; | |
| extents->x_bearing = ft_face->glyph->metrics.horiBearingX; | |
| extents->y_bearing = ft_face->glyph->metrics.horiBearingY; | |
| extents->width = ft_face->glyph->metrics.width; | |
| extents->height = -ft_face->glyph->metrics.height; | |
| if (font->x_scale < 0) | |
| { | |
| extents->x_bearing = -extents->x_bearing; | |
| extents->width = -extents->width; | |
| } | |
| if (font->y_scale < 0) | |
| { | |
| extents->y_bearing = -extents->y_bearing; | |
| extents->height = -extents->height; | |
| } | |
| return true; | |
| } |
Lines 324 to 349 in 20e69c9
| static hb_bool_t | |
| hb_ft_get_glyph_contour_point (hb_font_t *font HB_UNUSED, | |
| void *font_data, | |
| hb_codepoint_t glyph, | |
| unsigned int point_index, | |
| hb_position_t *x, | |
| hb_position_t *y, | |
| void *user_data HB_UNUSED) | |
| { | |
| const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; | |
| FT_Face ft_face = ft_font->ft_face; | |
| if (unlikely (FT_Load_Glyph (ft_face, glyph, ft_font->load_flags))) | |
| return false; | |
| if (unlikely (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)) | |
| return false; | |
| if (unlikely (point_index >= (unsigned int) ft_face->glyph->outline.n_points)) | |
| return false; | |
| *x = ft_face->glyph->outline.points[point_index].x; | |
| *y = ft_face->glyph->outline.points[point_index].y; | |
| return true; | |
| } |
Metadata
Metadata
Assignees
Labels
No labels