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 | None
Language | Haskell2010

GI.Pango.Objects.Context

Contents

- Exported types
- Methods
  - changed
  - getBaseDir
  - getBaseGravity
  - getFontDescription
  - getFontMap
  - getGravity
  - getGravityHint
  - getLanguage
  - getMatrix
  - getMetrics
  - getRoundGlyphPositions
  - getSerial
  - listFamilies
  - loadFont
  - loadFontset
  - new
  - setBaseDir
  - setBaseGravity
  - setFontDescription
  - setFontMap
  - setGravityHint
  - setLanguage
  - setMatrix
  - setRoundGlyphPositions

Description

A `PangoContext` stores global information used to control the itemization process.

The information stored by `PangoContext` includes the fontmap used to look up fonts, and default values such as the default language, default gravity, or default font.

To obtain a `PangoContext`, use `fontMapCreateContext`.

Synopsis

- newtype Context = Context (ManagedPtr Context)
- class (GObject o, IsDescendantOf Context o) => IsContext o
- toContext :: (MonadIO m, IsContext o) => o -> m Context
- contextChanged :: (HasCallStack, MonadIO m, IsContext a) => a -> m ()
- contextGetBaseDir :: (HasCallStack, MonadIO m, IsContext a) => a -> m Direction
- contextGetBaseGravity :: (HasCallStack, MonadIO m, IsContext a) => a -> m Gravity
- contextGetFontDescription :: (HasCallStack, MonadIO m, IsContext a) => a -> m (Maybe FontDescription)
- contextGetFontMap :: (HasCallStack, MonadIO m, IsContext a) => a -> m (Maybe FontMap)
- contextGetGravity :: (HasCallStack, MonadIO m, IsContext a) => a -> m Gravity
- contextGetGravityHint :: (HasCallStack, MonadIO m, IsContext a) => a -> m GravityHint
- contextGetLanguage :: (HasCallStack, MonadIO m, IsContext a) => a -> m Language
- contextGetMatrix :: (HasCallStack, MonadIO m, IsContext a) => a -> m (Maybe Matrix)
- contextGetMetrics :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe FontDescription -> Maybe Language -> m FontMetrics
- contextGetRoundGlyphPositions :: (HasCallStack, MonadIO m, IsContext a) => a -> m Bool
- contextGetSerial :: (HasCallStack, MonadIO m, IsContext a) => a -> m Word32
- contextListFamilies :: (HasCallStack, MonadIO m, IsContext a) => a -> m [FontFamily]
- contextLoadFont :: (HasCallStack, MonadIO m, IsContext a) => a -> FontDescription -> m (Maybe Font)
- contextLoadFontset :: (HasCallStack, MonadIO m, IsContext a) => a -> FontDescription -> Language -> m (Maybe Fontset)
- contextNew :: (HasCallStack, MonadIO m) => m Context
- contextSetBaseDir :: (HasCallStack, MonadIO m, IsContext a) => a -> Direction -> m ()
- contextSetBaseGravity :: (HasCallStack, MonadIO m, IsContext a) => a -> Gravity -> m ()
- contextSetFontDescription :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe FontDescription -> m ()
- contextSetFontMap :: (HasCallStack, MonadIO m, IsContext a, IsFontMap b) => a -> Maybe b -> m ()
- contextSetGravityHint :: (HasCallStack, MonadIO m, IsContext a) => a -> GravityHint -> m ()
- contextSetLanguage :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe Language -> m ()
- contextSetMatrix :: (HasCallStack, MonadIO m, IsContext a) => a -> Maybe Matrix -> m ()
- contextSetRoundGlyphPositions :: (HasCallStack, MonadIO m, IsContext a) => a -> Bool -> m ()

# Exported types

newtype Context Source #

Memory-managed wrapper type.

Constructors

Context (ManagedPtr Context) |

#### Instances

Instances details

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

class (GObject o, IsDescendantOf Context o) => IsContext o Source #

Type class for types which can be safely cast to `Context`, for instance with `toContext`.

#### Instances

Instances details

(GObject o, IsDescendantOf Context o) => IsContext o Source # |
Instance details Defined in GI.Pango.Objects.Context

