[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    Re: Get the default font in Gtk3
From:       Emmanuele Bassi <ebassi () gmail ! com>
Date:       2018-03-29 14:28:27
Message-ID: CALnHYQHwx1cSqLPjXB5_NH6p2tc3GQfjCdk4HUyA25r6Zq+39g () mail ! gmail ! com
[Download RAW message or body]

On 29 March 2018 at 15:12, rastersoft <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 ). 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]
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic