From 3273335a8d92e3aa5b1765a995f31fd2862381d3 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Fri, 27 Jan 2023 15:18:18 +1300 Subject: [PATCH] Get multiline text rendering working. It turns out that the font-features list was cutting short the text-lines list. So now the font-features list is infinite so the text-lines list cuts it short! --- src/Typograffiti/Atlas.hs | 1 - src/Typograffiti/Text.hs | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Typograffiti/Atlas.hs b/src/Typograffiti/Atlas.hs index af5d5f1..2c07d20 100644 --- a/src/Typograffiti/Atlas.hs +++ b/src/Typograffiti/Atlas.hs @@ -235,5 +235,4 @@ stringTris' :: (MonadIO m, MonadError TypograffitiError m) => Atlas -> [(GlyphInfo, GlyphPos)] -> m (Vector (V2 Float, V2 Float)) stringTris' atlas glyphs = do (_, _, ret) <- stringTris atlas glyphs - liftIO $ print ret return $ UV.concat $ reverse ret diff --git a/src/Typograffiti/Text.hs b/src/Typograffiti/Text.hs index 662cbc2..f215a13 100644 --- a/src/Typograffiti/Text.hs +++ b/src/Typograffiti/Text.hs @@ -154,8 +154,7 @@ makeDrawText lib filepath index fontsize SampleText {..} = do liftIO $ ft_Done_Face font drawGlyphs <- makeDrawGlyphs - -- FIXME get drawLinesWrapper working again! - return $ \RichText {..} -> + return $ drawLinesWrapper tabwidth $ \RichText {..} -> drawGlyphs atlas $ shape font' defaultBuffer { HB.text = text } features where x2 = (*2) @@ -171,7 +170,7 @@ drawLinesWrapper :: (MonadIO m, MonadFail m) => Int -> (RichText -> m (AllocatedRendering [TextTransform])) -> RichText -> m (AllocatedRendering [TextTransform]) drawLinesWrapper indent cb RichText {..} = do - let features' = splitFeatures 0 features $ Txt.lines text + let features' = splitFeatures 0 features (Txt.lines text) ++ repeat [] let cb' (a, b) = cb $ RichText a b renderers <- mapM cb' $ flip zip features' $ map processLine $ Txt.lines text let drawLine ts wsz y renderer = do -- 2.30.2