Re: Call for text size and style advice for Gnome 2



Darin Adler <darin bentspoon com> writes: 
> There are about 15 or so other places that do things to make the font bigger
> or smaller or bold, and I'd like to figure out what to do about them. What's
> the standard Gnome way of handling things like this? Does this somehow
> relate to RC files? How should these interact with user font choices in the
> Nautilus preferences dialog?

What we want to end up doing, for "bigger" or "bold", is to 
get a PangoAttrList applied to the PangoLayout for the text, with
a PangoAttrScale (using PANGO_SCALE_* scale factors) for the sizes (rather
than just picking sizes that look nice on most current X setups).

Then the sizes used in various GNOME places will be consistent, and by
modifying the global X font config we can make it nice. The problem
with just picking sizes is that we are going to have at least two
common X backends in use (Xft and the old one), and also different
sets of available fonts, and different Xft configurations. So what
looks nice on one computer won't on another. Already my GTK comes up
with a different default font than Owen's, for example.

That means the focus for GNOME needs to be on consistency, and the
focus for system integrators needs to be on making stuff look nice on
a given system. Pango can also try to be smart, if GNOME is
consistent, to the extent that it's possible. But if we have apps
setting all kinds of random sizes and faces it's hard to fix
centrally.

For font choices in the Nautilus prefs dialog, I don't know. For
things like menus that are in no way special, nautilus prefs shouldn't
affect them (I don't guess they do now). For the icon view, Nautilus
should probably just ignore the global setting. Or perhaps you should
introduce a boolean flag for "use standard font size" which would be
on by default, and toggled off if you customize this.
(The reason for the flag is that if someone customizes their font
globally, they'd probably expect Nautilus to follow that, if they
haven't previously adjusted Nautilus specifically.)

> Havoc told me that the old way it was done is not good for accessibility and
> that instead I should be using gtk_label_set_markup.
> ...  I don't understand how it
> helps for accessibility either, so I am working in the dark here.

The reason is that markup for <large> gives you a PangoAttrScale, and
calling gtk_widget_modify_font() gives you a fixed font size. The
scale changes with the theme, so if someone can't see well they can
crank up the font size. The hardcoded font size does not change with
the global font size setting.

> This has a few
> problems, though. For one thing, if the label is one that has text that can
> be changed, each place that changes the text has to use
> gtk_label_set_markup. For another, if the label has arbitrary text in it,
> there's no guarantee it won't have something that looks like markup. So this
> seems like it might not be the right approach.

There are two solutions to this. One is to escape any text you're
putting in the markup, with g_markup_escape_text(). (The convenience
function here is hard since you want a printf clone that escapes the
%s argument, but it would be nice to have.)

The other solution is to instead set the PangoAttrList on your label
with a PangoAttrScale or PangoAttrWeight. This only works if you want
the attribute on the entire string. (You can use G_MAXINT for the end
index in the attr list, and never change it even as your text
changes.) If you want the attribute on a subportion of the string, you
must use markup, so the position of the attribute can be translated by
the i18n team when they translate the text itself.

So it's easy to imagine a gtk_label_make_larger convenience function
that uses attr list. I think I patched make_larger at some point to
use modify_font(), and I shouldn't have probably, the attr list
approach might have been better. Note that attr lists and markup can't
be mixed, since markup is just a different way to set the attr list.
 
> (There's also code that selects the largest possible font that will fit up
> to a certain size that and code that uses ellipses as needed. I could use
> help or advice about how to do these with Pango and perhaps GtkLabel.)

I already sent you a non-working patch to do this, remember. ;-) 

Anders says it crashes, I can look at fixing it, I just keep
forgetting. In any case, it was one theory on how to rewrite the
ellipsization.

As I mentioned above I probably should have used attr list instead of
gtk_widget_modify_font() for the make_larger stuff, IIRC.

The discussion of g_markup_escape_text() reminds me that I bet
Nautilus needs to validate incoming text with g_utf8_validate() in
about a zillion places. e.g. filenames all need to be validated.
And probably their invalid form needs to be saved for manipulating
them, in addition to the valid form used for display...

Havoc



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]