Gtk2HsContentsIndex
Graphics.UI.Gtk.Pango.Layout
Portabilityportable (depends on GHC)
Stabilityprovisional
Maintainergtk2hs-users@lists.sourceforge.net
Description

Functions to run the rendering pipeline.

  • The Pango rendering pipeline takes a string of Unicode characters and converts it into glyphs. The functions described in this module accomplish various steps of this process.

TODO

  • Functions that are missing: pango_layout_set_attributes, pango_layout_get_attributes, pango_layout_set_font_description, pango_layout_set_tabs, pango_layout_get_tabs, pango_layout_get_log_attrs, pango_layout_iter_get_run
  • The following functions cannot be bound easily due to Unicode/UTF8 issues: pango_layout_xy_to_index, pango_layout_index_to_pos, pango_layout_get_cursor_pos, pango_layout_move_cursor_visually, pango_layout_iter_get_index, pango_layout_line_index_to_x, pango_layout_line_x_to_index, pango_layout_line_get_x_ranges
  • These functions are not bound, because they're too easy: pango_layout_get_size, pango_layout_get_pixel_size, pango_layout_get_line
Synopsis
data PangoLayout
layoutCopy :: PangoLayout -> IO PangoLayout
layoutGetContext :: PangoLayout -> IO PangoContext
layoutContextChanged :: PangoLayout -> IO ()
layoutSetText :: PangoLayout -> String -> IO ()
layoutGetText :: PangoLayout -> IO String
layoutSetMarkup :: PangoLayout -> Markup -> IO ()
layoutSetMarkupWithAccel :: PangoLayout -> Markup -> IO Char
layoutSetWidth :: PangoLayout -> Int -> IO ()
layoutGetWidth :: PangoLayout -> IO Int
data LayoutWrapMode
= WrapWholeWords
| WrapAnywhere
| WrapPartialWords
layoutSetWrap :: PangoLayout -> LayoutWrapMode -> IO ()
layoutGetWrap :: PangoLayout -> IO LayoutWrapMode
layoutSetIndent :: PangoLayout -> Int -> IO ()
layoutGetIndent :: PangoLayout -> IO Int
layoutSetSpacing :: PangoLayout -> Int -> IO ()
layoutGetSpacing :: PangoLayout -> IO Int
layoutSetJustify :: PangoLayout -> Bool -> IO ()
layoutGetJustify :: PangoLayout -> IO Bool
data LayoutAlignment
= AlignLeft
| AlignCenter
| AlignRight
layoutSetAlignment :: PangoLayout -> LayoutAlignment -> IO ()
layoutGetAlignment :: PangoLayout -> IO LayoutAlignment
layoutSetSingleParagraphMode :: PangoLayout -> Bool -> IO ()
layoutGetSingleParagraphMode :: PangoLayout -> IO Bool
layoutGetExtents :: PangoLayout -> IO (Rectangle, Rectangle)
layoutGetPixelExtents :: PangoLayout -> IO (Rectangle, Rectangle)
layoutGetLineCount :: PangoLayout -> IO Int
layoutGetLines :: PangoLayout -> IO [LayoutLine]
data LayoutIter
layoutGetIter :: PangoLayout -> IO LayoutIter
layoutIterNextRun :: LayoutIter -> IO Bool
layoutIterNextChar :: LayoutIter -> IO Bool
layoutIterNextCluster :: LayoutIter -> IO Bool
layoutIterNextLine :: LayoutIter -> IO Bool
layoutIterAtLastLine :: LayoutIter -> IO Bool
layoutIterGetBaseline :: LayoutIter -> IO Int
layoutIterGetLine :: LayoutIter -> IO (Maybe LayoutLine)
layoutIterGetCharExtents :: LayoutIter -> IO Rectangle
layoutIterGetClusterExtents :: LayoutIter -> IO (Rectangle, Rectangle)
layoutIterGetRunExtents :: LayoutIter -> IO (Rectangle, Rectangle)
layoutIterGetLineYRange :: LayoutIter -> IO (Int, Int)
layoutIterGetLineExtents :: LayoutIter -> IO (Rectangle, Rectangle)
data LayoutLine
layoutLineGetExtents :: LayoutLine -> IO (Rectangle, Rectangle)
layoutLineGetPixelExtents :: LayoutLine -> IO (Rectangle, Rectangle)
Documentation
data PangoLayout
show/hide Instances
layoutCopy :: PangoLayout -> IO PangoLayout
Create a copy of the Layout.
layoutGetContext :: PangoLayout -> IO PangoContext
Retrieves the PangoContext from this layout.
layoutContextChanged :: PangoLayout -> IO ()

