gi-pango-1.0.29: 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.GlyphString

Contents

- Exported types
- Methods
  - copy
  - extents
  - extentsRange
  - free
  - getLogicalWidths
  - getWidth
  - indexToX
  - indexToXFull
  - new
  - setSize
  - xToIndex
- Properties
  - logClusters
  - numGlyphs

Description

A `PangoGlyphString` is used to store strings of glyphs with geometry and visual attribute information.

The storage for the glyph information is owned by the structure which simplifies memory management.

Synopsis

- newtype GlyphString = GlyphString (ManagedPtr GlyphString)
- newZeroGlyphString :: MonadIO m => m GlyphString
- glyphStringCopy :: (HasCallStack, MonadIO m) => GlyphString -> m (Maybe GlyphString)
- glyphStringExtents :: (HasCallStack, MonadIO m, IsFont a) => GlyphString -> a -> m (Rectangle, Rectangle)
- glyphStringExtentsRange :: (HasCallStack, MonadIO m, IsFont a) => GlyphString -> Int32 -> Int32 -> a -> m (Rectangle, Rectangle)
- glyphStringFree :: (HasCallStack, MonadIO m) => GlyphString -> m ()
- glyphStringGetLogicalWidths :: (HasCallStack, MonadIO m) => GlyphString -> Text -> Int32 -> Int32 -> [Int32] -> m ()
- glyphStringGetWidth :: (HasCallStack, MonadIO m) => GlyphString -> m Int32
- glyphStringIndexToX :: (HasCallStack, MonadIO m) => GlyphString -> Text -> Int32 -> Analysis -> Int32 -> Bool -> m Int32
- glyphStringIndexToXFull :: (HasCallStack, MonadIO m) => GlyphString -> Text -> Int32 -> Analysis -> Maybe LogAttr -> Int32 -> Bool -> m Int32
- glyphStringNew :: (HasCallStack, MonadIO m) => m GlyphString
- glyphStringSetSize :: (HasCallStack, MonadIO m) => GlyphString -> Int32 -> m ()
- glyphStringXToIndex :: (HasCallStack, MonadIO m) => GlyphString -> Text -> Int32 -> Analysis -> Int32 -> m (Int32, Int32)
- getGlyphStringLogClusters :: MonadIO m => GlyphString -> m Int32
- setGlyphStringLogClusters :: MonadIO m => GlyphString -> Int32 -> m ()
- getGlyphStringNumGlyphs :: MonadIO m => GlyphString -> m Int32
- setGlyphStringNumGlyphs :: MonadIO m => GlyphString -> Int32 -> m ()

# Exported types

newtype GlyphString Source #

Memory-managed wrapper type.

Constructors

GlyphString (ManagedPtr GlyphString) |

#### Instances

Instances details

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

newZeroGlyphString :: MonadIO m => m GlyphString Source #

Construct a `GlyphString` struct initialized to zero.

# Methods

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

Expand

#### Methods

copy, extents, extentsRange, free, indexToX, indexToXFull, xToIndex.

#### Getters

getLogicalWidths, getWidth.

#### Setters

setSize.

## copy

glyphStringCopy Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GlyphString | `string`: a `PangoGlyphString`
-> m (Maybe GlyphString) | Returns: the newly allocated `PangoGlyphString`

Copy a glyph string and associated storage.

## extents

glyphStringExtents Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> GlyphString | `glyphs`: a `PangoGlyphString`
-> a | `font`: a `PangoFont`
-> m (Rectangle, Rectangle) |

Compute the logical and ink extents of a glyph string.

See the documentation for `fontGetGlyphExtents` for details about the interpretation of the rectangles.

Examples of logical (red) and ink (green) rects:

## extentsRange

glyphStringExtentsRange Source #

Arguments

:: (HasCallStack, MonadIO m, IsFont a) |
=> GlyphString | `glyphs`: a `PangoGlyphString`
-> Int32 | `start`: start index
-> Int32 | `end`: end index (the range is the set of bytes with indices such that start <= index < end)
-> a | `font`: a `PangoFont`
-> m (Rectangle, Rectangle) |

Computes the extents of a sub-portion of a glyph string.

The extents are relative to the start of the glyph string range (the origin of their coordinate system is at the start of the range, not at the start of the entire glyph string).

## free

glyphStringFree Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GlyphString | `string`: a `PangoGlyphString`, may be `Nothing`
-> m () |

Free a glyph string and associated storage.

## getLogicalWidths

