monomer-1.5.1.0: A GUI library for writing native Haskell applications.
Copyright(c) 2018 Francisco Vallarino
LicenseBSD-3-Clause (see the LICENSE file)
Maintainerfjvallarino@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Monomer.Graphics.Text

Description

Helper functions for calculating text size.

Synopsis

Documentation

calcTextSize Source #

Arguments

:: FontManager

The font manager.

-> StyleState

The style.

-> Text

The text to calculate.

-> Size

The calculated size.

Returns the size a given text an style will take.

calcTextSize_ Source #

Arguments

:: FontManager

The font manager.

-> StyleState

The style.

-> TextMode

Single or multiline.

-> TextTrim

Whether to trim or keep spaces.

-> Maybe Double

Optional max width (needed for multiline).

-> Maybe Int

Optional max lines.

-> Text

The text to calculate.

-> Size

The calculated size.

Returns the size a given text an style will take.

fitTextToSize Source #

Arguments

:: FontManager

The font manager.

-> StyleState

The style.

-> TextOverflow

Whether to clip or use ellipsis.

-> TextMode

Single or multiline.

-> TextTrim

Whether to trim or keep spaces.

-> Maybe Int

Optional max lines.

-> Size

The bounding size.

-> Text

The text to fit.

-> Seq TextLine

The fitted text lines.

Fits the given text to a determined size, splitting on multiple lines as needed. Since the function returns glyphs that may be partially visible, the text can overflow vertically or horizontally and a scissor is needed. The rectangles are returned with zero offset (i.e., x = 0 and first line y = 0), and a translation transform is needed when rendering.

fitTextToWidth Source #

Arguments

:: FontManager

The fontManager.

-> StyleState

The style.

-> Double

The maximum width.

-> TextTrim

Whether to trim or keep spaces.

-> Text

The text to calculate.

-> Seq TextLine

The fitted text lines.

Fits a single line of text to the given width, potentially splitting into several lines.

alignTextLines Source #

Arguments

:: StyleState

The style.

-> Rect

The bounding rect. Text may overflow.

-> Seq TextLine

The TextLines to align.

-> Seq TextLine

The aligned TextLines.

Aligns a Seq of TextLines to the given rect.

moveTextLines Source #

Arguments

:: Point

The offset.

-> Seq TextLine

The TextLines.

-> Seq TextLine

The displaced TextLines.

Moves a Seq of TextLines by the given offset.

getTextLinesSize :: Seq TextLine -> Size Source #

Returns the combined size of a sequence of text lines.

getGlyphsMin :: Seq GlyphPos -> Double Source #

Gets the minimum x a Seq of Glyphs will use.

getGlyphsMax :: Seq GlyphPos -> Double Source #

Gets the maximum x a Seq of Glyphs will use.