~alcinnz/CatTrap

83e2a9cc192721b83d0bdafc7ded6c4c6f2b0aeb — Adrian Cochrane 1 year, 29 days ago 48ed1b3
Expose text data from main module.
1 files changed, 12 insertions(+), 7 deletions(-)

M Graphics/Layout.hs
M Graphics/Layout.hs => Graphics/Layout.hs +12 -7
@@ 8,7 8,8 @@ module Graphics.Layout(LayoutItem(..), UserData,
        layoutGetBox, layoutGetChilds, layoutGetInner,
        boxMinWidth, boxMaxWidth, boxNatWidth, boxWidth,
        boxNatHeight, boxMinHeight, boxMaxHeight, boxHeight,
        boxSplit, boxPaginate, boxPosition, boxLayout{-, glyphsPerFont-}) where
        boxSplit, boxPaginate, boxPosition, boxLayout,
        glyphs, codepoints, fragmentFont, {-, glyphsPerFont-}) where

import Data.Text.ParagraphLayout.Rich (Paragraph(..), ParagraphOptions(..),
                                ParagraphLayout(..), layoutRich)


@@ 21,7 22,7 @@ import Graphics.Layout.Box as B
import Graphics.Layout.Grid as G
import Graphics.Layout.Flow as F
import Graphics.Layout.Inline as I
import Graphics.Layout.CSS.Font (Font')
import Graphics.Layout.CSS.Font (Font'(..))

import Data.Maybe (fromMaybe)



@@ 396,11 397,15 @@ boxLayout parent self paginate = self9
-- | Compute a mapping from a layout tree indicating which glyphs for which fonts
-- are required.
-- Useful for assembling glyph atlases.
{- glyphsPerFont :: LayoutItem x y z -> M.Map (Pattern, Double) IS.IntSet
glyphsPerFont (LayoutSpan _ font self) =
    (pattern font, fontSize font) `M.singleton` IS.fromList glyphs
  where glyphs = map fromEnum $ map Hb.codepoint $ map fst $ fragmentGlyphs self
glyphsPerFont node = M.unionsWith IS.union $ map glyphsPerFont $ layoutGetChilds node -}
glyphsPerFont :: (CastDouble x, CastDouble y, Eq x, Eq y, Eq z) =>
        LayoutItem x y z -> M.Map (Pattern, Double) IS.IntSet
glyphsPerFont (LayoutSpan self) | (_:_) <- glyphs =
        (pattern font, fontSize font) `M.singleton` IS.fromList glyphs
    | otherwise = M.empty
  where
    glyphs = map fromEnum $ codepoints self
    (font, _) = fragmentFont self
glyphsPerFont node = M.unionsWith IS.union $ map glyphsPerFont $ layoutGetChilds node

parMap' :: NFData b => (a -> b) -> [a] -> [b]
parMap' = parMap rdeepseq