Re: On font dialog default sample string selection
- From: "Henrique Carvalho Alves" <hcarvalhoalves gmail com>
- To: "Behdad Esfahbod" <behdad behdad org>
- Cc: gtk-devel-list gnome org, gtk-i18n-list gnome org
- Subject: Re: On font dialog default sample string selection
- Date: Mon, 18 Aug 2008 14:20:13 -0300
2008/8/18 Behdad Esfahbod <behdad behdad org>:
> [CC'ing gtk-i18n-list]
>
> Henrique Carvalho Alves wrote:
>> 2008/8/17 Henrique Carvalho Alves <hcarvalhoalves gmail com>:
>>> 2008/8/17 Sven Neumann <sven gimp org>:
>>>> Using the font name for preview does not work. You could try to add some
>>>> heuristics that select a reasonable text depending on font coverage. But
>>>> that is likely going to fail in some corner cases. So whatever you end
>>>> up doing, you should give the user a way to change the text used for
>>>> preview.
>>>>
>>>> Sven
>>>>
>>> You're right. The current font dialog also fails for that (see Ubuntu,
>>> which ships some fonts for other languages, and the preview just
>>> presents a default "abcdABCDE" text in sans). I too guess finding the
>>> glyph coverage for the font is hard and not reliable. As stated on the
>>> last reply, making the preview editable is better, of course. The
>>> question here: is using the font name and size as preview text a
>>> better default?
>
> The text should be editable, sure.
>
> It's still useful to have a better default preview text. It may also be
> useful to have a drop down of some other preset texts the font supports.
>
> For preset texts, there's a lot around:
>
> - For Latin: The quick brown... [1], abcd..., "Hamburgfonts" [2], Lorem
> ipsum [3],
>
> - Font samples for other lagnauges [4]
>
> - Pangrams for other languages [5],
>
> - When no languages are available, "I can eat glass" [6]
>
> In fact, these can go right in Pango. There's already API for that:
> pango_language_get_sample_string(). There's a bug to make that more useful
> [7]. I may have been motivated now to fix that for tomorrow's release.
>
> Note that Gtk+ can also use a special translatable string to let translators
> decide what string should be used for their language. Let's call this
> "current locale's preferred sample string".
>
> I have also added API to Pango already to be able to tell if a font can render
> a particular string. Just turn fallback off in your layout
> (pango_attr_fallback_new()), then use pango_layout_get_unknown_glyphs_count()
> and divide that by the number of characters in the string.
>
> Next is to decide which language to show by default, and which ones to show in
> the drop down. Here's what I propose:
>
> - If the font can render the current locale's preferred sample string, that
> should be the default, otherwise pick one of the supported strings
> arbitrarily. For bonus, prefer those that use scripts other than Latin.
> Among those, take one that uses the PangoScript with smaller/larger value,
> depending on whether you want to promote common or exotic languages :P.
>
> - To the list add all strings that can be rendered by the font. If the
> Pango fontmap being used is not a PangoFcFontMap, simply add the Latin ones
> (other than the current locale's preferred sample string that is). If it is a
> PangoFcFontMap:
>
> * Get a PangoFont of the font at hand (simply use any string and fallbacks
> off)
>
> * Get the "pattern" GObject property of the PangoFont (which actually is a
> PangoFcFont) which is a FcPattern *. Note that this fails with older Pango
> versions, so be prepared for handling that.
>
> * Fetch all the FC_LANG elements of the pattern.
>
> * For all those languages, use pango_language_get_sample_string() and add
> them. Note that that function returns a junk string if it doesn't know about
> the language. This can be detected by comparing the return value to that of
> pango_language_get_sample_string(pango_lanugage_from_string ("xx")).
>
> That's all. I don't mind jumping in and implementing this when someone has a
> patch against GTK+ to use the right widget there.
>
>
> behdad
>
> [1] http://en.wikipedia.org/wiki/The_quick_brown_fox_jumps_over_the_lazy_dog
> [2] http://en.wikipedia.org/wiki/Hamburgefonts
> [3] http://en.wikipedia.org/wiki/Lorem_ipsum
> [4] http://en.wikipedia.org/wiki/Sample_Font_Displays_In_Other_Languages
> [5] http://en.wikipedia.org/wiki/List_of_pangrams#Other_languages
> [6] http://svn.gnome.org/viewvc/pango/trunk/pango-view/GLASS.txt?view=markup
> [7] http://bugzilla.gnome.org/show_bug.cgi?id=473806
>
>
That's great. I didn't know Pango was aware of possible languages for
fonts (I'm new to Gtk and Gnome APIs), and
pango_language_get_sample_string() is exactly what was needed.
So, it's even better, instead of using that logic only for choosing a
preview text, it can be actually used to filter the font lists by
language - and then, choose the appropriate, i18n preview text for
each font selected.
This solves the problem mentioned with the current dialog, by letting
the user find a font that provides the appropriate script wanted, and
preview using the correct glyphs, without the _need_ to input a
preview text to see how the font will look.
I'll be hacking a prototype to the mentioned functionality so we can
test and then I'll poke the list again.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]