I need a suggestion on how to make the layout with GtkFontChooserWidget on GTK4

Hi, ALL,

The software I’m writing is currently linked to GTK3.

One of the dialogs there looks like below

Unfortunately in GTK4, the font panel I’m using here is gone.

What do you suggest to do.

I don’t want to copy/paste your code in my software because it’s possible I’ll end up fixing more issues than needed. On top of that I’m not sure how it will be in terms of Copyright.

So, what should I do? How do I make it work?

As you can see I have 3 font selection pages there in a notebook and they look the same…

Thank you.

P.S.: I already asked to bring it back in GTK4 and got a reply that it will not be possible. But that post didn’t have a screenshot.

“How to make the layout” from the title of the post is a bit vague, in this case it is the use of GtkFontChooserWidget, AFAICT.

The “gtk3” tag is also misleading, since your question is about porting to GTK 4.

BTW, you can also take a screenshot instead of a photo :wink: (see the Print Screen key on your keyboard, for example).

@swilmet,

I actually didn’t use any tags.

And I would love to do a screenshot - except unfortunately my browser, FF, is too old to post here.

So im posting from the phone.

And I guess I need to edit the title, if I can.

P.S.: i edit the post and fixed the tag.

Thank you.

Hi,

You still can use Gtk.FontChooserWidget, but it’s deprecated so will be removed in gtk5.
These font widgets are tailored for Linux/fontconfig and may not work well on other systems. This is why the new font selection interfaces in gtk4 now rely on things like xdg-portals to improve the system integration.

For your usecase I would suggest to use a simple Gtk.FontDialogButton for choosing the font face an size, and just keep the other settings like colors and underline in your interface.

Hi,

I took a look at the screenshot in the GtkFontDialogButton. It will not look too appealing, but I guess I don’t have a choice do I?

BTW, GTK itself is most suitable for *nix systems, so I don’t know why this panel is being removed…

But that’s a different story/issue.

Thx.

The widget is being “removed” because on *nix systems—which are basically Linux, these days—we use sandboxing, and all the dialogs that interact with a system feature have been moved from widgets to asynchronous objects that handle the dialogs through calls to corresponding portals. This also allows using native dialogs on macOS and Windows.

While the font selection dialog does not have a corresponding portal—as of yet, at least—it would be bad to have a different API model than the rest of the dialogs provided by GTK. So, for consistency’s sake, GtkFontChooser and friends have been deprecated.

In the future, we will have different dialogs depending on the platform, as any platform has its own ideas of what a font selection dialog should look like.

Have fun testing.