~jaro/balkon

ref: 073b66e243ec1ffa8f1627756a9bb8dcc533e677 balkon/test/Data/Text/ParagraphLayout/SpanData.hs -rw-r--r-- 2.9 KiB
073b66e2Jaro Move ScriptCode to appropriate module. 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
module Data.Text.ParagraphLayout.SpanData
    ( emptySpan
    , czechHello
    , arabicHello
    , serbianMixedScript
    , englishAroundArabic
    )
where

import Data.Text (pack)
import Data.Text.Glyphize (Direction (DirLTR, DirRTL), Font)

import Data.Text.ParagraphLayout.Internal.BoxOptions
import Data.Text.ParagraphLayout.Internal.LineHeight
import Data.Text.ParagraphLayout.Internal.ResolvedBox
import Data.Text.ParagraphLayout.Internal.ResolvedSpan
import Data.Text.ParagraphLayout.Internal.TextOptions

defaultBox :: Direction -> ResolvedBox ()
defaultBox dir = ResolvedBox () 0 defaultBoxOptions dir

emptySpan :: Font -> ResolvedSpan ()
emptySpan font = ResolvedSpan
    { spanUserData = ()
    , spanIndex = 0
    , spanOffsetInParagraph = 0
    , spanText = pack ""
    , spanTextOptions = (defaultTextOptions DirLTR)
        { textFont = font
        , textLineHeight = Normal
        , textLanguage = "en"
        }
    , spanBoxes = [defaultBox DirLTR]
    , spanLineBreaks = []
    , spanCharacterBreaks = []
    }

czechHello :: Font -> ResolvedSpan ()
czechHello font = ResolvedSpan
    { spanUserData = ()
    , spanIndex = 0
    , spanOffsetInParagraph = 0
    , spanText = pack "Ahoj, světe!"
    , spanTextOptions = (defaultTextOptions DirLTR)
        { textFont = font
        , textLineHeight = Normal
        , textLanguage = "cs"
        }
    , spanBoxes = [defaultBox DirLTR]
    , spanLineBreaks = []
    , spanCharacterBreaks = []
    }

arabicHello :: Font -> ResolvedSpan ()
arabicHello font = ResolvedSpan
    { spanUserData = ()
    , spanIndex = 0
    , spanOffsetInParagraph = 0
    , spanText = pack "سلام"
    , spanTextOptions = (defaultTextOptions DirRTL)
        { textFont = font
        , textLineHeight = Normal
        , textLanguage = "ar"
        }
    , spanBoxes = [defaultBox DirRTL]
    , spanLineBreaks = []
    , spanCharacterBreaks = []
    }

serbianMixedScript :: Font -> ResolvedSpan ()
serbianMixedScript font = ResolvedSpan
    { spanUserData = ()
    , spanIndex = 0
    , spanOffsetInParagraph = 0
    , spanText = pack "Vikipedija (Википедија)"
    , spanTextOptions = (defaultTextOptions DirLTR)
        { textFont = font
        , textLineHeight = Normal
        , textLanguage = "sr"
        }
    , spanBoxes = [defaultBox DirLTR]
    , spanLineBreaks = []
    , spanCharacterBreaks = []
    }

-- | Source:
-- <https://www.w3.org/International/articles/inline-bidi-markup/uba-basics>
englishAroundArabic :: Font -> ResolvedSpan ()
englishAroundArabic font = ResolvedSpan
    { spanUserData = ()
    , spanIndex = 0
    , spanOffsetInParagraph = 0
    , spanText = pack "The title is مفتاح معايير الويب in Arabic."
    , spanTextOptions = (defaultTextOptions DirLTR)
        { textFont = font
        , textLineHeight = Normal
        , textLanguage = "en"
        }
    , spanBoxes = [defaultBox DirLTR]
    , spanLineBreaks = []
    , spanCharacterBreaks = []
    }