GNOME Bugzilla – Bug 790747
pango_cairo_context_set_font_options() is unintuitive
Last modified: 2017-11-23 02:53:05 UTC
When using pangocairo, one must use pango_cairo_context_set_font_options() instead of cairo_set_font_options(). I do not find the reasoning behind this choice, and it has tricked countless people, myself being the latest one. Indeed, examples/cairotwisted.c is also broken in that it uses cairo_set_font_options(). I think we should fix this. Maybe such that if pango_cairo_context_set_font_options() is called, we use those, otherwise use the ones from cairo_t. A simple patch I tried didn't quite work, so filing this for now.
The simple patch I had in mind, that doesn't work, is this: ``` diff --git a/pango/pangocairo-context.c b/pango/pangocairo-context.c index 9dd02351..b5b8bfcf 100644 --- a/pango/pangocairo-context.c +++ b/pango/pangocairo-context.c @@ -108,6 +108,9 @@ _pango_cairo_update_context (cairo_t *cr, if (!info->surface_options) info->surface_options = cairo_font_options_create (); cairo_surface_get_font_options (target, info->surface_options); + if (!info->set_options) + info->set_options = cairo_font_options_create (); + cairo_get_font_options (cr, info->set_options); old_merged_options = info->merged_options; info->merged_options = NULL; ```
Fixed in master. Hopefully this doesn't break the world. ommit 3e5769aca2200b9f20614b1b9ec71f1bcf057ffe (HEAD -> master, origin/master, origin/HEAD) Author: Behdad Esfahbod <behdad@behdad.org> Date: Wed Nov 22 18:50:30 2017 -0800 [pangocairo] Pick up font-options from cairo_t Now one can use cairo_set_font_options(), whereas before they had to use pango_cairo_context_set_font_options(). If the latter is used, it will override the former. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=790747