~jaro/balkon

85383d46341222037bb8fa91204a8349b158011e — Jaro 1 year, 4 months ago 5b76807
Test struts in textless box.
A .golden/richParagraphLayout/offsetTextlessBoxDown.golden => .golden/richParagraphLayout/offsetTextlessBoxDown.golden +38 -0
@@ 0,0 1,38 @@
ParagraphLayout
    { paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 2624, y_size = -1621}
    , paragraphLines =
        [ Line {lineNumber = 1, lineRect = Rect {x_origin = 0, y_origin = 0, x_size = 2624, y_size = -1621}}
        ]
    , paragraphFragments =
        [ Fragment
            { fragmentUserData = "outer"
            , fragmentLine = 1
            , fragmentAncestorBoxes =
                []
            , fragmentContentRect = Rect {x_origin = 0, y_origin = 0, x_size = 1797, y_size = -1121}
            , fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 1797, y_size = -1121}
            , fragmentPen = (0, -932)
            , fragmentGlyphs =
                [ (GlyphInfo {codepoint = 82, cluster = 6, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 590, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 88, cluster = 7, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 87, cluster = 8, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 402, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 3, cluster = 9, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0})
                ]
            }
        , Fragment
            { fragmentUserData = "inner"
            , fragmentLine = 1
            , fragmentAncestorBoxes =
                [ AncestorBox {boxUserData = "text box", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0}
                , AncestorBox {boxUserData = "textless box", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0}
                ]
            , fragmentContentRect = Rect {x_origin = 1797, y_origin = -500, x_size = 827, y_size = -1121}
            , fragmentRect = Rect {x_origin = 1797, y_origin = -500, x_size = 827, y_size = -1121}
            , fragmentPen = (0, -932)
            , fragmentGlyphs =
                [ (GlyphInfo {codepoint = 76, cluster = 10, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 81, cluster = 11, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0})
                ]
            }
        ]
    }

A .golden/richParagraphLayout/offsetTextlessBoxUp.golden => .golden/richParagraphLayout/offsetTextlessBoxUp.golden +38 -0
@@ 0,0 1,38 @@
ParagraphLayout
    { paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 2624, y_size = -1621}
    , paragraphLines =
        [ Line {lineNumber = 1, lineRect = Rect {x_origin = 0, y_origin = 0, x_size = 2624, y_size = -1621}}
        ]
    , paragraphFragments =
        [ Fragment
            { fragmentUserData = "outer"
            , fragmentLine = 1
            , fragmentAncestorBoxes =
                []
            , fragmentContentRect = Rect {x_origin = 0, y_origin = -500, x_size = 1797, y_size = -1121}
            , fragmentRect = Rect {x_origin = 0, y_origin = -500, x_size = 1797, y_size = -1121}
            , fragmentPen = (0, -932)
            , fragmentGlyphs =
                [ (GlyphInfo {codepoint = 82, cluster = 6, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 590, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 88, cluster = 7, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 87, cluster = 8, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 402, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 3, cluster = 9, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0})
                ]
            }
        , Fragment
            { fragmentUserData = "inner"
            , fragmentLine = 1
            , fragmentAncestorBoxes =
                [ AncestorBox {boxUserData = "text box", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0}
                , AncestorBox {boxUserData = "textless box", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0}
                ]
            , fragmentContentRect = Rect {x_origin = 1797, y_origin = -500, x_size = 827, y_size = -1121}
            , fragmentRect = Rect {x_origin = 1797, y_origin = -500, x_size = 827, y_size = -1121}
            , fragmentPen = (0, -932)
            , fragmentGlyphs =
                [ (GlyphInfo {codepoint = 76, cluster = 10, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0})
                , (GlyphInfo {codepoint = 81, cluster = 11, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0})
                ]
            }
        ]
    }

M test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs => test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs +20 -0
@@ 18,6 18,7 @@ module Data.Text.ParagraphLayout.Rich.ParagraphData
    , newline2TextParagraph
    , offsetMiddleInnerTextParagraph
    , offsetMiddleOuterTextParagraph
    , offsetTextlessBoxParagraph
    , softBreakParagraph
    , spaceBoxParagraph
    )


@@ 431,6 432,25 @@ offsetMiddleOuterTextParagraph offset font = constructParagraph
        b = b_ { boxVerticalAlignment = AlignBaseline offset }
        t = tLTR { textFont = font, textLanguage = "en" }

offsetTextlessBoxParagraph :: Int32 -> Font -> ParagraphOptions ->
    Paragraph String
offsetTextlessBoxParagraph offset font = constructParagraph
    (pack "prefix")
    (rootBox t
        [ text "outer" "out "
        , box "textless box" b1 t
            [ box "text box" b2 t
                [ text "inner" "in"
                ]
            ]
        ]
    )
    (pack "suffix")
    where
        b1 = b_ { boxVerticalAlignment = AlignBaseline offset }
        b2 = b_ { boxVerticalAlignment = AlignLineBottom }
        t = tLTR { textFont = font, textLanguage = "en" }

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 +10 -2
@@ 174,8 174,6 @@ spec = do
                    result `shouldBeGolden` "mixedLineHeightBaseline3"

            describe "offset middle baseline" $ do
                -- TODO: also test struts for inline boxes with children
                -- FIXME: prevent vertical trimming of paragraphs
                let opts = defaultParagraphOptions
                        { paragraphAlignment = AlignStart
                        , paragraphMaxWidth = largeWidth


@@ 214,6 212,16 @@ spec = do
                    let result = layoutRich input
                    result `shouldBeGolden` "offsetMiddleDownOuterTextWrap"

                it "textless inline box strut extends line upwards" $ do
                    let input = offsetTextlessBoxParagraph 500 font opts
                    let result = layoutRich input
                    result `shouldBeGolden` "offsetTextlessBoxUp"

                it "textless inline box strut extends line downwards" $ do
                    let input = offsetTextlessBoxParagraph (-500) font opts
                    let result = layoutRich input
                    result `shouldBeGolden` "offsetTextlessBoxDown"

            it "handles mixed sizes" $ do
                let opts = defaultParagraphOptions
                        { paragraphAlignment = AlignStart