GNOME Bugzilla – Bug 170055
Support relative font sizes in text markup
Last modified: 2018-05-22 12:09:16 UTC
Pango markup language doesn't currently allow use of a scale factor, like possible with the GtkTextTag or PangoAttribute. It could be useful to have though, being more exact and convenient than nesting many <span size="larger"> which are the only current relative size attributes.
I want to do this as size="150%" like CSS.
*** Bug 325767 has been marked as a duplicate of this bug. ***
Created attachment 64527 [details] [review] add the codes about supporting "150%" I wrote a patch for adding the codes that support size = "150%" in text markup. If size = "n%" in text markup, font size will become old_font_size * (n / 100). For example: font size = 50 * PANGO_SCALE, pango_layout_set_markup (layout, "<span size=\"150%\">A</span>"); then font size becomes 1.5 * 50 * PANGO_SCALE.
Created attachment 64542 [details] [review] my patch Ok, I've implemented relative sizes such that they actually work recursively too. Imagine this text: <span size="1024">a<span size="200%">b<span size="200%">c</span>d</span>e</span> the sizes one expects is of course 12421. Now with this: <span size="1024">a<span size="200%">b<span size="1024">c</span>d</span>e</span> Now of course you expect 12121, and not 12221. To make it do this, I changed pango-attributes.c such that an inner font attribute makes scale attributes after it to not scale. But I think the promise of attributes is to scale the font size, and the markup parser should clear any scale setting when setting font size. Owen, which one is correct?
Filed bug 562252 to add new api that helps here.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pango/issues/23.