Signal a Context change.

  • Forces recomputation of any state in the PangoLayout that might depend on the layout's context. This function should be called if you make changes to the context subsequent to creating the layout.
layoutSetText :: PangoLayout -> String -> IO ()
Set the string in the layout.
layoutGetText :: PangoLayout -> IO String
Retrieve the string in the layout.
layoutSetMarkup :: PangoLayout -> Markup -> IO ()

Set the string in the layout.

  • The string may include Markup.
layoutSetMarkupWithAccel :: PangoLayout -> Markup -> IO Char

Set the string in the layout.

  • The string may include Markup. Furthermore, any underscore character indicates that the next character should be marked as accelerator (i.e. underlined). A literal underscore character can be produced by placing it twice in the string.
  • The character which follows the underscore is returned so it can be used to add the actual keyboard shortcut.
layoutSetWidth :: PangoLayout -> Int -> IO ()

Set the width of this paragraph.

  • Sets the width to which the lines of the PangoLayout should be wrapped.
  • width is the desired width, or -1 to indicate that no wrapping should be performed.
layoutGetWidth :: PangoLayout -> IO Int

Gets the width of this paragraph.

  • Gets the width to which the lines of the PangoLayout should be wrapped.
  • Returns is the current width, or -1 to indicate that no wrapping is performed.
data LayoutWrapMode

Enumerates how a line can be wrapped.

WrapWholeWords
Breaks lines only between words.
  • This variant does not guarantee that the requested width is not exceeded. A word that is longer than the paragraph width is not split.
WrapAnywhere
Break lines anywhere.
WrapPartialWords
Wrap within a word if it is the only one on this line.
  • This option acts like WrapWholeWords but will split a word if it is the only one on this line and it exceeds the specified width.
Constructors
WrapWholeWords
WrapAnywhere
WrapPartialWords
show/hide Instances
layoutSetWrap :: PangoLayout -> LayoutWrapMode -> IO ()

Set how this paragraph is wrapped.

  • Sets the wrap style; the wrap style only has an effect if a width is set on the layout with layoutSetWidth. To turn off wrapping, set the width to -1.
layoutGetWrap :: PangoLayout -> IO LayoutWrapMode
Get the wrap mode for the layout.
layoutSetIndent :: PangoLayout -> Int -> IO ()

