typograffiti-0.2.0.0: Just let me draw nice text already

Copyright(c) 2018 Schell Scivally 2023 Adrian Cochrane
LicenseMIT
MaintainerSchell Scivally <schell@takt.com> & Adrian Cochrane <alcinnz@argonaut-constellation.org>
Safe HaskellNone
LanguageHaskell2010

Typograffiti.Cache

Description

This module provides a method of caching rendererd text, making it suitable for interactive rendering. You can use the defaultCache or provide your own.

Synopsis

Documentation

class Layout t where Source #

Generic operations for text layout.

Methods

translate :: t -> V2 Float -> t Source #

Instances
Layout [TextTransform] Source # 
Instance details

Defined in Typograffiti.Cache

data AllocatedRendering t Source #

Holds an allocated draw function for some amount of text. The function takes one parameter that can be used to transform the text in various ways. This type is generic and can be used to take advantage of your own font rendering shaders.

Constructors

AllocatedRendering 

Fields

  • arDraw :: t -> V2 Int -> IO ()

    Draw the text with some transformation in some monad.

  • arRelease :: IO ()

    Release the allocated draw function in some monad.

  • arSize :: V2 Int

    The size (in pixels) of the drawn text.

makeDrawGlyphs :: (MonadIO m, MonadError TypograffitiError m, MonadIO n, MonadFail n, MonadError TypograffitiError n) => m (Atlas -> [(GlyphInfo, GlyphPos)] -> n (AllocatedRendering [TextTransform])) Source #

Constructs a callback for for computing the geometry for rendering given glyphs out of the given texture.

vertexShader :: ByteString Source #

The GPU code to finalize the position of glyphs onscreen.

fragmentShader :: ByteString Source #

The GPU code to composite the recoloured glyph into the output image.

data SpatialTransform Source #

Geometrically transform the text.

Constructors

SpatialTransformTranslate (V2 Float)

Shift the text horizontally or vertically.

SpatialTransformScale (V2 Float)

Resize the text.

SpatialTransformRotate Float

Enlarge the text.

SpatialTransformSkew Float

Skew the text, approximating italics (or rather obliques).

SpatialTransform (M44 Float)

Apply an arbitrary matrix transform to the text.

data TextTransform Source #

Modify the rendered text.

Constructors

TextTransformMultiply (V4 Float)

Adjust the colour of the rendered text.

TextTransformSpatial SpatialTransform

Adjust the position of the rendered text.

Instances
Layout [TextTransform] Source # 
Instance details

Defined in Typograffiti.Cache

transformToUniforms :: [TextTransform] -> (M44 Float, V4 Float) Source #

Convert the TextTransforms into data that can be sent to the GPU.

move :: Float -> Float -> TextTransform Source #

Shift the text horizontally or vertically.

scale :: Float -> Float -> TextTransform Source #

Resize the text.

rotate :: Float -> TextTransform Source #

Rotate the text.

color :: Float -> Float -> Float -> Float -> TextTransform Source #

Recolour the text.

alpha :: Float -> TextTransform Source #

Make the text semi-transparant.

liftGL :: (MonadIO m, MonadError TypograffitiError m) => m (Either String a) -> m a Source #

Utility for calling OpenGL APIs in a error monad.