~jaro/balkon

ref: 18e994081f0919013b51e3d73cf58022fed3ee6c balkon/src/Data/Text/ParagraphLayout/Internal/Fragment.hs -rw-r--r-- 1.6 KiB
18e99408Jaro Expose ParagraphConstruction. 1 year, 8 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
module Data.Text.ParagraphLayout.Internal.Fragment (Fragment(..))
where

import Data.Int (Int32)
import Data.Text.Glyphize (GlyphInfo, GlyphPos)

import Data.Text.ParagraphLayout.Internal.Rect

-- | Box fragment or fragment (CSS3), except that continuous text even within
-- one line can be split into multiple fragments because of spans or changes in
-- script.
data Fragment = Fragment
    { fragmentRect :: Rect Int32
    -- ^ Physical position of the fragment within the paragraph, calculated
    -- using all glyph advances in this fragment and the calculated line height.
    --
    -- This is the space that the glyphs "take up" and is probably what you
    -- want to use for detecting position-based events such as mouse clicks.
    --
    -- Beware that actual glyphs will not be drawn exactly to the borders of
    -- this rectangle -- they may be offset inwards and they can also extend
    -- outwards!
    --
    -- These are not the typographic bounding boxes that you use for determining
    -- the area to draw on -- you need FreeType or a similar library for that.
    --
    -- The origin coordinates are relative to the paragraph.
    --
    -- The sizes can be positive or negative, depending on the text direction.
    --
    -- X coordinates increase from left to right.
    -- Y coordinates increase from bottom to top.
    , fragmentPen :: (Int32, Int32)
    -- ^ Coordinates of the initial pen position, from which the first glyph
    -- should be drawn. That glyph's `x_advance` or `y_advance` are then used
    -- to move the pen position for the next glyph.
    , fragmentGlyphs :: [(GlyphInfo, GlyphPos)]
    }
    deriving (Eq, Read, Show)