~alcinnz/Typograffiti

3273335a8d92e3aa5b1765a995f31fd2862381d3 — Adrian Cochrane 1 year, 10 months ago f793b68
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!
2 files changed, 2 insertions(+), 4 deletions(-)

M src/Typograffiti/Atlas.hs
M src/Typograffiti/Text.hs
M src/Typograffiti/Atlas.hs => src/Typograffiti/Atlas.hs +0 -1
@@ 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

M src/Typograffiti/Text.hs => src/Typograffiti/Text.hs +2 -3
@@ 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