After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 790747 - pango_cairo_context_set_font_options() is unintuitive
pango_cairo_context_set_font_options() is unintuitive
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: cairo
unspecified
Other Linux
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2017-11-23 02:22 UTC by Behdad Esfahbod
Modified: 2017-11-23 02:53 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Behdad Esfahbod 2017-11-23 02:22:09 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.
Comment 1 Behdad Esfahbod 2017-11-23 02:24:03 UTC
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;
```
Comment 2 Behdad Esfahbod 2017-11-23 02:53:05 UTC
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