summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2008-08-20 05:58:19 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2008-08-20 05:58:19 +0000
commitd92ddce7941204242334b70dbc290ff5f6d454c3 (patch)
treed15c62391698ca26ac52e264a0cd0a9a493f8df9
parent536679459af082b739064b8f93ebf15d1a2d5d6f (diff)
downloadpango-d92ddce7941204242334b70dbc290ff5f6d454c3.tar.gz
Bug 314094 – Get rid of poutpourri default sample string
2008-08-20 Behdad Esfahbod <behdad@gnome.org> 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
-rw-r--r--ChangeLog9
-rw-r--r--pango/pango-language-sample-table.h2
-rw-r--r--pango/pango-language.c49
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 <behdad@gnome.org>
+
+ 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 <behdad@gnome.org>
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:
+ * <informalexample>pango_language_get_sample_string
+ * (pango_language_from_string ("xx"))</informalexample>.
*
* 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;
}