~jaro/balkon

573d4d8d02f6d30b7c1930f86f761120cc947350 — Jaro 1 year, 5 months ago a42dd23
Simplify code since run direction is always known.
M src/Data/Text/ParagraphLayout/Internal/Layout.hs => src/Data/Text/ParagraphLayout/Internal/Layout.hs +2 -2
@@ 137,7 137,7 @@ positionFragmentH line originY originX (WithBoxes lbs (WithSpan rs pf) rbs) =
        normalLineHeight = ascent + descent
        ascent = ascender extents
        descent = - descender extents
        extents = fontExtentsForDir (textFont opts) (PF.direction pf)
        extents = fontExtentsForDir (textFont opts) (Just $ PF.direction pf)
        opts = RS.spanTextOptions rs

ancestorBoxes


@@ 310,7 310,7 @@ shapeRun (WithSpan rs run) = shape font buffer features
        buffer = defaultBuffer
            { text = Lazy.fromStrict $ runText run
            , contentType = Just ContentTypeUnicode
            , direction = runDirection run
            , direction = Just $ runDirection run
            , script = runScript run
            , language = Just $ textLanguage opts
            -- Perhaps counter-intuitively, the `beginsText` and `endsText`

M src/Data/Text/ParagraphLayout/Internal/ProtoFragment.hs => src/Data/Text/ParagraphLayout/Internal/ProtoFragment.hs +2 -2
@@ 11,7 11,7 @@ import qualified Data.Text.ParagraphLayout.Internal.BiDiLevels as BiDi

-- | A box fragment which has not been positioned yet.
data ProtoFragment = ProtoFragment
    { direction :: Maybe Direction
    { direction :: Direction
    -- ^ Text direction, which is constant within a fragment.
    , level :: BiDi.Level
    -- ^ BiDi embedding level.


@@ 24,7 24,7 @@ data ProtoFragment = ProtoFragment

-- | Construct a `ProtoFragment`, automatically calculating the total advance
-- for a horizontal text direction.
protoFragmentH :: Maybe Direction -> BiDi.Level -> [(GlyphInfo, GlyphPos)] ->
protoFragmentH :: Direction -> BiDi.Level -> [(GlyphInfo, GlyphPos)] ->
    ProtoFragment
protoFragmentH dir lvl gs = ProtoFragment dir lvl adv gs
    where

M src/Data/Text/ParagraphLayout/Internal/Run.hs => src/Data/Text/ParagraphLayout/Internal/Run.hs +2 -2
@@ 23,7 23,7 @@ data Run = Run
    { runOffsetInSpan :: Int
    , runText :: Text
    , runLevel :: Level
    , runDirection :: Maybe Direction
    , runDirection :: Direction
    , runScript :: Maybe ScriptCode
    }
    deriving (Eq, Show)


@@ 85,7 85,7 @@ spanToRuns s = snd $ mapAccumL run 0 $ protoRuns zipper levels
                { runOffsetInSpan = acc
                , runText = t
                , runLevel = PR.level pr
                , runDirection = Just $ levelDirectionH $ PR.level pr
                , runDirection = levelDirectionH $ PR.level pr
                , runScript = Just $ PR.script pr
                }
            )

M test/Data/Text/ParagraphLayout/Internal/RunSpec.hs => test/Data/Text/ParagraphLayout/Internal/RunSpec.hs +24 -24
@@ 58,7 58,7 @@ spec = do
                    { runOffsetInSpan = 0
                    , runText = spanText inputSpan
                    , runLevel = 0
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                ]


@@ 70,7 70,7 @@ spec = do
                    { runOffsetInSpan = 0
                    , runText = spanText inputSpan
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Arab"
                    }
                ]


@@ 83,14 83,14 @@ spec = do
                    { runOffsetInSpan = 0
                    , runText = pack "Vikipedija ("
                    , runLevel = 0
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                , Run
                    { runOffsetInSpan = 12
                    , runText = pack "Википедија)"
                    , runLevel = 0
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Cyrl"
                    }
                ]


@@ 103,21 103,21 @@ spec = do
                    { runOffsetInSpan = 0
                    , runText = pack "bahrain"
                    , runLevel = 0
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                , Run
                    { runOffsetInSpan = 7
                    , runText = pack "مصر"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Arab"
                    }
                , Run
                    { runOffsetInSpan = 13
                    , runText = pack "kuwait"
                    , runLevel = 0
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                ]


@@ 130,21 130,21 @@ spec = do
                    { runOffsetInSpan = 0
                    , runText = pack "bahrain"
                    , runLevel = 2
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                , Run
                    { runOffsetInSpan = 7
                    , runText = pack "مصر"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Arab"
                    }
                , Run
                    { runOffsetInSpan = 13
                    , runText = pack "kuwait"
                    , runLevel = 2
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                ]


@@ 157,35 157,35 @@ spec = do
                    { runOffsetInSpan = 0
                    , runText = pack "في "
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Arab"
                    }
                , Run
                    { runOffsetInSpan = 5
                    , runText = pack "XHTML 1.0"
                    , runLevel = 2
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                , Run
                    { runOffsetInSpan = 14
                    , runText = pack " يتم تحقيق ذلك بإضافة العنصر المضمن "
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Arab"
                    }
                , Run
                    { runOffsetInSpan = 79
                    , runText = pack "bdo"
                    , runLevel = 2
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                , Run
                    { runOffsetInSpan = 82
                    , runText = pack "."
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Zyyy"
                    }
                ]


@@ 198,21 198,21 @@ spec = do
                    { runOffsetInSpan = 0
                    , runText = pack "The title is "
                    , runLevel = 0
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                , Run
                    { runOffsetInSpan = 13
                    , runText = pack "مفتاح معايير الويب"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Arab"
                    }
                , Run
                    { runOffsetInSpan = 47
                    , runText = pack " in Arabic."
                    , runLevel = 0
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                ]


@@ 227,7 227,7 @@ spec = do
                    { runOffsetInSpan = 0
                    , runText = pack "Viki"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Latn"
                    }
                -- direction change


@@ 235,7 235,7 @@ spec = do
                    { runOffsetInSpan = 4
                    , runText = pack "pedi"
                    , runLevel = 2
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Latn"
                    }
                -- direction change


@@ 243,7 243,7 @@ spec = do
                    { runOffsetInSpan = 8
                    , runText = pack "ja ("
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Latn"
                    }
                -- script change


@@ 251,7 251,7 @@ spec = do
                    { runOffsetInSpan = 12
                    , runText = pack "Вики"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Cyrl"
                    }
                -- direction change


@@ 259,7 259,7 @@ spec = do
                    { runOffsetInSpan = 20
                    , runText = pack "педи"
                    , runLevel = 2
                    , runDirection = Just DirLTR
                    , runDirection = DirLTR
                    , runScript = Just "Cyrl"
                    }
                -- direction change


@@ 267,7 267,7 @@ spec = do
                    { runOffsetInSpan = 28
                    , runText = pack "ја)"
                    , runLevel = 1
                    , runDirection = Just DirRTL
                    , runDirection = DirRTL
                    , runScript = Just "Cyrl"
                    }
                ]