Portability | portable (depends on GHC) |
---|---|
Stability | provisional |
Maintainer | gtk2hs-users@lists.sourceforge.net |
Safe Haskell | None |
Functions to run the rendering pipeline.
- This module provides elementary rendering functions. For a simpler
interface, consider using
PangoLayout
s. - The Pango rendering pipeline takes a string of Unicode characters,
divides them into sequences of letters that have the same characteristics
such as font, size, color, etc. Such a sequence is called
PangoItem
. EachPangoItem
is then converted into oneGlyphItem
, that is an actual sequence of glyphs, where several characters might be turned into legatures or clusters, e.g. an "e" and an accent modifier are turned into a single glyph. TheseGlyphItem
s can then be rendered onto the output device with functions such ascairoShowGlyphString
.
- data PangoItem
- pangoItemize :: PangoContext -> String -> [PangoAttribute] -> IO [PangoItem]
- pangoItemGetFontMetrics :: PangoItem -> IO FontMetrics
- pangoItemGetFont :: PangoItem -> IO Font
- pangoItemGetLanguage :: PangoItem -> IO Language
- data GlyphItem
- pangoShape :: PangoItem -> IO GlyphItem
- glyphItemExtents :: GlyphItem -> IO (PangoRectangle, PangoRectangle)
- glyphItemExtentsRange :: GlyphItem -> Int -> Int -> IO (PangoRectangle, PangoRectangle)
- glyphItemIndexToX :: GlyphItem -> Int -> Bool -> IO Double
- glyphItemXToIndex :: GlyphItem -> Double -> IO (Int, Bool)
- glyphItemGetLogicalWidths :: GlyphItem -> Maybe Bool -> IO [Double]
- glyphItemSplit :: GlyphItem -> Int -> IO (GlyphItem, GlyphItem)
PangoItem
: Partition text into units with similar attributes.
A sequence of characters that are rendered with the same settings.
pangoItemize :: PangoContext -> String -> [PangoAttribute] -> IO [PangoItem]Source
Turn a string into a sequence of glyphs.
- Partitions the input string into segments with the same text direction and shaping engine. The generated list of items will be in logical order (the start offsets of the items are ascending).
pangoItemGetFontMetrics :: PangoItem -> IO FontMetricsSource
Retrieve the metrics of the font that was chosen to break the given
PangoItem
.
GlyphItem
: Turn text segments into glyph sequences.
A sequence of glyphs for a chunk of a string.
- A glyph item contains the graphical representation of a
PangoItem
. Clusters (likee
and an accent modifier) as well as legatures (such asffi
turning into a single letter that omits the dot over thei
) are usually represented as a single glyph.
pangoShape :: PangoItem -> IO GlyphItemSource
glyphItemExtents :: GlyphItem -> IO (PangoRectangle, PangoRectangle)Source
Ask for bounding rectangles of this glyph sequence.
- Compute the logical and ink extents of a glyph string. The logical extend is used for positioning, the ink size is the smallest bounding box that includes all character pixels. The ink size can be smaller or larger that the logical layout.
glyphItemExtentsRange :: GlyphItem -> Int -> Int -> IO (PangoRectangle, PangoRectangle)Source
Ask for bounding rectangles for a sub-range of a glyph sequence.
- The returned rectangles are relative to the given sub-range, that is,
the result of this function is the same as if
glyphItemExtents
were called on the sub-string.
:: GlyphItem | the rendered string |
-> Int | the index into the string |
-> Bool | return the beginning ( |
-> IO Double |
Get the horizontal position of a character.
- Clusters (e.g. "e" with an accent modifier) are divided up into equal portions.
glyphItemXToIndex :: GlyphItem -> Double -> IO (Int, Bool)Source
Get the character at the given horizontal position.
- The position is clipped to the width of this line.
- The function returns the position in the string that corresponds
to the given horizontal location. Furthermore, if the position lies
on the first half of the character,
False
is returned.
glyphItemGetLogicalWidths :: GlyphItem -> Maybe Bool -> IO [Double]Source
Retrieve the width of every character in a string.
- The boolean parameter
determines if the returned array starts with the leftmost glyph
(
False
) or with the rightmost glyph (True
). IfNothing
is passed in, the direction is taken from theGlyphItem
, i.e., the array starts with the leftmost glyph for left-to-rigth text and with the rightmost glyph for right-to-left text. When multiple characters compose a single glyph, the width of this glyph is divided among the characters that compose this cluster.
glyphItemSplit :: GlyphItem -> Int -> IO (GlyphItem, GlyphItem)Source
Split a GlyphItem
at the given index.
- The given
GlyphItem
is split at the given index. The index must be at least one and not greater or equal to length, i.e. the item must be split into two non-empty segments. The function throws anArrayException
if the index is out of bounds.