toContext :: (MonadIO m, IsContext o) => o -> m Context Source #

Cast to `Context`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

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

Expand

#### Methods

bindProperty, bindPropertyFull, changed, forceFloating, freezeNotify, getv, isFloating, listFamilies, loadFont, loadFontset, notify, notifyByPspec, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getBaseDir, getBaseGravity, getData, getFontDescription, getFontMap, getGravity, getGravityHint, getLanguage, getMatrix, getMetrics, getProperty, getQdata, getRoundGlyphPositions, getSerial.

#### Setters

setBaseDir, setBaseGravity, setData, setDataFull, setFontDescription, setFontMap, setGravityHint, setLanguage, setMatrix, setProperty, setRoundGlyphPositions.

## changed

contextChanged Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m () |

Forces a change in the context, which will cause any `PangoLayout` using this context to re-layout.

This function is only useful when implementing a new backend for Pango, something applications won't do. Backends should call this function if they have attached extra data to the context and such data is changed.

Since: 1.32.4

## getBaseDir

contextGetBaseDir Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m Direction | Returns: the base direction for the context.

Retrieves the base direction for the context.

See `contextSetBaseDir`.

## getBaseGravity

contextGetBaseGravity Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m Gravity | Returns: the base gravity for the context.

Retrieves the base gravity for the context.

See `contextSetBaseGravity`.

Since: 1.16

## getFontDescription

contextGetFontDescription Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m (Maybe FontDescription) | Returns: a pointer to the context's default font description. This value must not be modified or freed.

Retrieve the default font description for the context.

## getFontMap

contextGetFontMap Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m (Maybe FontMap) | Returns: the font map for the. `PangoContext` This value is owned by Pango and should not be unreferenced.

Gets the `PangoFontMap` used to look up fonts for this context.

Since: 1.6

## getGravity

contextGetGravity Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m Gravity | Returns: the resolved gravity for the context.

Retrieves the gravity for the context.

This is similar to `contextGetBaseGravity`, except for when the base gravity is `GravityAuto` for which `Gravity`.`get_for_matrix`() is used to return the gravity from the current context matrix.

Since: 1.16

## getGravityHint

contextGetGravityHint Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m GravityHint | Returns: the gravity hint for the context.

Retrieves the gravity hint for the context.

See `contextSetGravityHint` for details.

Since: 1.16

## getLanguage

contextGetLanguage Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m Language | Returns: the global language tag.

Retrieves the global language tag for the context.

## getMatrix

contextGetMatrix Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m (Maybe Matrix) | Returns: the matrix, or `Nothing` if no matrix has been set (which is the same as the identity matrix). The returned matrix is owned by Pango and must not be modified or freed.

Gets the transformation matrix that will be applied when rendering with this context.

See `contextSetMatrix`.

Since: 1.6

## getMetrics

