~jaro/balkon

751a2ba1ffff4e19600404569bdbd26b7c1fe059 — Jaro 1 year, 9 months ago 5543d47
Use top edge for placing lines.
M .golden/czechHelloParagraph/golden => .golden/czechHelloParagraph/golden +2 -2
@@ 1,5 1,5 @@
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 5274, y_size = 1121}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 5274, y_size = 1121}, fragmentPen = (0,189), fragmentGlyphs =
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = -1121, x_size = 5274, y_size = 1121}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 5274, y_size = -1121}, fragmentPen = (0,-932), fragmentGlyphs =
        [(GlyphInfo {codepoint = 36, cluster = 0, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 663, y_advance = 0, x_offset = 0, y_offset = 0}),
        (GlyphInfo {codepoint = 75, cluster = 1, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 571, y_advance = 0, x_offset = 0, y_offset = 0}),
        (GlyphInfo {codepoint = 82, cluster = 2, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 590, y_advance = 0, x_offset = 0, y_offset = 0}),

M .golden/lineHeightLarger/golden => .golden/lineHeightLarger/golden +2 -2
@@ 1,5 1,5 @@
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = 1600}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = 1600}, fragmentPen = (0,428), fragmentGlyphs =
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = -1600, x_size = 522, y_size = 1600}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = -1600}, fragmentPen = (0,-1172), fragmentGlyphs =
        [(GlyphInfo {codepoint = 68, cluster = 0, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0})]
    }]
]}

M .golden/lineHeightNormal/golden => .golden/lineHeightNormal/golden +2 -2
@@ 1,5 1,5 @@
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = 1121}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = 1121}, fragmentPen = (0,189), fragmentGlyphs =
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = -1121, x_size = 522, y_size = 1121}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = -1121}, fragmentPen = (0,-932), fragmentGlyphs =
        [(GlyphInfo {codepoint = 68, cluster = 0, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0})]
    }]
]}

M .golden/lineHeightSmaller/golden => .golden/lineHeightSmaller/golden +2 -2
@@ 1,5 1,5 @@
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = 599}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = 599}, fragmentPen = (0,-72), fragmentGlyphs =
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = -599, x_size = 522, y_size = 599}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 522, y_size = -599}, fragmentPen = (0,-671), fragmentGlyphs =
        [(GlyphInfo {codepoint = 68, cluster = 0, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 522, y_advance = 0, x_offset = 0, y_offset = 0})]
    }]
]}

M .golden/mixedLanguageLTRParagraph/golden => .golden/mixedLanguageLTRParagraph/golden +3 -3
@@ 1,5 1,5 @@
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 6113, y_size = 1121}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 4837, y_size = 1121}, fragmentPen = (0,189), fragmentGlyphs =
ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = -1121, x_size = 6113, y_size = 1121}, spanLayouts = [
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 0, y_origin = 0, x_size = 4837, y_size = -1121}, fragmentPen = (0,-932), fragmentGlyphs =
        [(GlyphInfo {codepoint = 77, cluster = 4, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 253, y_advance = 0, x_offset = 0, y_offset = 0}),
        (GlyphInfo {codepoint = 86, cluster = 5, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 446, y_advance = 0, x_offset = 0, y_offset = 0}),
        (GlyphInfo {codepoint = 72, cluster = 6, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 559, y_advance = 0, x_offset = 0, y_offset = 0}),


@@ 12,7 12,7 @@ ParagraphLayout {paragraphRect = Rect {x_origin = 0, y_origin = 0, x_size = 6113
        (GlyphInfo {codepoint = 15, cluster = 13, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 246, y_advance = 0, x_offset = 0, y_offset = 0}),
        (GlyphInfo {codepoint = 3, cluster = 14, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 231, y_advance = 0, x_offset = 0, y_offset = 0})]
    }],
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 4837, y_origin = 0, x_size = 1276, y_size = 1121}, fragmentPen = (0,189), fragmentGlyphs =
    SpanLayout [Fragment {fragmentRect = Rect {x_origin = 4837, y_origin = 0, x_size = 1276, y_size = -1121}, fragmentPen = (0,-932), fragmentGlyphs =
        [(GlyphInfo {codepoint = 0, cluster = 15, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 500, y_advance = 0, x_offset = 0, y_offset = 0}),
        (GlyphInfo {codepoint = 0, cluster = 18, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 500, y_advance = 0, x_offset = 0, y_offset = 0}),
        (GlyphInfo {codepoint = 4, cluster = 21, unsafeToBreak = False, unsafeToConcat = False, safeToInsertTatweel = False},GlyphPos {x_advance = 276, y_advance = 0, x_offset = 0, y_offset = 0})]

M src/Data/Text/ParagraphLayout/Plain.hs => src/Data/Text/ParagraphLayout/Plain.hs +5 -4
@@ 150,13 150,14 @@ layoutSingleLine runs = indexedFrags
-- TODO: Allow a run across multiple spans (e.g. if they only differ by colour).

-- | Align the given horizontal fragment vertically on a line,
-- using `originY` as its bottom edge.
-- using `originY` as its top edge.
alignFragmentH :: Int32 -> WithSpan PF.ProtoFragment -> WithSpan Fragment
alignFragmentH originY (WithSpan rs pf) = WithSpan rs (Fragment rect (penX, penY) (PF.glyphs pf))
alignFragmentH originY (WithSpan rs pf) =
    WithSpan rs (Fragment rect (penX, penY) (PF.glyphs pf))
    where
        rect = Rect (PF.offset pf) originY (PF.advance pf) lineHeight
        rect = Rect (PF.offset pf) originY (PF.advance pf) (-lineHeight)
        penX = 0
        penY = descent + leading `div` 2
        penY = descent + leading `div` 2 - lineHeight
        lineHeight = case RS.spanLineHeight rs of
            Normal -> normalLineHeight
            Absolute h -> h