summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-05-14 07:53:07 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-05-14 07:53:07 +0000
commit1e54ba144dd8ded33a443e0845d2016b7c9c9981 (patch)
treef43a329e1ec11dcf65167c2e1c005016356cbf01
parent82e04d3696977d11611f9356707f9e00ea1e04d4 (diff)
downloadpango-1e54ba144dd8ded33a443e0845d2016b7c9c9981.tar.gz
Move pango_script_get_sample_language() from pango-script.c to
2007-05-14 Behdad Esfahbod <behdad@gnome.org> * pango/pango-language.c (pango_script_get_sample_language): * pango/pango-script.c: Move pango_script_get_sample_language() from pango-script.c to pango-language.c. Fits better. svn path=/trunk/; revision=2293
-rw-r--r--ChangeLog6
-rw-r--r--pango/pango-language.c134
-rw-r--r--pango/pango-script.c131
3 files changed, 139 insertions, 132 deletions
diff --git a/ChangeLog b/ChangeLog
index 0575795b..ff8007ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2007-05-14 Behdad Esfahbod <behdad@gnome.org>
+ * pango/pango-language.c (pango_script_get_sample_language):
+ * pango/pango-script.c: Move pango_script_get_sample_language()
+ from pango-script.c to pango-language.c. Fits better.
+
+2007-05-14 Behdad Esfahbod <behdad@gnome.org>
+
Part of Bug 325714 – Pango should respect $LANGUAGE
Bug 414264 – Pango vertical writing support is different with real
CJK usage.
diff --git a/pango/pango-language.c b/pango/pango-language.c
index b04ad21a..7e5d11cc 100644
--- a/pango/pango-language.c
+++ b/pango/pango-language.c
@@ -428,7 +428,8 @@ script_for_lang_compare (gconstpointer key,
* applications in most circumstances.
*
* Return value: %TRUE if @script is one of the scripts used
- * to write @language, or if nothing is known about @language.
+ * to write @language, or if nothing is known about @language,
+ * %FALSE otherwise.
*
* Since: 1.4
**/
@@ -495,3 +496,134 @@ pango_language_includes_script (PangoLanguage *language,
return FALSE;
}
+
+/**
+ * pango_script_get_sample_language:
+ * @script: a #PangoScript
+ *
+ * Given a script, finds a language tag that is reasonably
+ * representative of that script. This will usually be the
+ * most widely spoken or used language written in that script:
+ * for instance, the sample language for %PANGO_SCRIPT_CYRILLIC
+ * is <literal>ru</literal> (Russian), the sample language
+ * for %PANGO_SCRIPT_ARABIC is <literal>ar</literal>.
+ *
+ * For some
+ * scripts, no sample language will be returned because there
+ * is no language that is sufficiently representative. The best
+ * example of this is %PANGO_SCRIPT_HAN, where various different
+ * variants of written Chinese, Japanese, and Korean all use
+ * significantly different sets of Han characters and forms
+ * of shared characters. No sample language can be provided
+ * for many historical scripts as well.
+ *
+ * Return value: a #PangoLanguage that is representative
+ * of the script, or %NULL if no such language exists.
+ *
+ * Since: 1.4
+ **/
+PangoLanguage *
+pango_script_get_sample_language (PangoScript script)
+{
+ /* Note that in the following, we want
+ * pango_language_includes_script() for the sample language
+ * to include the script, so alternate orthographies
+ * (Shavian for English, Osmanya for Somali, etc), typically
+ * have no sample language
+ */
+ static const char sample_languages[][4] = {
+ "", /* PANGO_SCRIPT_COMMON */
+ "", /* PANGO_SCRIPT_INHERITED */
+ "ar", /* PANGO_SCRIPT_ARABIC */
+ "hy", /* PANGO_SCRIPT_ARMENIAN */
+ "bn", /* PANGO_SCRIPT_BENGALI */
+ /* Used primarily in Taiwan, but not part of the standard
+ * zh-tw orthography */
+ "", /* PANGO_SCRIPT_BOPOMOFO */
+ "chr", /* PANGO_SCRIPT_CHEROKEE */
+ "cop", /* PANGO_SCRIPT_COPTIC */
+ "ru", /* PANGO_SCRIPT_CYRILLIC */
+ /* Deseret was used to write English */
+ "", /* PANGO_SCRIPT_DESERET */
+ "hi", /* PANGO_SCRIPT_DEVANAGARI */
+ "am", /* PANGO_SCRIPT_ETHIOPIC */
+ "ka", /* PANGO_SCRIPT_GEORGIAN */
+ "", /* PANGO_SCRIPT_GOTHIC */
+ "el", /* PANGO_SCRIPT_GREEK */
+ "gu", /* PANGO_SCRIPT_GUJARATI */
+ "pa", /* PANGO_SCRIPT_GURMUKHI */
+ "", /* PANGO_SCRIPT_HAN */
+ "ko", /* PANGO_SCRIPT_HANGUL */
+ "he", /* PANGO_SCRIPT_HEBREW */
+ "ja", /* PANGO_SCRIPT_HIRAGANA */
+ "kn", /* PANGO_SCRIPT_KANNADA */
+ "ja", /* PANGO_SCRIPT_KATAKANA */
+ "km", /* PANGO_SCRIPT_KHMER */
+ "lo", /* PANGO_SCRIPT_LAO */
+ "en", /* PANGO_SCRIPT_LATIN */
+ "ml", /* PANGO_SCRIPT_MALAYALAM */
+ "mn", /* PANGO_SCRIPT_MONGOLIAN */
+ "my", /* PANGO_SCRIPT_MYANMAR */
+ /* Ogham was used to write old Irish */
+ "", /* PANGO_SCRIPT_OGHAM */
+ "", /* PANGO_SCRIPT_OLD_ITALIC */
+ "or", /* PANGO_SCRIPT_ORIYA */
+ "", /* PANGO_SCRIPT_RUNIC */
+ "si", /* PANGO_SCRIPT_SINHALA */
+ "syr", /* PANGO_SCRIPT_SYRIAC */
+ "ta", /* PANGO_SCRIPT_TAMIL */
+ "te", /* PANGO_SCRIPT_TELUGU */
+ "dv", /* PANGO_SCRIPT_THAANA */
+ "th", /* PANGO_SCRIPT_THAI */
+ "bo", /* PANGO_SCRIPT_TIBETAN */
+ "iu", /* PANGO_SCRIPT_CANADIAN_ABORIGINAL */
+ "", /* PANGO_SCRIPT_YI */
+ "tl", /* PANGO_SCRIPT_TAGALOG */
+ /* There are no ISO-636 language codes for the following
+ * Phillipino languages/scripts */
+ "", /* PANGO_SCRIPT_HANUNOO */
+ "", /* PANGO_SCRIPT_BUHID */
+ "", /* PANGO_SCRIPT_TAGBANWA */
+
+ "", /* PANGO_SCRIPT_BRAILLE */
+ "", /* PANGO_SCRIPT_CYPRIOT */
+ "", /* PANGO_SCRIPT_LIMBU */
+ /* Used for Somali (so) in the past */
+ "", /* PANGO_SCRIPT_OSMANYA */
+ /* The Shavian alphabet was designed for English */
+ "", /* PANGO_SCRIPT_SHAVIAN */
+ "", /* PANGO_SCRIPT_LINEAR_B */
+ "", /* PANGO_SCRIPT_TAI_LE */
+ "uga", /* PANGO_SCRIPT_UGARITIC */
+
+ "", /* PANGO_SCRIPT_NEW_TAI_LUE */
+ "bug", /* PANGO_SCRIPT_BUGINESE */
+ /* The original script for Old Church Slavonic (chu), later
+ * written with Cyrillic */
+ "", /* PANGO_SCRIPT_GLAGOLITIC */
+ /* Used for for Berber (ber), but Arabic script is more common */
+ "", /* PANGO_SCRIPT_TIFINAGH */
+ /* Syloti Nagri is used for Sylheti, no ISO 639 code */
+ "", /* PANGO_SCRIPT_SYLOTI_NAGRI */
+ "peo", /* PANGO_SCRIPT_OLD_PERSIAN */
+ "", /* PANGO_SCRIPT_KHAROSHTHI */
+
+ "", /* PANGO_SCRIPT_UNKNOWN */
+ "", /* PANGO_SCRIPT_BALINESE */
+ "", /* PANGO_SCRIPT_CUNEIFORM */
+ "", /* PANGO_SCRIPT_PHOENICIAN */
+ "", /* PANGO_SCRIPT_PHAGS_PA */
+ "nqo" /* PANGO_SCRIPT_NKO */
+ };
+ const char *sample_language;
+
+ g_return_val_if_fail (script >= 0, NULL);
+ g_return_val_if_fail ((guint)script < G_N_ELEMENTS (sample_languages), NULL);
+
+ sample_language = sample_languages[script];
+
+ if (!sample_language[0])
+ return NULL;
+ else
+ return pango_language_from_string (sample_language);
+}
diff --git a/pango/pango-script.c b/pango/pango-script.c
index 3036c999..d10b3a91 100644
--- a/pango/pango-script.c
+++ b/pango/pango-script.c
@@ -379,134 +379,3 @@ pango_script_iter_next (PangoScriptIter *iter)
/**********************************************************
* End of code from ICU
**********************************************************/
-
-/**
- * pango_script_get_sample_language:
- * @script: a #PangoScript
- *
- * Given a script, finds a language tag that is reasonably
- * representative of that script. This will usually be the
- * most widely spoken or used language written in that script:
- * for instance, the sample language for %PANGO_SCRIPT_CYRILLIC
- * is <literal>ru</literal> (Russian), the sample language
- * for %PANGO_SCRIPT_ARABIC is <literal>ar</literal>.
- *
- * For some
- * scripts, no sample language will be returned because there
- * is no language that is sufficiently representative. The best
- * example of this is %PANGO_SCRIPT_HAN, where various different
- * variants of written Chinese, Japanese, and Korean all use
- * significantly different sets of Han characters and forms
- * of shared characters. No sample language can be provided
- * for many historical scripts as well.
- *
- * Return value: a #PangoLanguage that is representative
- * of the script, or %NULL if no such language exists.
- *
- * Since: 1.4
- **/
-PangoLanguage *
-pango_script_get_sample_language (PangoScript script)
-{
- /* Note that in the following, we want
- * pango_language_includes_script() for the sample language
- * to include the script, so alternate orthographies
- * (Shavian for English, Osmanya for Somali, etc), typically
- * have no sample language
- */
- static const char sample_languages[][4] = {
- "", /* PANGO_SCRIPT_COMMON */
- "", /* PANGO_SCRIPT_INHERITED */
- "ar", /* PANGO_SCRIPT_ARABIC */
- "hy", /* PANGO_SCRIPT_ARMENIAN */
- "bn", /* PANGO_SCRIPT_BENGALI */
- /* Used primarily in Taiwan, but not part of the standard
- * zh-tw orthography */
- "", /* PANGO_SCRIPT_BOPOMOFO */
- "chr", /* PANGO_SCRIPT_CHEROKEE */
- "cop", /* PANGO_SCRIPT_COPTIC */
- "ru", /* PANGO_SCRIPT_CYRILLIC */
- /* Deseret was used to write English */
- "", /* PANGO_SCRIPT_DESERET */
- "hi", /* PANGO_SCRIPT_DEVANAGARI */
- "am", /* PANGO_SCRIPT_ETHIOPIC */
- "ka", /* PANGO_SCRIPT_GEORGIAN */
- "", /* PANGO_SCRIPT_GOTHIC */
- "el", /* PANGO_SCRIPT_GREEK */
- "gu", /* PANGO_SCRIPT_GUJARATI */
- "pa", /* PANGO_SCRIPT_GURMUKHI */
- "", /* PANGO_SCRIPT_HAN */
- "ko", /* PANGO_SCRIPT_HANGUL */
- "he", /* PANGO_SCRIPT_HEBREW */
- "ja", /* PANGO_SCRIPT_HIRAGANA */
- "kn", /* PANGO_SCRIPT_KANNADA */
- "ja", /* PANGO_SCRIPT_KATAKANA */
- "km", /* PANGO_SCRIPT_KHMER */
- "lo", /* PANGO_SCRIPT_LAO */
- "en", /* PANGO_SCRIPT_LATIN */
- "ml", /* PANGO_SCRIPT_MALAYALAM */
- "mn", /* PANGO_SCRIPT_MONGOLIAN */
- "my", /* PANGO_SCRIPT_MYANMAR */
- /* Ogham was used to write old Irish */
- "", /* PANGO_SCRIPT_OGHAM */
- "", /* PANGO_SCRIPT_OLD_ITALIC */
- "or", /* PANGO_SCRIPT_ORIYA */
- "", /* PANGO_SCRIPT_RUNIC */
- "si", /* PANGO_SCRIPT_SINHALA */
- "syr", /* PANGO_SCRIPT_SYRIAC */
- "ta", /* PANGO_SCRIPT_TAMIL */
- "te", /* PANGO_SCRIPT_TELUGU */
- "dv", /* PANGO_SCRIPT_THAANA */
- "th", /* PANGO_SCRIPT_THAI */
- "bo", /* PANGO_SCRIPT_TIBETAN */
- "iu", /* PANGO_SCRIPT_CANADIAN_ABORIGINAL */
- "", /* PANGO_SCRIPT_YI */
- "tl", /* PANGO_SCRIPT_TAGALOG */
- /* There are no ISO-636 language codes for the following
- * Phillipino languages/scripts */
- "", /* PANGO_SCRIPT_HANUNOO */
- "", /* PANGO_SCRIPT_BUHID */
- "", /* PANGO_SCRIPT_TAGBANWA */
-
- "", /* PANGO_SCRIPT_BRAILLE */
- "", /* PANGO_SCRIPT_CYPRIOT */
- "", /* PANGO_SCRIPT_LIMBU */
- /* Used for Somali (so) in the past */
- "", /* PANGO_SCRIPT_OSMANYA */
- /* The Shavian alphabet was designed for English */
- "", /* PANGO_SCRIPT_SHAVIAN */
- "", /* PANGO_SCRIPT_LINEAR_B */
- "", /* PANGO_SCRIPT_TAI_LE */
- "uga", /* PANGO_SCRIPT_UGARITIC */
-
- "", /* PANGO_SCRIPT_NEW_TAI_LUE */
- "bug", /* PANGO_SCRIPT_BUGINESE */
- /* The original script for Old Church Slavonic (chu), later
- * written with Cyrillic */
- "", /* PANGO_SCRIPT_GLAGOLITIC */
- /* Used for for Berber (ber), but Arabic script is more common */
- "", /* PANGO_SCRIPT_TIFINAGH */
- /* Syloti Nagri is used for Sylheti, no ISO 639 code */
- "", /* PANGO_SCRIPT_SYLOTI_NAGRI */
- "peo", /* PANGO_SCRIPT_OLD_PERSIAN */
- "", /* PANGO_SCRIPT_KHAROSHTHI */
-
- "", /* PANGO_SCRIPT_UNKNOWN */
- "", /* PANGO_SCRIPT_BALINESE */
- "", /* PANGO_SCRIPT_CUNEIFORM */
- "", /* PANGO_SCRIPT_PHOENICIAN */
- "", /* PANGO_SCRIPT_PHAGS_PA */
- "nqo" /* PANGO_SCRIPT_NKO */
- };
- const char *sample_language;
-
- g_return_val_if_fail (script >= 0, NULL);
- g_return_val_if_fail ((guint)script < G_N_ELEMENTS (sample_languages), NULL);
-
- sample_language = sample_languages[script];
-
- if (!sample_language[0])
- return NULL;
- else
- return pango_language_from_string (sample_language);
-}