module Data.Text.ParagraphLayout.RunSpec (spec) where
import Data.Text (pack)
import Data.Text.Glyphize (Direction(..))
import Test.Hspec
import Data.Text.ParagraphLayout.FontLoader
import Data.Text.ParagraphLayout.ResolvedSpan
import Data.Text.ParagraphLayout.Run
import Data.Text.ParagraphLayout.SpanData
spec :: Spec
spec = do
describe "spanToRuns" $ before loadUbuntuRegular $ do
it "handles span with no text" $ \font -> do
spanToRuns (emptySpan font) `shouldBe` []
it "handles Czech hello" $ \font -> do
let inputSpan = czechHello font
let runs = spanToRuns inputSpan
runs `shouldBe`
[ Run
{ runOffsetInSpan = 0
, runText = spanText inputSpan
, runDirection = Just DirLTR
, runScript = Just "Latn"
}
]
it "handles Serbian with mixed script" $ \font -> do
let inputSpan = serbianMixedScript font
let runs = spanToRuns inputSpan
runs `shouldBe`
[ Run
-- TODO: We might want both parentheses in the same run.
{ runOffsetInSpan = 0
, runText = pack "Vikipedija ("
, runDirection = Just DirLTR
, runScript = Just "Latn"
}
, Run
{ runOffsetInSpan = 12
, runText = pack "Википедија)"
, runDirection = Just DirLTR
, runScript = Just "Cyrl"
}
]