pango-0.13.4.0: Binding to the Pango text rendering engine.

Maintainergtk2hs-users@lists.sourceforge.net
Stabilityprovisional
Portabilityportable (depends on GHC)
Safe HaskellNone
LanguageHaskell98

Graphics.Rendering.Pango.Markup

Description

This module defines some helper functions for generating texts with embedded attributes. Note that there is no need to use these functions. In particular, if you set markup in labels that are subject to internationalization, it can be of advantage to write out the markup instead of using the functions in this module.

In order to display a string that may contain markup characters, use escapeMarkup.

When you write markup directly, you can make use of the following convenience tags:

b
Bold
big
Makes font relatively larger
i
Italic
s
Strikethrough
sub
Subscript
sup
Superscript
small
Makes font relatively smaller
tt
Monospace font
u
Underline

Synopsis

Documentation

data SpanAttribute Source #

These are all the attributes the markSpan function can express.

Constructors

FontDescr String

Choose a font by textual description.

  • Takes a string to completely describe the font, example: FontDescr "Sans Italic 12"
FontFamily String

Specify the family of font to use.

  • Example: FontFamily "Sans"
FontSize Size

Change the size of the current font.

  • The constuctor takes the size in points (pt) or a predefined sizes. Setting the absolute size 12.5pt can be achieved by passing FontSize (SizePoint 12.5) to markSpan. Next to predefined absolute sizes such as SizeSmall the size can be changed by asking for the next larger or smaller front with SizeLarger and SizeSmaller, respectively.
FontStyle FontStyle

Change the slant of the current font.

FontWeight Weight

Change the thickness of the current font.

  • The constructor takes one of the six predefined weights. Most likely to be supported: WeightBold.
FontVariant Variant

Choosing an alternative rendering for lower case letters.

  • The argument VariantSmallCaps will display lower case letters as smaller upper case letters, if this option is available.
FontStretch Stretch

Choose a different width.

FontForeground String

Foreground color.

  • This constructor and FontBackground take both a description of the color to be used for rendering. The name is either a hex code of the form "#RRGGBB" or an X11 color name like "dark olive green".
FontBackground String

Background color.

FontUnderline Underline

Specify underlining of text.

FontRise Double

Specify a vertical displacement.

  • Takes the vertical displacement in em (the width of the 'm' character in the current font).
FontLang Language

Give a hint about the language to be displayed.

  • This hint might help the system rendering a particular piece of text with different fonts that are more suitable for the given language.
FontGravity PangoGravity

Gravity of text, use for ratation.

FontGravityHint PangoGravityHint

Intensity of gravity.

markSpan :: [SpanAttribute] -> String -> String Source #

Create the most generic span attribute.

parseMarkup Source #

Arguments

:: (GlibString markup, GlibString string) 
=> markup

the string containing markup

-> Char

accelMarker - the character that prefixes an accelerator

-> IO ([[PangoAttribute]], Char, string)

list of attributes, the accelerator character found and the input string without markup

Parse the marked-up text (see Markup format) to create a plain-text string and an attribute list.

  • The attribute list is a list of lists of attribute. Each list describes the attributes for the same span.
  • If accelMarker is not '\0' (a zero character), the given character will mark the character following it as an accelerator. For example, accelMarker might be an ampersand or underscore. All characters marked as an accelerator will receive a UnderlineLow attribute, and the first character so marked will be returned as accelChar. If no accelerator character is found, the accelMarker character itself is returned. Two accelMarker characters following each other produce a single literal accelMarker character.
  • If a parsing error occurs a GError is thrown.