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

Contents

- Exported types
- Methods
  - describe
  - describeWithAbsoluteSize
  - descriptionsFree
  - deserialize
  - getCoverage
  - getFace
  - getFeatures
  - getFontMap
  - getGlyphExtents
  - getLanguages
  - getMetrics
  - hasChar
  - serialize

Description

A `PangoFont` is used to represent a font in a rendering-system-independent manner.

Synopsis

- newtype Font = Font (ManagedPtr Font)
- class (GObject o, IsDescendantOf Font o) => IsFont o
- toFont :: (MonadIO m, IsFont o) => o -> m Font
- fontDescribe :: (HasCallStack, MonadIO m, IsFont a) => a -> m FontDescription
- fontDescribeWithAbsoluteSize :: (HasCallStack, MonadIO m, IsFont a) => a -> m FontDescription
- fontDescriptionsFree :: (HasCallStack, MonadIO m) => Maybe [FontDescription] -> m ()
- fontDeserialize :: (HasCallStack, MonadIO m, IsContext a) => a -> Bytes -> m (Maybe Font)
- fontGetCoverage :: (HasCallStack, MonadIO m, IsFont a) => a -> Language -> m Coverage
- fontGetFace :: (HasCallStack, MonadIO m, IsFont a) => a -> m (Maybe FontFace)
- fontGetFeatures :: (HasCallStack, MonadIO m, IsFont a) => a -> [FeatureT] -> Word32 -> m ([FeatureT], Word32)
- fontGetFontMap :: (HasCallStack, MonadIO m, IsFont a) => Maybe a -> m (Maybe FontMap)
- fontGetGlyphExtents :: (HasCallStack, MonadIO m, IsFont a) => Maybe a -> Word32 -> m (Rectangle, Rectangle)
- fontGetLanguages :: (HasCallStack, MonadIO m, IsFont a) => a -> m (Maybe [Language])
- fontGetMetrics :: (HasCallStack, MonadIO m, IsFont a) => Maybe a -> Maybe Language -> m FontMetrics
- fontHasChar :: (HasCallStack, MonadIO m, IsFont a) => a -> Char -> m Bool
- fontSerialize :: (HasCallStack, MonadIO m, IsFont a) => a -> m Bytes

# Exported types

newtype Font Source #

Memory-managed wrapper type.

Constructors

Font (ManagedPtr Font) |

#### Instances

Instances details

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

class (GObject o, IsDescendantOf Font o) => IsFont o Source #

Type class for types which can be safely cast to `Font`, for instance with `toFont`.

#### Instances

Instances details

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

toFont :: (MonadIO m, IsFont o) => o -> m Font Source #

Cast to `Font`, 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, describe, describeWithAbsoluteSize, forceFloating, freezeNotify, getv, hasChar, isFloating, notify, notifyByPspec, ref, refSink, runDispose, serialize, stealData, stealQdata, thawNotify, unref, watchClosure.

#### Getters

getCoverage, getData, getFace, getFeatures, getFontMap, getGlyphExtents, getLanguages, getMetrics, getProperty, getQdata.

#### Setters

setData, setDataFull, setProperty.

## describe

fontDescribe Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> a | `font`: a `PangoFont`
-> m FontDescription | Returns: a newly-allocated `PangoFontDescription` object.

Returns a description of the font, with font size set in points.

Use `fontDescribeWithAbsoluteSize` if you want the font size in device units.

## describeWithAbsoluteSize

fontDescribeWithAbsoluteSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> a | `font`: a `PangoFont`
-> m FontDescription | Returns: a newly-allocated `PangoFontDescription` object.

Returns a description of the font, with absolute font size set in device units.

Use `fontDescribe` if you want the font size in points.

Since: 1.14

## descriptionsFree

fontDescriptionsFree Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe [FontDescription] | `descs`: a pointer to an array of `PangoFontDescription`, may be `Nothing`
-> m () |

Deprecated: (Since version 1.56)Just use pango_font_description_free in a loop

Frees an array of font descriptions.

## deserialize

fontDeserialize Source #

Arguments

