From 974b68d6651d8090453d335cba70f5c92c2d118e Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Wed, 15 Mar 2023 18:34:59 +1300 Subject: [PATCH] Fill in missing logic to lookup needed atlases. --- src/Main.hs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 8196acc..c3f5e28 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -110,12 +110,15 @@ lowerVars "-rhapsode" = CSSCond.B True lowerVars _ = CSSCond.B False lowerToks _ = CSSCond.B False -renderLayout drawText (LayoutSpan ((x, y), _) font self) = do - drawText' <- drawText $ fragmentGlyphs self - -- FIXME Allow CSS to set the colour. - liftIO $ arDraw drawText' [TextTransformMultiply $ V4 0 0 0 1] - (V2 (fromEnum x) (fromEnum y)) -renderLayout drawText node = layoutGetChilds node `forM` renderLayout drawText +renderLayout atlases drawText (LayoutSpan ((x, y), _) font self) + | Just atlas <- M.lookup (pattern font, fontSize font) atlases = do + drawText' <- drawText $ fragmentGlyphs self + -- FIXME Allow CSS to set the colour. + liftIO $ arDraw drawText' [TextTransformMultiply $ V4 0 0 0 1] + (V2 (fromEnum x) (fromEnum y)) +renderLayout atlases drawText node = do + layoutGetChilds node `forM` renderLayout atlases drawText + return () main :: IO () main = do @@ -189,7 +192,7 @@ main = do let outerbox = zeroBox { B.min = size, B.size = size, B.max = size } let layout = boxLayout outerbox (finalizeCSS' sysfont style) False - renderLayout drawText layout + renderLayout atlases drawText layout liftIO $ glSwapWindow w unless (QuitEvent `elem` events) loop -- 2.30.2