typograffiti-0.1.0.3: Just let me draw nice text already

Copyright(c) 2018 Schell Scivally
LicenseMIT
MaintainerSchell Scivally <schell@takt.com>
Safe HaskellNone
LanguageHaskell2010

Typograffiti.Atlas

Description

This module provides a font-character atlas to use in font rendering with opengl.

Synopsis

Documentation

data TypograffitiError Source #

Constructors

TypograffitiErrorNoGlyphMetricsForChar Char

The are no glyph metrics for this character. This probably means the character has not been loaded into the atlas.

TypograffitiErrorFreetype String String

There was a problem while interacting with the freetype2 library.

TypograffitiErrorGL String

There was a problem while interacting with OpenGL.

data AtlasMeasure Source #

Constructors

AM 

Fields

Instances
Eq AtlasMeasure Source # 
Instance details

Defined in Typograffiti.Atlas

Show AtlasMeasure Source # 
Instance details

Defined in Typograffiti.Atlas

spacing :: Int Source #

The amount of spacing between glyphs rendered into the atlas's texture.

measure :: FT_Face -> Int -> (IntMap AtlasMeasure, AtlasMeasure) -> Char -> FreeTypeIO (IntMap AtlasMeasure, AtlasMeasure) Source #

Extract the measurements of a character in the FT_Face and append it to the given AtlasMeasure.

allocAtlas Source #

Arguments

:: (MonadIO m, MonadError TypograffitiError m) 
=> FilePath

Path to the font file to use for this Atlas.

-> GlyphSize

Size of glyphs in this Atlas.

-> String

The characters to include in this Atlas.

-> m Atlas 

Allocate a new Atlas. When creating a new Atlas you must pass all the characters that you might need during the life of the Atlas. Character texturization only happens once.

freeAtlas :: MonadIO m => Atlas -> m () Source #

Releases all resources associated with the given Atlas.

makeCharQuad Source #

Arguments

:: (MonadIO m, MonadError TypograffitiError m) 
=> Atlas

The atlas that contains the metrics for the given character.

-> Bool

Whether or not to use kerning.

-> Int

The current "pen position".

-> Maybe FT_UInt

The freetype index of the previous character, if available.

-> Char

The character to generate geometry for.

-> m (Vector (V2 Float, V2 Float), Int, Maybe FT_UInt)

Returns the generated geometry (position in 2-space and UV parameters), the next pen position and the freetype index of the given character, if available.

Construct the geometry needed to render the given character.

asciiChars :: String Source #

A string containing all standard ASCII characters. This is often passed as the String parameter in allocAtlas.

stringTris Source #

Arguments

:: (MonadIO m, MonadError TypograffitiError m) 
=> Atlas

The font atlas.

-> Bool

Whether or not to use kerning.

-> String

The string.

-> m (Vector (V2 Float, V2 Float)) 

Generate the geometry of the given string.