From 48bb30e72fe8266d9404961b40e227ed308f4b7d Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Mon, 4 Mar 2024 15:18:55 +1300 Subject: [PATCH] Reserve enough horizontal space for inline boxes. --- Graphics/Layout/Inline.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Graphics/Layout/Inline.hs b/Graphics/Layout/Inline.hs index 0c11afa..5cfb522 100644 --- a/Graphics/Layout/Inline.hs +++ b/Graphics/Layout/Inline.hs @@ -75,16 +75,17 @@ lowerSpacing :: (CastDouble m, CastDouble n) => (x -> PaddedBox m n) -> lowerSpacing cb (Paragraph a b (RootBox c) d) = Paragraph a b (RootBox $ inner c) d where inner (Box childs opts) = flip Box opts $ map inner' childs - inner' (InlineBox e@(_, Left box, _) child opts) = inlineBox e box child opts - inner' (InlineBox e@(_, Right k, _) (Box childs opts') opts) = - let box = cb k in inlineBox e box (Box childs opts' { + inner' (InlineBox e@(_, Left box, _) child opts) = + inlineBox e (leftSpace box') (rightSpace box') child opts + where box' = mapX' unscale $ mapY' unscale box + inner' (InlineBox e@(_, Right k, _) (Box childs opts') opts) = let box = cb k + in inlineBox e (Box.width $ mapX' unscale box) 0 (Box childs opts' { textAscender = Just $ Box.height $ mapY' unscale box }) opts inner' self@(TextSequence _ _) = self - inlineBox dat f child opts = InlineBox dat (inner child) $ - flip activateBoxSpacing opts $ - BoxSpacingLeftRight (leftSpace box) (rightSpace box) - where box = mapX' unscale $ mapY' unscale f + inlineBox dat left right child opts = InlineBox dat (inner child) $ + flip activateBoxSpacing opts $ BoxSpacingLeftRight left right + -- | A tree extracted from Balkón's inline layout. -- 2.30.2