From d92ddce7941204242334b70dbc290ff5f6d454c3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 20 Aug 2008 05:58:19 +0000 Subject: =?UTF-8?q?Bug=20314094=20=E2=80=93=20Get=20rid=20of=20poutpourri?= =?UTF-8?q?=20default=20sample=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-08-20 Behdad Esfahbod Bug 314094 – Get rid of poutpourri default sample string * pango/pango-language-sample-table.h: * pango/pango-language.c (pango_language_get_sample_string): Use default language if provided language to get_sample_string() is NULL. svn path=/trunk/; revision=2696 --- ChangeLog | 9 +++++++ pango/pango-language-sample-table.h | 2 ++ pango/pango-language.c | 49 ++++++++++++++++++++++--------------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d6ab99d..72aa214f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-08-20 Behdad Esfahbod + + Bug 314094 – Get rid of poutpourri default sample string + + * pango/pango-language-sample-table.h: + * pango/pango-language.c (pango_language_get_sample_string): + Use default language if provided language to get_sample_string() + is NULL. + 2008-08-19 Behdad Esfahbod Bug 473806 – Improve pango_language_get_sample_string() diff --git a/pango/pango-language-sample-table.h b/pango/pango-language-sample-table.h index 8bdc829c..31dfe4a2 100644 --- a/pango/pango-language-sample-table.h +++ b/pango/pango-language-sample-table.h @@ -46,6 +46,8 @@ * be demonstrative of normal text in the language, as well as exposing font * feature requirements unique to the language. It should be suitable for use * as sample text in a font selection dialog. + * + * Needless to say, the list MUST be sorted on the language code. */ LANGUAGE( af /* Afrikaans */, diff --git a/pango/pango-language.c b/pango/pango-language.c index e21109d8..5aedd564 100644 --- a/pango/pango-language.c +++ b/pango/pango-language.c @@ -377,37 +377,46 @@ static const LangInfo lang_texts[] = { * @language: a #PangoLanguage, or %NULL * * Get a string that is representative of the characters needed to - * render a particular language. This function is a bad hack for - * internal use by renderers and Pango. + * render a particular language. + * + * The sample text may be a pangram, but is not necessarily. It is chosen to + * be demonstrative of normal text in the language, as well as exposing font + * feature requirements unique to the language. It is suitable for use + * as sample text in a font selection dialog. + * + * If @language is %NULL, the default language as found by + * pango_language_get_default() is used. + * + * If Pango does not have a sample string for @language, the classic + * "The quick brown fox..." is returned. This can be detected by + * comparing the returned pointer value to that returned for (non-existent) + * language code "xx". That is, compare to: + * pango_language_get_sample_string + * (pango_language_from_string ("xx")). * * Return value: the sample string. This value is owned by Pango - * and must not be freed. + * and should not be freed. **/ G_CONST_RETURN char * pango_language_get_sample_string (PangoLanguage *language) { + const char *lang_str; const char *result; - if (language) - { - const char *lang_str = pango_language_to_string (language); + if (!language) + language = pango_language_get_default (); + + lang_str = pango_language_to_string (language); - LangInfo *lang_info = bsearch (lang_str, lang_texts, - G_N_ELEMENTS (lang_texts), sizeof (LangInfo), - lang_info_compare); + LangInfo *lang_info = bsearch (lang_str, lang_texts, + G_N_ELEMENTS (lang_texts), sizeof (LangInfo), + lang_info_compare); + /* XXX find best matching language */ - if (lang_info) - result = lang_pool.str + lang_info->offset; - else - result = "The quick brown fox jumps over the lazy dog."; - } + if (lang_info) + result = lang_pool.str + lang_info->offset; else - { - /* Complete junk - */ - - result = "\330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205 \304\215esky \316\225\316\273\316\273\316\267\316\275\316\271\316\272\316\254 Fran\303\247ais \346\227\245\346\234\254\350\252\236 \355\225\234\352\270\200 \320\240\321\203\321\201\321\201\320\272\320\270\320\271 \344\270\255\346\226\207,\346\231\256\351\200\232\350\257\235,\346\261\211\350\257\255 T\303\274rk\303\247e"; - } + result = "The quick brown fox jumps over the lazy dog."; return result; } -- cgit v1.2.1