mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-20 11:12:46 +03:00
Can free pango font desc as soon as it's set.
This commit is contained in:
parent
51084243a2
commit
3af77eabd8
@ -94,12 +94,12 @@ bool nsfont_width(const plot_font_style_t *fstyle,
|
||||
|
||||
desc = nsfont_style_to_description(fstyle);
|
||||
pango_layout_set_font_description(nsfont_pango_layout, desc);
|
||||
pango_font_description_free(desc);
|
||||
|
||||
pango_layout_set_text(nsfont_pango_layout, string, length);
|
||||
|
||||
pango_layout_get_pixel_size(nsfont_pango_layout, width, 0);
|
||||
|
||||
pango_font_description_free(desc);
|
||||
|
||||
/* LOG("fstyle: %p string:\"%.*s\", length: %u, width: %dpx",
|
||||
fstyle, length, string, length, *width);
|
||||
*/
|
||||
@ -132,6 +132,8 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
|
||||
|
||||
desc = nsfont_style_to_description(fstyle);
|
||||
pango_layout_set_font_description(nsfont_pango_layout, desc);
|
||||
pango_font_description_free(desc);
|
||||
|
||||
pango_layout_set_text(nsfont_pango_layout, string, length);
|
||||
|
||||
if (pango_layout_xy_to_index(nsfont_pango_layout, x * PANGO_SCALE,
|
||||
@ -140,8 +142,6 @@ bool nsfont_position_in_string(const plot_font_style_t *fstyle,
|
||||
|
||||
pango_layout_index_to_pos(nsfont_pango_layout, index, &pos);
|
||||
|
||||
pango_font_description_free(desc);
|
||||
|
||||
*char_offset = index;
|
||||
*actual_x = PANGO_PIXELS(pos.x);
|
||||
|
||||
@ -182,10 +182,13 @@ bool nsfont_split(const plot_font_style_t *fstyle,
|
||||
PangoLayout *layout;
|
||||
PangoLayoutLine *line;
|
||||
|
||||
desc = nsfont_style_to_description(fstyle);
|
||||
context = gdk_pango_context_get();
|
||||
layout = pango_layout_new(context);
|
||||
|
||||
desc = nsfont_style_to_description(fstyle);
|
||||
pango_layout_set_font_description(layout, desc);
|
||||
pango_font_description_free(desc);
|
||||
|
||||
pango_layout_set_text(layout, string, length);
|
||||
|
||||
/* Limit width of layout to the available width */
|
||||
@ -207,7 +210,6 @@ bool nsfont_split(const plot_font_style_t *fstyle,
|
||||
|
||||
g_object_unref(layout);
|
||||
g_object_unref(context);
|
||||
pango_font_description_free(desc);
|
||||
|
||||
*char_offset = index;
|
||||
/* Obtain the pixel offset of the split character */
|
||||
@ -238,20 +240,20 @@ bool nsfont_paint(int x, int y, const char *string, size_t length,
|
||||
if (length == 0)
|
||||
return true;
|
||||
|
||||
desc = nsfont_style_to_description(fstyle);
|
||||
|
||||
layout = pango_cairo_create_layout(current_cr);
|
||||
|
||||
desc = nsfont_style_to_description(fstyle);
|
||||
pango_layout_set_font_description(layout, desc);
|
||||
pango_layout_set_text(layout, string, length);
|
||||
line = pango_layout_get_line_readonly(layout, 0);
|
||||
pango_font_description_free(desc);
|
||||
|
||||
pango_layout_set_text(layout, string, length);
|
||||
|
||||
line = pango_layout_get_line_readonly(layout, 0);
|
||||
cairo_move_to(current_cr, x, y);
|
||||
nsgtk_set_colour(fstyle->foreground);
|
||||
pango_cairo_show_layout_line(current_cr, line);
|
||||
|
||||
g_object_unref(layout);
|
||||
pango_font_description_free(desc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user