Re: Get the default font in Gtk3
- From: rastersoft <raster rastersoft com>
- To: Emmanuele Bassi <ebassi gmail com>
- Cc: gtk-app-devel-list list <gtk-app-devel-list gnome org>
- Subject: Re: Get the default font in Gtk3
- Date: Thu, 29 Mar 2018 16:42:56 +0200
Ok, now I thing I got it. Thank you very much!!!!!!!!!
El 29/03/18 a las 16:28, Emmanuele Bassi escribió:
On 29 March 2018 at 15:12, rastersoft <raster rastersoft com
<mailto:raster rastersoft com>> wrote:
[get the Gtk font type and size]
Ops, sorry: I'm reworking a backup utility that I wrote
(cronopete), and
I added a timeline with the backups (you can see an
screenshot at
http://www.rastersoft.com/cronopete_screenshot.png
<http://www.rastersoft.com/cronopete_screenshot.png> ). As
you can see, at
the left is the timeline and it has the days, months and
years. I think
those should use the same typography than the standard Gtk
widgets, but
reducing the size to 2/3. The same for the titles in each
"pseudowindow"
(they have a visual effect: they go forward and backwards
when you move
through the timeline).
...I must be missing something here...
You can change font size in a layout. The scrolling might be
tricky, but
just eyeballing it, sounds like something that can be done by
showing
the layout twice at different coords in different clips
(cairo_save/cairo_restore brackets).
So...?
(Only thing I'm not quite sure about right now is if gtk fully
initializes
font description in a layout, cause I vaguely recall that it might
not... though maybe that was just wrt. theming API...)
Mainly the problem is that I'm using cairo_show_text...
That's the Cairo toy text API; you should only use it for tests or
small examples; it's basically useless for anything user-facing.
I presume that what you say is that I should replace all that with
Pango... Now I have some problems: first, I'm using vala and I
can't find the "get_pango_layout" from a widget. It exists
"create_pango_layout", so I suppose that this is the call I need
to create a layout.
Yes, the function is `gtk_widget_create_pango_layout()`:
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-create-pango-layout
Now the big question is: does ANY widget return the right layout,
or I must use a widget designed to contain text (like a Gtk.Label)
to get that layout, paint into it, and paste it in the final Cairo
canvas (which won't be the same canvas than the Gtk.Label from
which I created the layout)?
All widgets that need to render text call
gtk_widget_create_pango_layout() internally, including GtkLabel.
Ciao,
Emmanuele.
--
https://www.bassi.io
[@] ebassi [@gmail.com <http://gmail.com>]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]