:: (HasCallStack, MonadIO m, IsContext a) |
=> a | `context`: a `PangoContext`
-> Bytes | `bytes`: the bytes containing the data
-> m (Maybe Font) | Returns: a new `PangoFont` (Can throw `GError`)

Loads data previously created via `fontSerialize`.

For a discussion of the supported format, see that function.

Note: to verify that the returned font is identical to the one that was serialized, you can compare `bytes` to the result of serializing the font again.

Since: 1.50

## getCoverage

fontGetCoverage Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> a | `font`: a `PangoFont`
-> Language | `language`: the language tag
-> m Coverage | Returns: a newly-allocated `PangoCoverage` object.

Computes the coverage map for a given font and language tag.

## getFace

fontGetFace Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> a | `font`: a `PangoFont`
-> m (Maybe FontFace) | Returns: the `PangoFontFace`

Gets the `PangoFontFace` to which `font` belongs.

Note that this function can return `NULL` in cases where the font outlives its font map.

Since: 1.46

## getFeatures

fontGetFeatures Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> a | `font`: a `PangoFont`
-> [FeatureT] | `features`: Array to features in
-> Word32 | `numFeatures`: the number of used items in `features`
-> m ([FeatureT], Word32) |

Obtain the OpenType features that are provided by the font.

These are passed to the rendering system, together with features that have been explicitly set via attributes.

Note that this does not include OpenType features which the rendering system enables by default.

Since: 1.44

## getFontMap

fontGetFontMap Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> Maybe a | `font`: a `PangoFont`
-> m (Maybe FontMap) | Returns: the `PangoFontMap` for the font

Gets the font map for which the font was created.

Note that the font maintains a *weak* reference to the font map, so if all references to font map are dropped, the font map will be finalized even if there are fonts created with the font map that are still alive. In that case this function will return `Nothing`.

It is the responsibility of the user to ensure that the font map is kept alive. In most uses this is not an issue as a `PangoContext` holds a reference to the font map.

Since: 1.10

## getGlyphExtents

fontGetGlyphExtents Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> Maybe a | `font`: a `PangoFont`
-> Word32 | `glyph`: the glyph index
-> m (Rectangle, Rectangle) |

Gets the logical and ink extents of a glyph within a font.

The coordinate system for each rectangle has its origin at the base line and horizontal origin of the character with increasing coordinates extending to the right and down. The macros `PANGO_ASCENT()`, `PANGO_DESCENT()`, `PANGO_LBEARING()`, and `PANGO_RBEARING()` can be used to convert from the extents rectangle to more traditional font metrics. The units of the rectangles are in 1/PANGO_SCALE of a device unit.

If `font` is `Nothing`, this function gracefully sets some sane values in the output variables and returns.

## getLanguages

fontGetLanguages Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> a | `font`: a `PangoFont`
-> m (Maybe [Language]) | Returns: an array of `PangoLanguage`

Returns the languages that are supported by `font`.

If the font backend does not provide this information, `Nothing` is returned. For the fontconfig backend, this corresponds to the FC_LANG member of the FcPattern.

The returned array is only valid as long as the font and its fontmap are valid.

Since: 1.50

## getMetrics

fontGetMetrics Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> Maybe a | `font`: a `PangoFont`
-> Maybe Language | `language`: language tag used to determine which script to get the metrics for, or `Nothing` to indicate to get the metrics for the entire font.
-> m FontMetrics | Returns: a `PangoFontMetrics` object. The caller must call `fontMetricsUnref` when finished using the object.

Gets overall metric information for a font.

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.

If `font` is `Nothing`, this function gracefully sets some sane values in the output variables and returns.

## hasChar

fontHasChar Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> a | `font`: a `PangoFont`
-> Char | `wc`: a Unicode character
-> m Bool | Returns: `TRUE` if `font` can render `wc`

Returns whether the font provides a glyph for this character.

Since: 1.44

## serialize

fontSerialize Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> a | `font`: a `PangoFont`
-> m Bytes | Returns: a `GBytes` containing the serialized form of `font`

Serializes the `font` in a way that can be uniquely identified.

There are no guarantees about the format of the output across different versions of Pango.

The intended use of this function is testing, benchmarking and debugging. The format is not meant as a permanent storage format.

To recreate a font from its serialized form, use `fontDeserialize`.

Since: 1.50