glyphStringGetLogicalWidths Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GlyphString | `glyphs`: a `PangoGlyphString`
-> Text | `text`: the text corresponding to the glyphs
-> Int32 | `length`: the length of `text`, in bytes
-> Int32 | `embeddingLevel`: the embedding level of the string
-> [Int32] | `logicalWidths`: an array whose length is the number of characters in text (equal to `g_utf8_strlen (text, length)` unless text has `NUL` bytes) to be filled in with the resulting character widths.
-> m () |

Given a `PangoGlyphString` and corresponding text, determine the width corresponding to each character.

When multiple characters compose a single cluster, the width of the entire cluster is divided equally among the characters.

See also `glyphItemGetLogicalWidths`.

## getWidth

glyphStringGetWidth Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GlyphString | `glyphs`: a `PangoGlyphString`
-> m Int32 | Returns: the logical width of the glyph string.

Computes the logical width of the glyph string.

This can also be computed using `glyphStringExtents`. However, since this only computes the width, it's much faster. This is in fact only a convenience function that computes the sum of `geometry`.width for each glyph in the `glyphs`.

Since: 1.14

## indexToX

glyphStringIndexToX Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GlyphString | `glyphs`: the glyphs return from [func`shape`]
-> Text | `text`: the text for the run
-> Int32 | `length`: the number of bytes (not characters) in `text`.
-> Analysis | `analysis`: the analysis information return from [func`itemize`]
-> Int32 | `index_`: the byte index within `text`
-> Bool | `trailing`: whether we should compute the result for the beginning (`False`) or end (`True`) of the character.
-> m Int32 |

Converts from character position to x position.

The X position is measured from the left edge of the run. Character positions are obtained using font metrics for ligatures where available, and computed by dividing up each cluster into equal portions, otherwise.

<picture> <source srcset="glyphstring-positions-dark.png" media="(prefers-color-scheme: dark)"> <img alt="Glyph positions" src="glyphstring-positions-light.png"> </picture>

## indexToXFull

glyphStringIndexToXFull Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GlyphString | `glyphs`: the glyphs return from [func`shape`]
-> Text | `text`: the text for the run
-> Int32 | `length`: the number of bytes (not characters) in `text`.
-> Analysis | `analysis`: the analysis information return from [func`itemize`]
-> Maybe LogAttr | `attrs`: `PangoLogAttr` array for `text`
-> Int32 | `index_`: the byte index within `text`
-> Bool | `trailing`: whether we should compute the result for the beginning (`False`) or end (`True`) of the character.
-> m Int32 |

Converts from character position to x position.

This variant of `glyphStringIndexToX` additionally accepts a `PangoLogAttr` array. The grapheme boundary information in it can be used to disambiguate positioning inside some complex clusters.

Since: 1.50

## new

glyphStringNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m GlyphString | Returns: the newly allocated `PangoGlyphString`, which should be freed with `glyphStringFree`.

Create a new `PangoGlyphString`.

## setSize

glyphStringSetSize Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GlyphString | `string`: a `PangoGlyphString`.
-> Int32 | `newLen`: the new length of the string
-> m () |

Resize a glyph string to the given length.

## xToIndex

glyphStringXToIndex Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GlyphString | `glyphs`: the glyphs returned from [func`shape`]
-> Text | `text`: the text for the run
-> Int32 | `length`: the number of bytes (not characters) in text.
-> Analysis | `analysis`: the analysis information return from [func`itemize`]
-> Int32 | `xPos`: the x offset (in Pango units)
-> m (Int32, Int32) |

Convert from x offset to character position.

Character positions are computed by dividing up each cluster into equal portions. In scripts where positioning within a cluster is not allowed (such as Thai), the returned value may not be a valid cursor position; the caller must combine the result with the logical attributes for the text to compute the valid cursor position.

# Properties

## logClusters

logical cluster info, indexed by the byte index within the text corresponding to the glyph string

getGlyphStringLogClusters :: MonadIO m => GlyphString -> m Int32 Source #

Get the value of the “`log_clusters`” field. When overloading is enabled, this is equivalent to

    get glyphString #logClusters

setGlyphStringLogClusters :: MonadIO m => GlyphString -> Int32 -> m () Source #

Set the value of the “`log_clusters`” field. When overloading is enabled, this is equivalent to

    set glyphString [ #logClusters := value ]

## numGlyphs

number of glyphs in this glyph string

getGlyphStringNumGlyphs :: MonadIO m => GlyphString -> m Int32 Source #

Get the value of the “`num_glyphs`” field. When overloading is enabled, this is equivalent to

    get glyphString #numGlyphs

setGlyphStringNumGlyphs :: MonadIO m => GlyphString -> Int32 -> m () Source #

Set the value of the “`num_glyphs`” field. When overloading is enabled, this is equivalent to

    set glyphString [ #numGlyphs := value ]