diff options
Diffstat (limited to 'frontends/gtk/layout_pango.c')
-rw-r--r-- | frontends/gtk/layout_pango.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c index 7c7190982..9e8e94d48 100644 --- a/frontends/gtk/layout_pango.c +++ b/frontends/gtk/layout_pango.c @@ -30,6 +30,7 @@ #include "utils/log.h" #include "utils/nsoption.h" +#include "netsurf/inttypes.h" #include "netsurf/layout.h" #include "netsurf/plot_style.h" @@ -42,12 +43,12 @@ static PangoLayout *nsfont_pango_layout = NULL; static inline void nsfont_pango_check(void) { if (nsfont_pango_context == NULL) { - LOG("Creating nsfont_pango_context."); + NSLOG(netsurf, INFO, "Creating nsfont_pango_context."); nsfont_pango_context = gdk_pango_context_get(); } if (nsfont_pango_layout == NULL) { - LOG("Creating nsfont_pango_layout."); + NSLOG(netsurf, INFO, "Creating nsfont_pango_layout."); nsfont_pango_layout = pango_layout_new(nsfont_pango_context); } } @@ -84,9 +85,10 @@ nsfont_width(const plot_font_style_t *fstyle, pango_layout_get_pixel_size(nsfont_pango_layout, width, 0); - /* LOG("fstyle: %p string:\"%.*s\", length: %u, width: %dpx", - fstyle, length, string, length, *width); - */ + NSLOG(netsurf, DEEPDEBUG, + "fstyle: %p string:\"%.*s\", length: %" PRIsizet ", width: %dpx", + fstyle, (int)length, string, length, *width); + return NSERROR_OK; } @@ -194,7 +196,7 @@ nsfont_split(const plot_font_style_t *fstyle, pango_layout_set_single_paragraph_mode(layout, TRUE); /* Obtain the second line of the layout (if there is one) */ - line = pango_layout_get_line(layout, 1); + line = pango_layout_get_line_readonly(layout, 1); if (line != NULL) { /* Pango split the text. The line's start_index indicates the * start of the character after the line break. */ @@ -222,32 +224,29 @@ nsfont_split(const plot_font_style_t *fstyle, * \param fstyle plot style for this text * \return true on success, false on error and error reported */ -bool nsfont_paint(int x, int y, const char *string, size_t length, +nserror nsfont_paint(int x, int y, const char *string, size_t length, const plot_font_style_t *fstyle) { PangoFontDescription *desc; - PangoLayout *layout; PangoLayoutLine *line; if (length == 0) - return true; + return NSERROR_OK; - layout = pango_cairo_create_layout(current_cr); + nsfont_pango_check(); desc = nsfont_style_to_description(fstyle); - pango_layout_set_font_description(layout, desc); + pango_layout_set_font_description(nsfont_pango_layout, desc); pango_font_description_free(desc); - pango_layout_set_text(layout, string, length); + pango_layout_set_text(nsfont_pango_layout, string, length); - line = pango_layout_get_line_readonly(layout, 0); + line = pango_layout_get_line_readonly(nsfont_pango_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); - - return true; + return NSERROR_OK; } @@ -278,7 +277,7 @@ nsfont_style_to_description(const plot_font_style_t *fstyle) break; } - size = (fstyle->size * PANGO_SCALE) / FONT_SIZE_SCALE; + size = (fstyle->size * PANGO_SCALE) / PLOT_STYLE_SCALE; if (fstyle->flags & FONTF_ITALIC) style = PANGO_STYLE_ITALIC; |