~jaro/balkon

5e218e2739e4175ea58ef98686426d80919e2f64 — Jaro 11 months ago e1e4bf7
Test with only directionally neutral characters.
A .golden/richParagraphLayout/neutralDirectionLTR.golden => .golden/richParagraphLayout/neutralDirectionLTR.golden +18 -0
@@ 0,0 1,18 @@
ParagraphLayout
    { paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 2003, y_size = -1500}
    , paragraphFragments =
        [ Fragment
            { fragmentUserData = "text"
            , fragmentLine = 1
            , fragmentAncestorBoxes =
                []
            , fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 2003, y_size = -1500}
            , fragmentPen = (0, -1085)
            , fragmentGlyphs =
                [ (GlyphInfo {codepoint = 91, cluster = 3, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 803, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 1392, cluster = 6, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 600, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 148, cluster = 9, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 600, y_advance = 0, x_offset = 0, y_offset = 0})
                ]
            }
        ]
    }

A .golden/richParagraphLayout/neutralDirectionRTL.golden => .golden/richParagraphLayout/neutralDirectionRTL.golden +18 -0
@@ 0,0 1,18 @@
ParagraphLayout
    { paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 2003, y_size = -1500}
    , paragraphFragments =
        [ Fragment
            { fragmentUserData = "text"
            , fragmentLine = 1
            , fragmentAncestorBoxes =
                []
            , fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 2003, y_size = -1500}
            , fragmentPen = (0, -1085)
            , fragmentGlyphs =
                [ (GlyphInfo {codepoint = 147, cluster = 9, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 600, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 1392, cluster = 6, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 600, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 91, cluster = 3, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 803, y_advance = 0, x_offset = 0, y_offset = 0})
                ]
            }
        ]
    }

M test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs => test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs +12 -0
@@ 7,6 7,7 @@ module Data.Text.ParagraphLayout.Rich.ParagraphData
    , mixedScriptParagraph
    , mixedSizesParagraph
    , nestedBoxesParagraph
    , neutralDirectionParagraph
    , softBreakParagraph
    )
where


@@ 194,6 195,17 @@ nestedBoxesParagraph font = constructParagraph
    where
        t = tLTR { textFont = font, textLanguage = "en" }

-- | A paragraph that contains only characters in the BiDi class
-- /Other neutrals (ON)/. This includes characters that can be mirrored.
neutralDirectionParagraph :: Direction -> Font -> ParagraphOptions ->
    Paragraph String
neutralDirectionParagraph dir font = constructParagraph
    (pack "_»")
    (rootBox t [text "text" "…―>"])
    (pack "*†")
    where
        t = (defaultTextOptions dir) { textFont = font, textLanguage = "zxx" }

softBreakParagraph :: Int32 -> Font -> ParagraphOptions -> Paragraph String
softBreakParagraph spacing font = constructParagraph
    (pack "prefix")

M test/Data/Text/ParagraphLayout/RichSpec.hs => test/Data/Text/ParagraphLayout/RichSpec.hs +12 -0
@@ 122,6 122,18 @@ spec = do
                let result = layoutRich input
                result `shouldBeGolden` "hardBoxBreakRTL"

            it "handles neutral characters in RTL paragraph" $ do
                let opts = defaultParagraphOptions
                let input = neutralDirectionParagraph DirRTL font opts
                let result = layoutRich input
                result `shouldBeGolden` "neutralDirectionRTL"

            it "handles neutral characters in LTR paragraph" $ do
                let opts = defaultParagraphOptions
                let input = neutralDirectionParagraph DirLTR font opts
                let result = layoutRich input
                result `shouldBeGolden` "neutralDirectionLTR"

            it "handles simple mixed direction in RTL paragraph" $ do
                let opts = defaultParagraphOptions
                let input = mixedDirectionSimpleParagraph DirRTL font opts