pango

Struct Language

Source
pub struct Language { /* private fields */ }
Expand description

The Language structure is used to represent a language.

Language pointers can be efficiently copied and compared with each other.

GLib type: Boxed type with copy-on-clone semantics.

Implementations§

Source§

impl Language

Source

pub fn as_ptr(&self) -> *mut PangoLanguage

Return the inner pointer to the underlying C value.

Source

pub unsafe fn from_glib_ptr_borrow(ptr: &*mut PangoLanguage) -> &Self

Borrows the underlying C value.

Source

pub unsafe fn from_glib_ptr_borrow_mut( ptr: &mut *mut PangoLanguage, ) -> &mut Self

Borrows the underlying C value mutably.

Source§

impl Language

Source

pub fn sample_string(&self) -> GString

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.

If @self is None, the default language as found by 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"))
§Returns

the sample string

Source

pub fn includes_script(&self, script: Script) -> bool

Determines if @script is one of the scripts used to write @self.

The returned value is conservative; if nothing is known about the language tag @self, true will be returned, since, as far as Pango knows, @script might be used to write @self.

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 scripts() internally.

§script

a Script

§Returns

true if @script is one of the scripts used to write @self or if nothing is known about @self (including the case that @self is None), false otherwise.

Source

pub fn matches(&self, range_list: &str) -> bool

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 ‘-’.

§range_list

a list of language ranges, separated by ‘;’, ‘:’, ‘,’, or space characters. Each element must either be ‘*’, or a RFC 3066 language range canonicalized as by from_string()

§Returns

true if a match was found

Source

pub fn to_str(&self) -> GString

Gets the RFC-3066 format string representing the given language tag.

Returns (transfer none): a string representing the language tag

Source

pub fn from_string(language: &str) -> Language

Convert a language tag to a Language.

The language tag must be in a RFC-3066 format. Language pointers can be efficiently copied (copy the pointer) and compared with other language tags (compare the pointer.)

This function first canonicalizes the string by converting it to lowercase, mapping ‘_’ to ‘-’, and stripping all characters other than letters and ‘-’.

Use default() if you want to get the Language for the current locale of the process.

§language

a string representing a language tag

§Returns

a Language

Source

pub fn default() -> Language

Returns the Language for the current locale of the process.

On Unix systems, this is the return value is derived from setlocale (LC_CTYPE, NULL), and the user can affect this through the environment variables LC_ALL, LC_CTYPE or LANG (checked in that order). The locale string typically is in the form lang_COUNTRY, where lang is an ISO-639 language code, and COUNTRY is an ISO-3166 country code. For instance, sv_FI for Swedish as written in Finland or pt_BR for Portuguese as written in Brazil.

On Windows, the C library does not use any such environment variables, and setting them won’t affect the behavior of functions like ctime(). The user sets the locale through the Regional Options in the Control Panel. The C library (in the setlocale() function) does not use country and language codes, but country and language names spelled out in English. However, this function does check the above environment variables, and does return a Unix-style locale string based on either said environment variables or the thread’s current locale.

Your application should call setlocale(LC_ALL, "") for the user settings to take effect. GTK does this in its initialization functions automatically (by calling gtk_set_locale()). See the setlocale() manpage for more details.

Note that the default language can change over the life of an application.

Also note that this function will not do the right thing if you use per-thread locales with uselocale(). In that case, you should just call pango_language_from_string() yourself.

§Returns

the default language as a Language

Source

pub fn preferred() -> Vec<Language>

Available on crate feature v1_48 only.

Returns the list of languages that the user prefers.

The list is 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 default().

When choosing language-specific resources, such as the sample text returned by sample_string(), you should first try the default language, followed by the languages returned by this function.

§Returns

a None-terminated array of Language*

Source§

impl Language

Source

pub fn scripts(&self) -> Vec<Script>

Determines the scripts used to to write @self.

If nothing is known about the language tag @self, or if @self is None, then 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.

The value @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.

The includes_script() function uses this function internally.

Note: while the return value is declared as Script, the returned values are from the GUnicodeScript enumeration, which may have more values. Callers need to handle unknown values.

§Returns

An array of Script values, with the number of entries in the array stored in @num_scripts, or None if Pango does not have any information about this particular language tag (also the case if @self is None).

Trait Implementations§

Source§

impl Clone for Language

Source§

fn clone(&self) -> Self

Copies the boxed type with the type-specific copy function.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Language

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Language

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Language> for Value

Source§

fn from(o: Language) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Language

Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

fn from_str(language: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl HasParamSpec for Language

Source§

type ParamSpec = ParamSpecBoxed

Source§

type SetValue = Language

Preferred value to be used as setter for the associated ParamSpec.
Source§

type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, Language>

Source§

fn param_spec_builder() -> Self::BuilderFn

Source§

impl Hash for Language

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Language

Source§

fn cmp(&self, other: &Language) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Language

Source§

fn eq(&self, other: &Language) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Language

Source§

fn partial_cmp(&self, other: &Language) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StaticType for Language

Source§

fn static_type() -> Type

Returns the type identifier of Self.
Source§

impl Eq for Language

Source§

impl Send for Language

Source§

impl StructuralPartialEq for Language

Source§

impl Sync for Language

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoClosureReturnValue for T
where T: Into<Value>,

Source§

impl<T> Property for T
where T: HasParamSpec,

Source§

type Value = T

Source§

impl<T> PropertyGet for T
where T: HasParamSpec,

Source§

type Value = T

Source§

fn get<R, F>(&self, f: F) -> R
where F: Fn(&<T as PropertyGet>::Value) -> R,

Source§

impl<T> StaticTypeExt for T
where T: StaticType,

Source§

fn ensure_type()

Ensures that the type has been registered with the type system.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSendValue for T
where T: Send + ToValue + ?Sized,

Source§

fn to_send_value(&self) -> SendValue

Returns a SendValue clone of self.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TransparentType for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T> TryFromClosureReturnValue for T
where T: for<'a> FromValue<'a> + StaticType + 'static,

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<'a, T, C, E> FromValueOptional<'a> for T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,