From 75e3b64a230f131fcde0b12604a187aef4ee2853 Mon Sep 17 00:00:00 2001 From: Jaro Date: Sun, 7 May 2023 03:10:33 +0200 Subject: [PATCH] Store direction in ResolvedBox. --- src/Data/Text/ParagraphLayout/Internal/ResolvedBox.hs | 3 +++ src/Data/Text/ParagraphLayout/Internal/Tree.hs | 4 +++- test/Data/Text/ParagraphLayout/SpanData.hs | 10 +++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Data/Text/ParagraphLayout/Internal/ResolvedBox.hs b/src/Data/Text/ParagraphLayout/Internal/ResolvedBox.hs index e579f48..87f1eb3 100644 --- a/src/Data/Text/ParagraphLayout/Internal/ResolvedBox.hs +++ b/src/Data/Text/ParagraphLayout/Internal/ResolvedBox.hs @@ -1,6 +1,8 @@ module Data.Text.ParagraphLayout.Internal.ResolvedBox (ResolvedBox (..)) where +import Data.Text.Glyphize (Direction) + import Data.Text.ParagraphLayout.Internal.BoxOptions -- | Internal structure describing an inline box. @@ -9,6 +11,7 @@ data ResolvedBox d = ResolvedBox { boxUserData :: d , boxIndex :: Int , boxOptions :: BoxOptions + , boxDirection :: Direction } instance Eq (ResolvedBox d) where diff --git a/src/Data/Text/ParagraphLayout/Internal/Tree.hs b/src/Data/Text/ParagraphLayout/Internal/Tree.hs index 085295a..e235f84 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Tree.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Tree.hs @@ -91,4 +91,6 @@ flattenNode :: Int -> BoxPath d -> TextOptions -> InnerNode d -> flattenNode idx path textOpts (TextSequence d len) = (idx, [TextLeaf d len textOpts path]) flattenNode idx path _ (InlineBox d (Box ns textOpts) boxOpts) = - flattenNodes (idx + 1) (ResolvedBox d idx boxOpts : path) textOpts ns + flattenNodes (idx + 1) (ResolvedBox d idx boxOpts dir : path) textOpts ns + where + dir = textDirection textOpts diff --git a/test/Data/Text/ParagraphLayout/SpanData.hs b/test/Data/Text/ParagraphLayout/SpanData.hs index d254cad..daaed20 100644 --- a/test/Data/Text/ParagraphLayout/SpanData.hs +++ b/test/Data/Text/ParagraphLayout/SpanData.hs @@ -14,8 +14,8 @@ import Data.Text.ParagraphLayout.Internal.ResolvedBox import Data.Text.ParagraphLayout.Internal.ResolvedSpan import Data.Text.ParagraphLayout.Internal.TextOptions -defaultBox :: ResolvedBox () -defaultBox = ResolvedBox () 0 defaultBoxOptions +defaultBox :: Direction -> ResolvedBox () +defaultBox dir = ResolvedBox () 0 defaultBoxOptions dir emptySpan :: Font -> ResolvedSpan () emptySpan font = ResolvedSpan @@ -28,7 +28,7 @@ emptySpan font = ResolvedSpan , textLineHeight = Normal , textLanguage = "en" } - , spanBoxes = [defaultBox] + , spanBoxes = [defaultBox DirLTR] , spanLineBreaks = [] , spanCharacterBreaks = [] } @@ -44,7 +44,7 @@ czechHello font = ResolvedSpan , textLineHeight = Normal , textLanguage = "cs" } - , spanBoxes = [defaultBox] + , spanBoxes = [defaultBox DirLTR] , spanLineBreaks = [] , spanCharacterBreaks = [] } @@ -60,7 +60,7 @@ serbianMixedScript font = ResolvedSpan , textLineHeight = Normal , textLanguage = "sr" } - , spanBoxes = [defaultBox] + , spanBoxes = [defaultBox DirLTR] , spanLineBreaks = [] , spanCharacterBreaks = [] } -- 2.30.2