From 7e49e20750cc725749f4f9c89942a19b85049881 Mon Sep 17 00:00:00 2001 From: Jaro Date: Thu, 22 Jun 2023 09:47:05 +0200 Subject: [PATCH] Prevent empty shaped runs. This is in preparation for a breaking change that introduces some empty fragments into the output. Since the shaped runs output is not concerned with runs of zero glyphs, these will be proactively removed. --- .../Text/ParagraphLayout/Internal/Plain/ParagraphLayout.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Data/Text/ParagraphLayout/Internal/Plain/ParagraphLayout.hs b/src/Data/Text/ParagraphLayout/Internal/Plain/ParagraphLayout.hs index ddad8ac..bb7f02b 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Plain/ParagraphLayout.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Plain/ParagraphLayout.hs @@ -81,6 +81,8 @@ appendFragments pla plb = paragraphLayout sls' paragraphFragments :: ParagraphLayout d -> [Fragment d] paragraphFragments pl = concat $ map spanFragments $ spanLayouts pl --- | Return all shaped runs in the paragraph. +-- | Return all non-empty shaped runs in the paragraph. shapedRuns :: ParagraphLayout d -> [ShapedRun] -shapedRuns pl = map shapedRun $ paragraphFragments pl +shapedRuns pl = map shapedRun $ filter hasGlyphs $ paragraphFragments pl + where + hasGlyphs = not . null . fragmentGlyphs -- 2.30.2