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
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
sampleSpan :: Direction -> String -> String -> Font -> ResolvedSpan ()
sampleSpan dir lang str font = ResolvedSpan
{ spanUserData = ()
, spanIndex = 0
, spanOffsetInParagraph = 0
, spanText = text
, spanTextOptions = (defaultTextOptions dir)
{ textFont = font
, textLineHeight = Normal
, textLanguage = lang
}
, spanBoxes = [defaultBox dir]
, spanLineBreaks = []
, spanCharacterBreaks = []
}
where
text = pack str
emptySpan :: Font -> ResolvedSpan ()
emptySpan = sampleSpan DirLTR "en"
""
czechHello :: Font -> ResolvedSpan ()
czechHello = sampleSpan DirLTR "cs"
"Ahoj, světe!"
arabicHello :: Font -> ResolvedSpan ()
arabicHello = sampleSpan DirRTL "ar"
"سلام"
serbianMixedScript :: Font -> ResolvedSpan ()
serbianMixedScript = sampleSpan DirLTR "sr"
"Vikipedija (Википедија)"
-- | Source:
-- <https://www.w3.org/International/articles/inline-bidi-markup/uba-basics>
englishAroundArabic :: Font -> ResolvedSpan ()
englishAroundArabic = sampleSpan DirLTR "en"
"The title is مفتاح معايير الويب in Arabic."