contextGetMetrics Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> Maybe FontDescription | `desc`: a `PangoFontDescription` structure. `Nothing` means that the font description from the context will be used.
-> Maybe Language | `language`: language tag used to determine which script to get the metrics for. `Nothing` means that the language tag from the context will be used. If no language tag is set on the context, metrics for the default language (as determined by `languageGetDefault` will be returned.
-> m FontMetrics | Returns: a `PangoFontMetrics` object. The caller must call `fontMetricsUnref` when finished using the object.

Get overall metric information for a particular font description.

Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language.

The `PangoFontDescription` is interpreted in the same way as by [func`itemize`], and the family name may be a comma separated list of names. If characters from multiple of these families would be used to render the string, then the returned fonts would be a composite of the metrics for the fonts loaded for the individual families.

## getRoundGlyphPositions

contextGetRoundGlyphPositions Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m Bool |

Returns whether font rendering with this context should round glyph positions and widths.

Since: 1.44

## getSerial

contextGetSerial Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m Word32 | Returns: The current serial number of `context`.

Returns the current serial number of `context`.

The serial number is initialized to an small number larger than zero when a new context is created and is increased whenever the context is changed using any of the setter functions, or the `PangoFontMap` it uses to find fonts has changed. The serial may wrap, but will never have the value 0. Since it can wrap, never compare it with "less than", always use "not equals".

This can be used to automatically detect changes to a `PangoContext`, and is only useful when implementing objects that need update when their `PangoContext` changes, like `PangoLayout`.

Since: 1.32.4

## listFamilies

contextListFamilies Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> m [FontFamily] |

List all families for a context.

## loadFont

contextLoadFont Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> FontDescription | `desc`: a `PangoFontDescription` describing the font to load
-> m (Maybe Font) | Returns: the newly allocated `PangoFont` that was loaded, or `Nothing` if no font matched.

Loads the font in one of the fontmaps in the context that is the closest match for `desc`.

## loadFontset

contextLoadFontset Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> FontDescription | `desc`: a `PangoFontDescription` describing the fonts to load
-> Language | `language`: a `PangoLanguage` the fonts will be used for
-> m (Maybe Fontset) | Returns: the newly allocated `PangoFontset` loaded, or `Nothing` if no font matched.

Load a set of fonts in the context that can be used to render a font matching `desc`.

## new

contextNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m Context | Returns: the newly allocated `PangoContext`, which should be freed with `objectUnref`.

Creates a new `PangoContext` initialized to default values.

This function is not particularly useful as it should always be followed by a `contextSetFontMap` call, and the function `fontMapCreateContext` does these two steps together and hence users are recommended to use that.

If you are using Pango as part of a higher-level system, that system may have it's own way of create a `PangoContext`. For instance, the GTK toolkit has, among others, `gtk_widget_get_pango_context()`. Use those instead.

## setBaseDir

contextSetBaseDir Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> Direction | `direction`: the new base direction
-> m () |

Sets the base direction for the context.

The base direction is used in applying the Unicode bidirectional algorithm; if the `direction` is `DirectionLtr` or `DirectionRtl`, then the value will be used as the paragraph direction in the Unicode bidirectional algorithm. A value of `DirectionWeakLtr` or `DirectionWeakRtl` is used only for paragraphs that do not contain any strong characters themselves.

## setBaseGravity

contextSetBaseGravity Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> Gravity | `gravity`: the new base gravity
-> m () |

Sets the base gravity for the context.

The base gravity is used in laying vertical text out.

Since: 1.16

## setFontDescription

contextSetFontDescription Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> Maybe FontDescription | `desc`: the new pango font description
-> m () |

Set the default font description for the context

## setFontMap

contextSetFontMap Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a, IsFontMap b) |
=> a | `context`: a `PangoContext`
-> Maybe b | `fontMap`: the `PangoFontMap` to set.
-> m () |

Sets the font map to be searched when fonts are looked-up in this context.

This is only for internal use by Pango backends, a `PangoContext` obtained via one of the recommended methods should already have a suitable font map.

## setGravityHint

contextSetGravityHint Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> GravityHint | `hint`: the new gravity hint
-> m () |

Sets the gravity hint for the context.

The gravity hint is used in laying vertical text out, and is only relevant if gravity of the context as returned by `contextGetGravity` is set to `GravityEast` or `GravityWest`.

Since: 1.16

## setLanguage

contextSetLanguage Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> Maybe Language | `language`: the new language tag.
-> m () |

Sets the global language tag for the context.

The default language for the locale of the running process can be found using `languageGetDefault`.

## setMatrix

contextSetMatrix Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> Maybe Matrix | `matrix`: a `PangoMatrix`, or `Nothing` to unset any existing matrix. (No matrix set is the same as setting the identity matrix.)
-> m () |

Sets the transformation matrix that will be applied when rendering with this context.

Note that reported metrics are in the user space coordinates before the application of the matrix, not device-space coordinates after the application of the matrix. So, they don't scale with the matrix, though they may change slightly for different matrices, depending on how the text is fit to the pixel grid.

Since: 1.6

## setRoundGlyphPositions

contextSetRoundGlyphPositions Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> Bool | `roundPositions`: whether to round glyph positions
-> m () |

Sets whether font rendering with this context should round glyph positions and widths to integral positions, in device units.

This is useful when the renderer can't handle subpixel positioning of glyphs.

The default value is to round glyph positions, to remain compatible with previous Pango behavior.

Since: 1.44