~jaro/balkon

ref: ae2fb11e89078608bbc1722b8b4096e5b20edf8b balkon/src/Data/Text/ParagraphLayout/Internal/TextOptions.hs -rw-r--r-- 1.5 KiB
ae2fb11eJaro Separate WithSpan for sharing with other modules. 1 year, 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module Data.Text.ParagraphLayout.Internal.TextOptions
    ( TextOptions (..)
    , defaultTextOptions
    )
where

import Data.Text.Glyphize (Font, emptyFont)

import Data.Text.ParagraphLayout.Internal.LineHeight

-- | Style options to be applied to a text sequence.
--
-- This record type is likely to be extended in the future.
-- Use `defaultTextOptions` and update it with specific record selectors
-- instead of constructing `TextOptions` directly.
data TextOptions = TextOptions

    { textFont :: Font
    -- ^ Font to be used for shaping and measurement.
    -- Make sure to set its scale (see `Data.Text.Glyphize.optionScale`) using
    -- the same units that you want in the output.

    , textLineHeight :: LineHeight
    -- ^ Preferred line height of the resulting fragments.

    , textLanguage :: String
    -- ^ IETF BCP 47 language tag, such as the value expected to be found in
    -- the HTML @lang@ attribute, specifying the primary language for the
    -- span's text content. An empty string explicitly means "language unknown".
    --
    -- Used for selecting the appropriate glyphs and line breaking rules,
    -- primarily in East Asian languages.

    -- TODO: textVerticalAlign
    -- TODO: textLetterSpacing
    -- TODO: textWordSpacing
    -- TODO: textDirection
    -- TODO: textFontFeatures
    -- TODO: textSoftBreaks

    }
    deriving (Eq)

-- | `TextOptions` with default values.
defaultTextOptions :: TextOptions
defaultTextOptions = TextOptions
    { textFont = emptyFont
    , textLineHeight = Normal
    , textLanguage = ""
    }