Set the indentation of this paragraph.

  • Sets the amount by which the first line should be shorter than the rest of the lines. This may be negative, in which case the subsequent lines will be shorter than the first line. (However, in either case, the entire width of the layout will be given by the value.
layoutGetIndent :: PangoLayout -> IO Int

Gets the indentation of this paragraph.

  • Gets the amount by which the first line should be shorter than the rest of the lines.
layoutSetSpacing :: PangoLayout -> Int -> IO ()
Set the spacing between lines of this paragraph.
layoutGetSpacing :: PangoLayout -> IO Int
Gets the spacing between the lines.
layoutSetJustify :: PangoLayout -> Bool -> IO ()

Set if text should be streched to fit width.

  • Sets whether or not each complete line should be stretched to fill the entire width of the layout. This stretching is typically done by adding whitespace, but for some scripts (such as Arabic), the justification is done by extending the characters.
layoutGetJustify :: PangoLayout -> IO Bool

Retrieve the justification flag.

data LayoutAlignment
Enumerate to which side incomplete lines are flushed.
Constructors
AlignLeft
AlignCenter
AlignRight
show/hide Instances
layoutSetAlignment :: PangoLayout -> LayoutAlignment -> IO ()

Set how this paragraph is aligned.

  • Sets the alignment for the layout (how partial lines are positioned within the horizontal space available.)
layoutGetAlignment :: PangoLayout -> IO LayoutAlignment
Get the alignment for the layout.
layoutSetSingleParagraphMode :: PangoLayout -> Bool -> IO ()

Honor newlines or not.

  • If honor is True, do not treat newlines and similar characters as paragraph separators; instead, keep all text in a single paragraph, and display a glyph for paragraph separator characters. Used when you want to allow editing of newlines on a single text line.
layoutGetSingleParagraphMode :: PangoLayout -> IO Bool

Retrieve if newlines are honored.

layoutGetExtents :: PangoLayout -> IO (Rectangle, Rectangle)

Compute the physical size of the layout.

  • Computes the logical and the ink size of the Layout. The logical layout 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.
  • All values are in layout units. To get to device units (pixel for Drawables) divide by pangoScale.
layoutGetPixelExtents :: PangoLayout -> IO (Rectangle, Rectangle)

Compute the physical size of the layout.

  • Computes the logical and the ink size of the Layout. The logical layout 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.
  • All values are in device units. This function is a wrapper around layoutGetExtents with scaling.
layoutGetLineCount :: PangoLayout -> IO Int
Ask for the number of lines in this layout.
layoutGetLines :: PangoLayout -> IO [LayoutLine]

Extract the single lines of the layout.

  • The lines of each layout are regenerated if any attribute changes. Thus the returned list does not reflect the current state of lines after a change has been made.
data LayoutIter
An iterator to examine a layout.
layoutGetIter :: PangoLayout -> IO LayoutIter
Create an iterator to examine a layout.
layoutIterNextRun :: LayoutIter -> IO Bool

Move to the next run.

  • Returns False if this was the last run in the layout.
layoutIterNextChar :: LayoutIter -> IO Bool

Move to the next char.

  • Returns False if this was the last char in the layout.
layoutIterNextCluster :: LayoutIter -> IO Bool

Move to the next cluster.

  • Returns False if this was the last cluster in the layout.
layoutIterNextLine :: LayoutIter -> IO Bool

Move to the next line.

  • Returns False if this was the last line in the layout.
layoutIterAtLastLine :: LayoutIter -> IO Bool

Check if the iterator is on the last line.

  • Returns True if the iterator is on the last line of this paragraph.
layoutIterGetBaseline :: LayoutIter -> IO Int

Query the vertical position within the layout.

  • Gets the y position of the current line's baseline, in layout coordinates (origin at top left of the entire layout).
layoutIterGetLine :: LayoutIter -> IO (Maybe LayoutLine)
Extract the line under the iterator.
layoutIterGetCharExtents :: LayoutIter -> IO Rectangle

Retrieve a rectangle surrounding a character.

  • Get the extents of the current character in layout cooridnates (origin is the top left of the entire layout). Only logical extents can sensibly be obtained for characters.
layoutIterGetClusterExtents :: LayoutIter -> IO (Rectangle, Rectangle)

Compute the physical size of the cluster.

  • Computes the logical and the ink size of the cluster pointed to by LayoutIter.
  • All values are in layoutIter units. To get to device units (pixel for Drawables) divide by pangoScale.
layoutIterGetRunExtents :: LayoutIter -> IO (Rectangle, Rectangle)

Compute the physical size of the run.

  • Computes the logical and the ink size of the run pointed to by LayoutIter.
  • All values are in layoutIter units. To get to device units (pixel for Drawables) divide by pangoScale.
layoutIterGetLineYRange :: LayoutIter -> IO (Int, Int)

Retrieve vertical extent of this line.

  • Divides the vertical space in the PangoLayout being iterated over between the lines in the layout, and returns the space belonging to the current line. A line's range includes the line's logical extents, plus half of the spacing above and below the line, if pangoLayoutSetSpacing has been called to set layout spacing. The y positions are in layout coordinates (origin at top left of the entire layout).
  • The first element in the returned tuple is the start, the second is the end of this line.
layoutIterGetLineExtents :: LayoutIter -> IO (Rectangle, Rectangle)

Compute the physical size of the line.

  • Computes the logical and the ink size of the line pointed to by LayoutIter.
  • Extents are in layout coordinates (origin is the top-left corner of the entire PangoLayout). Thus the extents returned by this function will be the same width/height but not at the same x/y as the extents returned from pangoLayoutLineGetExtents.
data LayoutLine
A single line in a PangoLayout.
layoutLineGetExtents :: LayoutLine -> IO (Rectangle, Rectangle)

Compute the physical size of the line.

  • Computes the logical and the ink size of the LayoutLine. The logical layout 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.
  • All values are in layout units. To get to device units (pixel for Drawables) divide by pangoScale.
layoutLineGetPixelExtents :: LayoutLine -> IO (Rectangle, Rectangle)

Compute the physical size of the line.

  • Computes the logical and the ink size of the LayoutLine. The logical layout 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.
  • All values are in device units. This function is a wrapper around layoutLineGetExtents with scaling.
Produced by Haddock version 0.7