~alcinnz/haphaestus

974b68d6651d8090453d335cba70f5c92c2d118e — Adrian Cochrane 1 year, 1 month ago 29bbf6b
Fill in missing logic to lookup needed atlases.
1 files changed, 10 insertions(+), 7 deletions(-)

M src/Main.hs
M src/Main.hs => src/Main.hs +10 -7
@@ 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