~jaro/balkon

ref: 9e3b0ec7fd4a92e3d2dba81cd00dadc4dfe4006c balkon/src/Data/Text/ParagraphLayout/Internal/ParagraphOptions.hs -rw-r--r-- 1.9 KiB
9e3b0ec7Jaro Set release date for v1.3.0.0. 1 year, 4 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
51
52
53
54
55
module Data.Text.ParagraphLayout.Internal.ParagraphOptions
    ( ParagraphOptions (..)
    , defaultParagraphOptions
    )
where

import Data.Int (Int32)
import Data.Text.Glyphize (Font, emptyFont)

import Data.Text.ParagraphLayout.Internal.LineHeight
import Data.Text.ParagraphLayout.Internal.ParagraphAlignment

-- | Defines options relevant to the entire paragraph.
--
-- This record type is likely to be extended in the future.
-- Use `defaultParagraphOptions` and update it with specific record selectors
-- instead of constructing `ParagraphOptions` directly.
--
-- In order to get CSS defaults, use:
--
-- > defaultParagraphOptions { paragraphAlignment = AlignStart }
data ParagraphOptions = ParagraphOptions

    { paragraphFont :: 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.

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

    , paragraphAlignment :: ParagraphAlignment
    -- ^ Alignment of non-overflowing lines within the paragraph.

    , paragraphMaxWidth :: Int32
    -- ^ Line width at which line breaking should occur.
    -- Lines will be broken at language-appropriate boundaries.
    -- If a line still exceeds this limit then, it will be broken at character
    -- boundaries, and if it already consists of a single cluster that cannot
    -- be further broken down, it will overflow.

    }
    deriving (Eq)

-- | `ParagraphOptions` with backwards-compatible values.
--
-- Note that this sets `paragraphAlignment` to `AlignLeft`,
-- whereas the CSS default should be `AlignStart`.
defaultParagraphOptions :: ParagraphOptions
defaultParagraphOptions = ParagraphOptions
    { paragraphFont = emptyFont
    , paragraphLineHeight = Normal
    , paragraphAlignment = AlignLeft
    , paragraphMaxWidth = maxBound
    }