GtkFontChooser: how does it work?

Can you please use my name?

It’s “GTK”, not “GTK+”. And I am one of the core developers.

It’s really not: it’s the “rule of three”. Contributions of new widgets and/or new API need to ensure that the API is going to be useful, and having just one application use it does not guarantee that. Additionally, core developers like me are going to maintain the new API for the entire duration of a major cycle (which can last from 5 to 10 years); we don’t add API that is only used by a single person.

It’s not at all impossible: it requires communication and iteration over the API, before landing it into GTK. Happens all the time.

Emmanuele ,

Oops, sorry for the typo.
Will be more careful next time.

Well it used to be called “GTK+”, IIRC.
I will keep that in mind.

And I know you are one of the core-devs. So, let me ask you - are you convinced?

Understandable.

But maybe all this is moot - if you can give me an access to the preview window layout, I can try to apply those attributes to it. No need to modify the existing font chooser layout, no need to redesign the widget - I will add 2 checboxes in my code along with the GtkFontChooserWidget and then update the preview window accordingly.
It will also keep the changes to the original librray code to the minimum to minimize the maintenance burden.
And it will be the less possibilities of introducing bugs to the code, which is always good.

Will this work?

My code will then have to maintain extra font object, but that is OK - at least for the time being.

What do you say? Will that work?

Thank you.

No. We are not really interested in giving you access to the internals of the font chooser widget. Exposing internal objects and state would inevitably come at an increased maintenance cost, because now we have to ensure that the Pango layout object is valid for as long as the widget exist—even if we decide to redesign its contents along the way—and assume it can be modified from outside the widget itself. That’s just something we won’t do.

Additionally, I assume you’re asking this to apply to GTK3, which is feature and API frozen; this is just not going to happen.

Your options are:

  • propose a change to the GTK font chooser widget, to show text attributes as well as the font family; this is a design change, and thus will have to go through the GNOME design team for validation; this change will affect GTK4 only
  • create your own composite widget, by packing a font chooser button to choose the font family and various widgets to control the text attributes, and maybe to display a preview of the text

Emmanuele,

Since I’m interested to make it work on GTK3 as well…

I think I will create a custom window/panel. I believe one can hide the font preview window in the GtkFontChooser interface - so that what I will do and create my own font previewer window.

But this might work as a starting point to implement this stuff for GTK4.

Also, I presume when I’m done, I will need to create a bug report for GTK and attach a screenshot.
If not - please let me know how to proceed.

BTW, I’m not really interested in allowing user to select font family - this parameter should be automatic, when (s)he select font name, because every font name belongs to some family. However you can’t select font name based on the font family. It is “one-to-many” relationship if I understand correctly.

Thank you.

We introduced the concept of ‘levels of detail’ for that, a while ago.

See gtk_font_chooser_set_level(), you can select how granular you want the user’s selection to be:

  • just a family
  • an individual face (called ‘style’ in the enumeration)
  • style and size (thats close to what you called a ‘font’)
  • allow to change variation axes (essentially, create a custom font)
  • select font features as well (comes close to your desire for strikethrough and underline, but we limit it to OpenType features)
1 Like

@matthiasc,
I did go to here, but
clicking on the GtkFontChooserLevel, brought me to this link, that gave me “404: NOT FOUND”.

You need to fix that link.

Thank you.

@ebassi,

This is what I have in mind and this is what I will use in my GTK3 port.

GtkFontChooser on top with the hidden preview window and at the bottom everything is custom made
Maybe I will use the switch control instead of check boxes.

Is it looks good

Thank you.

1 Like

https://developer.gnome.org/gtk4/3.99/GtkFontChooser.html#GtkFontChooserLevel

@matthiasc,
Thank you for the link.
Now is there an explanation what GTK_FONT_CHOOSER_LEVEL_FEATURES does?

And maybe its time to make a new value? Something like GTK_FONT_CHOOSER_EFFECTS?
If its set - developers will have an opportunity to select underlined/strikethrough font.

Something like on the screenshot I posted above.

Thank you.

As the documentation says: it lets you enable and disable OpenType font features. Thats things like ligatures, glyph variations, tabular numbers, etc

If its set - developers will have an opportunity to select underlined/strikethrough font.

As I said earlier, we currently consider those things to be out of scope for font selection.
Although you are right that the levels open the door for it a little bit.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.