~alcinnz/CatTrap

e9d8aec6fbeb6fd490d49c75a90c80d3f34db787 — Adrian Cochrane 1 year, 8 months ago 15bde40
Hardcode fallback fontfile, associate vals per span-line not per span.
2 files changed, 5 insertions(+), 2 deletions(-)

M Graphics/Layout/CSS/Internal.hs
M Graphics/Layout/Inline.hs
M Graphics/Layout/CSS/Internal.hs => Graphics/Layout/CSS/Internal.hs +3 -0
@@ 89,6 89,9 @@ hbScale f = fontSize f*hbUnit
hbUnit = 64 :: Double

pattern2hbfont :: Pattern -> Int -> [Variation] -> Font
pattern2hbfont pat scale variations | Nothing <- lookup "file" pat =
    let pat' = setValue "file" "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" pat
    in pattern2hbfont pat' scale variations
pattern2hbfont pat scale variations = createFontWithOptions options face
  where
    bytes = unsafePerformIO $ B.readFile $ getValue0 "file" pat

M Graphics/Layout/Inline.hs => Graphics/Layout/Inline.hs +2 -2
@@ 28,8 28,8 @@ inlineSize :: (CastDouble x, CastDouble y) => Font' -> Paragraph -> Size x y
inlineSize font self = Size (c font $ width r) (c font $ height r)
  where r = paragraphRect $ layoutPlain self
inlineChildren :: [x] -> Paragraph -> [(x, Fragment)]
inlineChildren vals self = concat $ map inner $ zip vals $ spanLayouts $ layoutPlain self
  where inner (x, SpanLayout y) = map (x,) y
inlineChildren vals self = zip vals $ concat $ map inner $ spanLayouts $ layoutPlain self
  where inner (SpanLayout y) = y

layoutPlain' :: Paragraph -> Int32 -> Rect Int32
layoutPlain' (Paragraph a b c d) width =