Copyright | (c) 2018 Francisco Vallarino |
---|---|
License | BSD-3-Clause (see the LICENSE file) |
Maintainer | fjvallarino@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Helper functions for calculating text size.
Synopsis
- calcTextSize :: FontManager -> StyleState -> Text -> Size
- calcTextSize_ :: FontManager -> StyleState -> TextMode -> TextTrim -> Maybe Double -> Maybe Int -> Text -> Size
- fitTextToSize :: FontManager -> StyleState -> TextOverflow -> TextMode -> TextTrim -> Maybe Int -> Size -> Text -> Seq TextLine
- fitTextToWidth :: FontManager -> StyleState -> Double -> TextTrim -> Text -> Seq TextLine
- alignTextLines :: StyleState -> Rect -> Seq TextLine -> Seq TextLine
- moveTextLines :: Point -> Seq TextLine -> Seq TextLine
- getTextLinesSize :: Seq TextLine -> Size
- getGlyphsMin :: Seq GlyphPos -> Double
- getGlyphsMax :: Seq GlyphPos -> Double
Documentation
:: 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.
:: 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.
:: 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.
:: 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, potencially spliting into several lines.
:: 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.
Moves a Seq of TextLines by the given offset.