~jaro/balkon

882969e0d9acabfc05f5ccad69c63d64983b9814 — Jaro 11 months ago 28d5a50
Link ResolvedSpan to boxes.
M src/Data/Text/ParagraphLayout/Internal/ResolvedSpan.hs => src/Data/Text/ParagraphLayout/Internal/ResolvedSpan.hs +2 -0
@@ 4,6 4,7 @@ where
import Data.Text (Text)
import qualified Data.Text.ICU as BreakStatus (Line)

import Data.Text.ParagraphLayout.Internal.ResolvedBox
import Data.Text.ParagraphLayout.Internal.TextContainer
import Data.Text.ParagraphLayout.Internal.TextOptions



@@ 15,6 16,7 @@ data ResolvedSpan d = ResolvedSpan
    , spanOffsetInParagraph :: Int
    , spanText :: Text
    , spanTextOptions :: TextOptions
    , spanBoxes :: [ResolvedBox d]
    , spanLineBreaks :: [(Int, BreakStatus.Line)]
    -- TODO: Can be optimised by starting with the shortest line break.
    , spanCharacterBreaks :: [(Int, ())]

M src/Data/Text/ParagraphLayout/Internal/Rich.hs => src/Data/Text/ParagraphLayout/Internal/Rich.hs +2 -1
@@ 55,7 55,7 @@ resolveSpans p@(Paragraph _ pStart root _) = do
        <*> ZipList leaves
        <*> ZipList sStarts
        <*> ZipList sTexts
    let (TextLeaf userData _ textOpts _) = leaf
    let (TextLeaf userData _ textOpts boxes) = leaf
    let lang = textLanguage textOpts
    let lBreaks = paragraphBreaks breakLine pText lang
    let cBreaks = paragraphBreaks breakCharacter pText lang


@@ 66,6 66,7 @@ resolveSpans p@(Paragraph _ pStart root _) = do
        -- TODO: Consider adding checks for array bounds.
        , RS.spanText = sText
        , RS.spanTextOptions = textOpts
        , RS.spanBoxes = boxes
        , RS.spanLineBreaks = subOffsetsDesc (sStart - pStart) lBreaks
        , RS.spanCharacterBreaks = subOffsetsDesc (sStart - pStart) cBreaks
        }

M test/Data/Text/ParagraphLayout/SpanData.hs => test/Data/Text/ParagraphLayout/SpanData.hs +8 -0
@@ 8,10 8,15 @@ where
import Data.Text (pack)
import Data.Text.Glyphize (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 :: ResolvedBox ()
defaultBox = ResolvedBox () 0 defaultBoxOptions

emptySpan :: Font -> ResolvedSpan ()
emptySpan font = ResolvedSpan
    { spanUserData = ()


@@ 23,6 28,7 @@ emptySpan font = ResolvedSpan
        , textLineHeight = Normal
        , textLanguage = "en"
        }
    , spanBoxes = [defaultBox]
    , spanLineBreaks = []
    , spanCharacterBreaks = []
    }


@@ 38,6 44,7 @@ czechHello font = ResolvedSpan
        , textLineHeight = Normal
        , textLanguage = "cs"
        }
    , spanBoxes = [defaultBox]
    , spanLineBreaks = []
    , spanCharacterBreaks = []
    }


@@ 53,6 60,7 @@ serbianMixedScript font = ResolvedSpan
        , textLineHeight = Normal
        , textLanguage = "sr"
        }
    , spanBoxes = [defaultBox]
    , spanLineBreaks = []
    , spanCharacterBreaks = []
    }