Language structure is used to
represent a language.
Language pointers can be efficiently
copied and compared with each other.
pub fn from_string(language: &str) -> Language[src]
Take a RFC-3066 format language tag as a string and convert it to a
Language pointer that can be efficiently copied (copy the
pointer) and compared with other language tags (compare the
This function first canonicalizes the string by converting it to lowercase, mapping '_' to '-', and stripping all characters other than letters and '-'.
Language::get_default if you want to get the
the current locale of the process.
a string representing a language tag, or
an opaque pointer to a
Language structure, or
None. The returned pointer will be valid forever
after, and should not be freed.
Gets the RFC-3066 format string representing the given language tag.
a string representing the language tag. This is owned by Pango and should not be freed.
Checks if a language tag matches one of the elements in a list of language ranges. A language tag is considered to match a range in the list if the range is '*', the range is exactly the tag, or the range is a prefix of the tag, and the character after it in the tag is '-'.
a list of language ranges, separated by ';', ':',
',', or space characters.
Each element must either be '*', or a RFC 3066 language range
canonicalized as by
true if a match was found.
pub fn includes_script(&self, script: Script) -> bool[src]
script is one of the scripts used to
self. The returned value is conservative;
if nothing is known about the language tag
true will be returned, since, as far as Pango knows,
script might be used to write
This routine is used in Pango's itemization process when determining if a supplied language tag is relevant to a particular section of text. It probably is not useful for applications in most circumstances.
This function uses
script is one of the scripts used
self or if nothing is known about
(including the case that
pub fn get_scripts(&self) -> Vec<Script>[src]
Determines the scripts used to to write
If nothing is known about the language tag
None is returned.
The list of scripts returned starts with the script that the
language uses most and continues to the one it uses least.
num_script points at will be set to the number
of scripts in the returned array (or zero if
None is returned).
Most languages use only one script for writing, but there are
some that use two (Latin and Cyrillic for example), and a few
use three (Japanese for example). Applications should not make
any assumptions on the maximum number of scripts returned
though, except that it is positive if the return value is not
None, and it is a small number.
Language::includes_script function uses this function
Note: while the return value is declared as PangoScript, the returned values are from the GUnicodeScript enumeration, which may have more values. Callers need to handle unknown values.
location to return number of scripts,
An array of
Script values, with the number of entries in the array stored
None if Pango does not have any information
about this particular language tag (also the case if
None). The returned array is owned by Pango and should not be
modified or freed.
pub fn get_sample_string(&self) -> GString[src]
Get a string that is representative of the characters needed to 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.
None, the default language as found by
Language::get_default is used.
If Pango does not have a sample string for
self, 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"))
the sample string. This value is owned by Pango and should not be freed.
Auto Trait Implementations
impl RefUnwindSafe for Language
impl UnwindSafe for Language
type Error = Infallible
The type returned in the event of a conversion error.