diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2012-07-31 14:06:57 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2012-07-31 14:06:57 +0100 |
commit | 90b0c48bb216cef4f3aafbc14565f203a3f6861c (patch) | |
tree | 301d766e84983e9221af5a95d95cc65716dd6151 /framebuffer/fbtk | |
parent | f6436d54c8aa367828433a59ba16ffbeac8444c3 (diff) | |
download | netsurf-90b0c48bb216cef4f3aafbc14565f203a3f6861c.tar.gz netsurf-90b0c48bb216cef4f3aafbc14565f203a3f6861c.tar.bz2 |
Split out common code to generate a font style for text input widget.
Diffstat (limited to 'framebuffer/fbtk')
-rw-r--r-- | framebuffer/fbtk/text.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c index f50a5ad59..27968148f 100644 --- a/framebuffer/fbtk/text.c +++ b/framebuffer/fbtk/text.c @@ -50,6 +50,19 @@ /* Convert pixels to points, assuming a DPI of 90 */ #define px_to_pt(x) (((x) * 72) / FBTK_DPI) +/* Get a font style for a text input */ +static inline void +fb_text_font_style(fbtk_widget_t *widget, int font_height, + plot_font_style_t *font_style) +{ + font_style->family = PLOT_FONT_FAMILY_SANS_SERIF; + font_style->size = px_to_pt(font_height) * FONT_SIZE_SCALE; + font_style->weight = 400; + font_style->flags = FONTF_NONE; + font_style->background = widget->bg; + font_style->foreground = widget->fg; +} + /** Text redraw callback. * * Called when a text widget requires redrawing. @@ -94,13 +107,7 @@ fb_redraw_text(fbtk_widget_t *widget, fbtk_callback_info *cbi ) if (widget->u.text.text != NULL) { fh = widget->height - padding - padding; - font_style.family = PLOT_FONT_FAMILY_SANS_SERIF; - font_style.size = px_to_pt(fh) * FONT_SIZE_SCALE; - font_style.weight = 400; - font_style.flags = FONTF_NONE; - font_style.background = widget->bg; - font_style.foreground = widget->fg; - + fb_text_font_style(widget, fh, &font_style); FBTK_LOG(("plotting %p at %d,%d %d,%d w/h %d,%d font h %d padding %d", widget, bbox.x0, bbox.y0, bbox.x1, bbox.y1, widget->width, widget->height, fh, padding)); @@ -192,12 +199,7 @@ fb_redraw_text_button(fbtk_widget_t *widget, fbtk_callback_info *cbi ) if (widget->u.text.text != NULL) { fh = widget->height - border - border; - font_style.family = PLOT_FONT_FAMILY_SANS_SERIF; - font_style.size = px_to_pt(fh) * FONT_SIZE_SCALE; - font_style.weight = 400; - font_style.flags = FONTF_NONE; - font_style.background = widget->bg; - font_style.foreground = widget->fg; + fb_text_font_style(widget, fh, &font_style); LOG(("plotting %p at %d,%d %d,%d w/h %d,%d font h %d border %d", widget, bbox.x0, bbox.y0, bbox.x1, bbox.y1, |