From ca5a620b72631891d191916a65d5208197ebf8a4 Mon Sep 17 00:00:00 2001 From: Jaro Date: Thu, 8 Jun 2023 11:13:29 +0200 Subject: [PATCH] Test mixed line height. --- .../mixedLineHeight.golden | 237 ++++++++++++++++++ .../ParagraphLayout/Rich/ParagraphData.hs | 41 +++ test/Data/Text/ParagraphLayout/RichSpec.hs | 7 + 3 files changed, 285 insertions(+) create mode 100644 .golden/richParagraphLayout/mixedLineHeight.golden diff --git a/.golden/richParagraphLayout/mixedLineHeight.golden b/.golden/richParagraphLayout/mixedLineHeight.golden new file mode 100644 index 0000000..b4ae748 --- /dev/null +++ b/.golden/richParagraphLayout/mixedLineHeight.golden @@ -0,0 +1,237 @@ +ParagraphLayout + { paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 16708, y_size = -8900} + , paragraphFragments = + [ Fragment + { fragmentUserData = "mediumText" + , fragmentLine = 1 + , fragmentAncestorBoxes = + [] + , fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 3928, y_size = -1300} + , fragmentPen = (0, -1022) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 80, cluster = 6, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 7, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 71, cluster = 8, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 589, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 76, cluster = 9, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 88, cluster = 10, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 11, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 3, cluster = 12, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "smallText" + , fragmentLine = 1 + , fragmentAncestorBoxes = + [ AncestorBox {boxUserData = "smallBox", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0} + ] + , fragmentRect = Rect {x_origin = 3928, y_origin = 0, x_size = 2606, y_size = -800} + , fragmentPen = (0, -772) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 86, cluster = 13, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 446, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 14, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 68, cluster = 15, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 79, cluster = 16, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 79, cluster = 17, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 3, cluster = 18, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "mediumText" + , fragmentLine = 1 + , fragmentAncestorBoxes = + [] + , fragmentRect = Rect {x_origin = 6534, y_origin = 0, x_size = 3928, y_size = -1300} + , fragmentPen = (0, -1022) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 80, cluster = 19, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 20, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 71, cluster = 21, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 589, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 76, cluster = 22, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 88, cluster = 23, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 24, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 3, cluster = 25, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "largeText" + , fragmentLine = 1 + , fragmentAncestorBoxes = + [ AncestorBox {boxUserData = "largeBox", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0} + ] + , fragmentRect = Rect {x_origin = 10462, y_origin = 0, x_size = 2549, y_size = -1700} + , fragmentPen = (0, -1222) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 79, cluster = 26, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 68, cluster = 27, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 85, cluster = 28, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 386, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 74, cluster = 29, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 578, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 30, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 3, cluster = 31, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "mediumText" + , fragmentLine = 1 + , fragmentAncestorBoxes = + [] + , fragmentRect = Rect {x_origin = 13011, y_origin = 0, x_size = 3697, y_size = -1300} + , fragmentPen = (0, -1022) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 80, cluster = 32, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 33, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 71, cluster = 34, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 589, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 76, cluster = 35, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 88, cluster = 36, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 37, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "smallText" + , fragmentLine = 2 + , fragmentAncestorBoxes = + [ AncestorBox {boxUserData = "smallBox", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0} + ] + , fragmentRect = Rect {x_origin = 0, y_origin = -1700, x_size = 2606, y_size = -800} + , fragmentPen = (0, -772) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 86, cluster = 40, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 446, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 41, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 68, cluster = 42, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 79, cluster = 43, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 79, cluster = 44, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 3, cluster = 45, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "mediumText" + , fragmentLine = 2 + , fragmentAncestorBoxes = + [] + , fragmentRect = Rect {x_origin = 2606, y_origin = -1700, x_size = 3928, y_size = -1300} + , fragmentPen = (0, -1022) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 80, cluster = 46, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 47, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 71, cluster = 48, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 589, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 76, cluster = 49, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 88, cluster = 50, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 51, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 3, cluster = 52, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "largeText" + , fragmentLine = 2 + , fragmentAncestorBoxes = + [ AncestorBox {boxUserData = "largeBox", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0} + ] + , fragmentRect = Rect {x_origin = 6534, y_origin = -1700, x_size = 2318, y_size = -1700} + , fragmentPen = (0, -1222) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 79, cluster = 53, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 68, cluster = 54, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 85, cluster = 55, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 386, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 74, cluster = 56, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 578, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 57, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "mediumText" + , fragmentLine = 3 + , fragmentAncestorBoxes = + [] + , fragmentRect = Rect {x_origin = 0, y_origin = -3400, x_size = 3928, y_size = -1300} + , fragmentPen = (0, -1022) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 80, cluster = 60, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 61, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 71, cluster = 62, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 589, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 76, cluster = 63, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 88, cluster = 64, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 65, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 3, cluster = 66, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "smallText" + , fragmentLine = 3 + , fragmentAncestorBoxes = + [ AncestorBox {boxUserData = "smallBox", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0} + ] + , fragmentRect = Rect {x_origin = 3928, y_origin = -3400, x_size = 2375, y_size = -800} + , fragmentPen = (0, -772) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 86, cluster = 67, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 446, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 68, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 68, cluster = 69, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 79, cluster = 70, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 79, cluster = 71, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "largeText" + , fragmentLine = 4 + , fragmentAncestorBoxes = + [ AncestorBox {boxUserData = "largeBox", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0} + ] + , fragmentRect = Rect {x_origin = 0, y_origin = -4700, x_size = 2549, y_size = -1700} + , fragmentPen = (0, -1222) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 79, cluster = 74, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 68, cluster = 75, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 85, cluster = 76, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 386, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 74, cluster = 77, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 578, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 78, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 3, cluster = 79, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "mediumText" + , fragmentLine = 4 + , fragmentAncestorBoxes = + [] + , fragmentRect = Rect {x_origin = 2549, y_origin = -4700, x_size = 3697, y_size = -1300} + , fragmentPen = (0, -1022) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 80, cluster = 80, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 81, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 71, cluster = 82, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 589, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 76, cluster = 83, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 88, cluster = 84, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 574, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 85, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "smallText" + , fragmentLine = 5 + , fragmentAncestorBoxes = + [ AncestorBox {boxUserData = "smallBox", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0} + ] + , fragmentRect = Rect {x_origin = 0, y_origin = -6400, x_size = 2375, y_size = -800} + , fragmentPen = (0, -772) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 86, cluster = 88, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 446, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 80, cluster = 89, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 861, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 68, cluster = 90, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 79, cluster = 91, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 79, cluster = 92, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + , Fragment + { fragmentUserData = "largeText" + , fragmentLine = 6 + , fragmentAncestorBoxes = + [ AncestorBox {boxUserData = "largeBox", boxLeftEdge = SpacedEdge 0, boxRightEdge = SpacedEdge 0, boxStartEdge = SpacedEdge 0, boxEndEdge = SpacedEdge 0} + ] + , fragmentRect = Rect {x_origin = 0, y_origin = -7200, x_size = 2318, y_size = -1700} + , fragmentPen = (0, -1222) + , fragmentGlyphs = + [ (GlyphInfo {codepoint = 79, cluster = 95, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 273, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 68, cluster = 96, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 85, cluster = 97, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 386, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 74, cluster = 98, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 578, y_advance = 0, x_offset = 0, y_offset = 0}) + , (GlyphInfo {codepoint = 72, cluster = 99, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False}, GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}) + ] + } + ] + } diff --git a/test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs b/test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs index 5921093..dfa020f 100644 --- a/test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs +++ b/test/Data/Text/ParagraphLayout/Rich/ParagraphData.hs @@ -5,6 +5,7 @@ module Data.Text.ParagraphLayout.Rich.ParagraphData , loremIpsumParagraph , mixedDirectionComplexParagraph , mixedDirectionSimpleParagraph + , mixedLineHeightParagraph , mixedScriptParagraph , mixedSizesParagraph , nestedBoxesParagraph @@ -22,6 +23,7 @@ import Data.Text.ParagraphLayout.Internal.ParagraphOptions import Data.Text.ParagraphLayout.Internal.Rich.Paragraph import Data.Text.ParagraphLayout.Internal.TextOptions import Data.Text.ParagraphLayout.Internal.Tree +import Data.Text.ParagraphLayout.Rich import Data.Text.ParagraphLayout.TextData tLTR :: TextOptions @@ -147,6 +149,45 @@ mixedDirectionSimpleParagraph dir font = constructParagraph t = (defaultTextOptions dir) { textFont = font, textLanguage = lang } (_, lang, textContents, _) = mixedDirectionSimple dir +mixedLineHeightParagraph :: (Int32, Int32, Int32) -> Font -> ParagraphOptions -> + Paragraph String +mixedLineHeightParagraph (lhSmall, lhMedium, lhLarge) font = constructParagraph + (pack "prefix") + (rootBox tMedium + -- Line 1: all 3 heights, with medium height prevailing. + [ text "mediumText" "medium " + , box "smallBox" b_ tSmall [text "smallText" "small "] + , text "mediumText" "medium " + , box "largeBox" b_ tLarge [text "largeText" "large "] + , text "mediumText" "medium " + , text "lineBreak" "\n" + -- Line 2: all 3 line heights, with medium only in the middle. + , box "smallBox" b_ tSmall [text "smallText" "small "] + , text "mediumText" "medium " + , box "largeBox" b_ tLarge [text "largeText" "large "] + , text "lineBreak" "\n" + -- Line 3: asymmetric, medium changing into small. + , text "mediumText" "medium " + , box "smallBox" b_ tSmall [text "smallText" "small "] + , text "lineBreak" "\n" + -- Line 4: asymmetric, large changing into medium. + , box "largeBox" b_ tLarge [text "largeText" "large "] + , text "mediumText" "medium " + , text "lineBreak" "\n" + -- Line 5: small only. + , box "smallBox" b_ tSmall [text "smallText" "small "] + , text "lineBreak" "\n" + -- Line 6: large only. + , box "largeBox" b_ tLarge [text "largeText" "large "] + ] + ) + (pack "suffix") + where + tLarge = t { textLineHeight = Absolute lhLarge } + tMedium = t { textLineHeight = Absolute lhMedium } + tSmall = t { textLineHeight = Absolute lhSmall } + t = tLTR { textFont = font, textLanguage = "en" } + mixedScriptParagraph :: Font -> ParagraphOptions -> Paragraph String mixedScriptParagraph font = constructParagraph (pack "prefix") diff --git a/test/Data/Text/ParagraphLayout/RichSpec.hs b/test/Data/Text/ParagraphLayout/RichSpec.hs index b2c0662..b218f32 100644 --- a/test/Data/Text/ParagraphLayout/RichSpec.hs +++ b/test/Data/Text/ParagraphLayout/RichSpec.hs @@ -41,6 +41,13 @@ spec = do let result = layoutRich input result `shouldBeGolden` "loremIpsum20em" + it "handles mixed line height" $ do + let opts = defaultParagraphOptions + let lineHeights = (800, 1300, 1700) + let input = mixedLineHeightParagraph lineHeights font opts + let result = layoutRich input + result `shouldBeGolden` "mixedLineHeight" + it "handles mixed sizes" $ do let opts = defaultParagraphOptions let input = mixedSizesParagraph (font, fontSmall) opts -- 2.30.2