summaryrefslogtreecommitdiff
path: root/pango/pango-language.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-09-08 10:44:20 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-09-18 14:54:11 -0400
commit937af77bcf7d689a85d549c573edd2de7bafbe5b (patch)
treeed5fd5145cc600e8fbf950e3fd3540acab102cec /pango/pango-language.c
parent712223916f82782e84d2efe8216210026d8fec6d (diff)
downloadpango-937af77bcf7d689a85d549c573edd2de7bafbe5b.tar.gz
Add pango_language_get_preferred
This returns the list of preferred languages, as determined from the PANGO_LANGUAGES or LANGUAGES environment variables.
Diffstat (limited to 'pango/pango-language.c')
-rw-r--r--pango/pango-language.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/pango/pango-language.c b/pango/pango-language.c
index 410ca0bf..04c3e0ca 100644
--- a/pango/pango-language.c
+++ b/pango/pango-language.c
@@ -791,13 +791,14 @@ parse_default_languages (void)
return (PangoLanguage **) g_array_free (langs, FALSE);
}
+G_LOCK_DEFINE_STATIC (languages);
+static gboolean initialized = FALSE; /* MT-safe */
+static PangoLanguage * const * languages = NULL; /* MT-safe */
+static GHashTable *hash = NULL; /* MT-safe */
+
static PangoLanguage *
_pango_script_get_default_language (PangoScript script)
{
- G_LOCK_DEFINE_STATIC (languages);
- static gboolean initialized = FALSE; /* MT-safe */
- static PangoLanguage * const * languages = NULL; /* MT-safe */
- static GHashTable *hash = NULL; /* MT-safe */
PangoLanguage *result, * const * p;
G_LOCK (languages);
@@ -835,6 +836,33 @@ out:
}
/**
+ * pango_language_get_preferred:
+ *
+ * Returns the list of languages that the user prefers, as specified
+ * by the PANGO_LANGUAGE or LANGUAGE environment variables, in order
+ * of preference. Note that this list does not necessarily include
+ * the language returned by pango_language_get_default().
+ *
+ * When choosing language-specific resources, such as the sample
+ * text returned by pango_language_get_sample_string(), you should
+ * first try the default language, followed by the languages returned
+ * by this function.
+ *
+ * Returns: (transfer none) (nullable): a %NULL-terminated array of
+ * PangoLanguage*
+ *
+ * Since: 1.48
+ */
+PangoLanguage **
+pango_language_get_preferred (void)
+{
+ /* We call this just for its side-effect of initializing languages */
+ _pango_script_get_default_language (PANGO_SCRIPT_COMMON);
+
+ return languages;
+}
+
+/**
* pango_script_get_sample_language:
* @script: a #PangoScript
*