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 = []
}