See: https://github.com/GNOME/pango/blob/master/examples/cairoshape.c
On Aug 11, 2016 8:04 AM, "Andy Meneely" <andy.mene...@gmail.com> wrote: > Hi, > I maintain a Ruby gem that uses Pango heavily ( > https://github.com/andymeneely/squib/). One of the key features is to be > able to draw an icon into the text such that it flows just like any other > word. Carving out the space in the Pango layout has proven to be a > finicky challenge. (Once we carve out the proper space in the layout, we > use Cairo to paint the image separately.) > > What is the proper way to carve out space for image? We need this space to > flow like any other word. > > The way we currently carve out space is a bit hacky ( > https://github.com/andymeneely/squib/blob/master/lib/squib/ > graphics/text.rb#L98). We (1) replace the key with a control character, > then (2) change the letter spacing of the middle character to the width we > need. This fails on some platforms and not others. > > If we created a zero-sized regular character (e.g "a"), then stroking path > will fail because a zero-sized font invalidates the matrix math. Plus, we > get strange behavior happening when the text is ONLY an embedded icon of a > zero-sized font (i.e. we get a warning that the font can't be found). > > So I've never been happy with the way we implement this and I'm convinced > Pango provides a better way. I see the AttrShape struct - should I be > using that? How do I set attributes for just one character? I've been > scouring the docs and mailing lists archives and I'm not grasping exactly > how attribute lists work, so that's why I went with markup. > > If you have solutions in just C, or in another scripting language, I can > port it. > > Thanks! > > _______________________________________________ > gtk-i18n-list mailing list > gtk-i18n-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-i18n-list > >
_______________________________________________ gtk-i18n-list mailing list gtk-i18n-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-i18n-list