gi-pango-1.0.30: Pango bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | Safe-Inferred
Language | Haskell2010

GI.Pango.Structs.Language

Contents

- Exported types
- Methods
  - fromString
  - getDefault
  - getPreferred
  - getSampleString
  - getScripts
  - includesScript
  - matches
  - toString

Description

The `PangoLanguage` structure is used to represent a language.

`PangoLanguage` pointers can be efficiently copied and compared with each other.

Synopsis

- newtype Language = Language (ManagedPtr Language)
- languageFromString :: (HasCallStack, MonadIO m) => Maybe Text -> m (Maybe Language)
- languageGetDefault :: (HasCallStack, MonadIO m) => m Language
- languageGetPreferred :: (HasCallStack, MonadIO m) => m (Maybe [Language])
- languageGetSampleString :: (HasCallStack, MonadIO m) => Maybe Language -> m Text
- languageGetScripts :: (HasCallStack, MonadIO m) => Maybe Language -> m (Maybe [Script])
- languageIncludesScript :: (HasCallStack, MonadIO m) => Maybe Language -> Script -> m Bool
- languageMatches :: (HasCallStack, MonadIO m) => Maybe Language -> Text -> m Bool
- languageToString :: (HasCallStack, MonadIO m) => Language -> m Text

# Exported types

newtype Language Source #

Memory-managed wrapper type.

Constructors

Language (ManagedPtr Language) |

#### Instances

Instances details

Eq Language Source # |
Instance details Defined in GI.Pango.Structs.Language Methods (==) :: Language -> Language -> Bool Source # (/=) :: Language -> Language -> Bool Source #
GBoxed Language Source # |
Instance details Defined in GI.Pango.Structs.Language
ManagedPtrNewtype Language Source # |
Instance details Defined in GI.Pango.Structs.Language Methods toManagedPtr :: Language -> ManagedPtr Language Source #
TypedObject Language Source # |
Instance details Defined in GI.Pango.Structs.Language Methods glibType :: IO GType Source #
HasParentTypes Language Source # |
Instance details Defined in GI.Pango.Structs.Language
IsGValue (Maybe Language) Source # | Convert `Language` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Pango.Structs.Language Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Language -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Language) Source #
type ParentTypes Language Source # |
Instance details Defined in GI.Pango.Structs.Language type ParentTypes Language = '[] :: [Type]

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

includesScript, matches, toString.

#### Getters

getSampleString, getScripts.

#### Setters

None.

## fromString

languageFromString Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Text | `language`: a string representing a language tag
-> m (Maybe Language) | Returns: a `PangoLanguage`

Convert a language tag to a `PangoLanguage`.

The language tag must be in a RFC-3066 format. `PangoLanguage` 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 [func`pango`.Language.get_default] if you want to get the `PangoLanguage` for the current locale of the process.

## getDefault

languageGetDefault Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m Language | Returns: the default language as a `PangoLanguage`

Returns the `PangoLanguage` 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 `languageFromString` yourself.

Since: 1.16

## getPreferred

languageGetPreferred Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m (Maybe [Language]) | Returns: a `Nothing`-terminated array of `PangoLanguage`*

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 [func`pango`.Language.get_default].

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

Since: 1.48

## getSampleString

languageGetSampleString Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Language | `language`: a `PangoLanguage`
-> m Text | Returns: the sample string

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 `language` is `Nothing`, the default language as found by [func`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:

    pango_language_get_sample_string (pango_language_from_string ("xx"))

## getScripts

languageGetScripts Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Language | `language`: a `PangoLanguage`
-> m (Maybe [Script]) | Returns: An array of `PangoScript` values, with the number of entries in the array stored in `numScripts`, or `Nothing` if Pango does not have any information about this particular language tag (also the case if `language` is `Nothing`).

Determines the scripts used to to write `language`.

If nothing is known about the language tag `language`, or if `language` is `Nothing`, then `Nothing` 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 `numScript` points at will be set to the number of scripts in the returned array (or zero if `Nothing` 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 `Nothing`, and it is a small number.

The `languageIncludesScript` function uses this function internally.

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.

Since: 1.22

## includesScript

languageIncludesScript Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Language | `language`: a `PangoLanguage`
-> Script | `script`: a `PangoScript`
-> m Bool | Returns: `True` if `script` is one of the scripts used to write `language` or if nothing is known about `language` (including the case that `language` is `Nothing`), `False` otherwise.

Determines if `script` is one of the scripts used to write `language`.

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

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 `languageGetScripts` internally.

Since: 1.4

## matches

languageMatches Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Language | `language`: a language tag (see [func`pango`.Language.from_string]), `Nothing` is allowed and matches nothing but '*'
-> Text | `rangeList`: a list of language ranges, separated by ';', ':', ',', or space characters. Each element must either be '*', or a RFC 3066 language range canonicalized as by [func`pango`.Language.from_string]
-> m Bool | Returns: `True` if a match was found

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 '-'.

## toString

languageToString Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Language | `language`: a language tag.
-> m Text |

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

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