From 397a9e427f251005c29846c94299ef5d6467d352 Mon Sep 17 00:00:00 2001 From: Jaro Date: Thu, 8 Jun 2023 04:23:19 +0200 Subject: [PATCH] Fix handling of mixed line height. Displace lines by the height of the tallest fragment in the previous line, not the shortest one. --- CHANGELOG.md | 3 +++ src/Data/Text/ParagraphLayout/Internal/Layout.hs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86da013..d3a2e0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 1.2.0.0 -- TBD +* Fixed a bug where only the height of the shortest fragment on a line + would be considered when positioning the following line. + * Removed `paragraphLineHeight` from the rich text interface after it was included by mistake. Rich text needs to use `textLineHeight` instead. diff --git a/src/Data/Text/ParagraphLayout/Internal/Layout.hs b/src/Data/Text/ParagraphLayout/Internal/Layout.hs index eea0480..c260b0b 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Layout.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Layout.hs @@ -103,7 +103,7 @@ positionLineH :: Int32 -> (Int, PL.ProtoLine NonEmpty d) -> (Int32, NonEmpty (FragmentWithSpan d)) positionLineH originY (num, pl) = (nextY, frags) where - nextY = maximum $ fmap y_min rects + nextY = minimum $ fmap y_min rects rects = fmap (\ (WithSpan _ r) -> fragmentRect r) frags (_, frags) = mapAccumL (positionFragmentH num originY) originX wpfs wpfs = PL.applyBoxes pl -- 2.30.2