@@ 100,15 100,11 @@ layoutLines maxWidth runs
| null rest
-- Everything fits. We are done.
= fitting : []
- | null fitting
- -- Nothing fits. We must resolve this by overflowing.
- = overflowing : []
| otherwise
-- Something fits, the rest goes on the next line.
= fitting : layoutLines maxWidth rest
where
(fitting, rest) = layoutAndWrapRunsH maxWidth runs
- overflowing = layoutRunsH runs
-- TODO: Allow a run across multiple spans (e.g. if they only differ by colour).
@@ 123,7 119,10 @@ positionLineH :: Int32 -> [WithSpan PF.ProtoFragment] ->
(Int32, [WithSpan Fragment])
positionLineH originY pfs = (nextY, frags)
where
- nextY = maximum $ map y_min rects
+ -- A line with no glyphs will be considered to have zero height.
+ -- This can happen when line breaking produces a line that contains
+ -- onls spaces.
+ nextY = if null rects then originY else maximum $ map y_min rects
rects = map (\(WithSpan _ r) -> fragmentRect r) frags
frags = snd $ mapAccumL (positionFragmentH originY) originX pfs
originX = paragraphOriginX