gelatin-freetype2-0.1.0.0: FreeType2 based text rendering for the gelatin realtime rendering system.

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

Gelatin.FreeType2.Internal

Description

This module provides easy freetype2 font rendering using gelatin's graphics primitives.

Synopsis

Documentation

loadWords Source #

Arguments

:: MonadIO m 
=> Backend GLuint e V2V2 (V2 Float) Float Raster

The V2V2 backend needed to render font glyphs.

-> Atlas

The atlas to load the words into.

-> String

The string of words to load, with each word separated by spaces.

-> m Atlas 

Load a string of words into the Atlas.

unloadMissingWords Source #

Arguments

:: MonadIO m 
=> Atlas

The Atlas to unload words from.

-> String

The source string.

-> m Atlas 

Unload any words not contained in the source string.

allocAtlas Source #

Arguments

:: MonadIO m 
=> FilePath

FilePath of the Font to use for this Atlas.

-> GlyphSize

Size of glyphs in this Atlas

-> String

The characters to include in this Atlas.

-> m (Maybe 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 here.

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

Releases all resources associated with the given Atlas.

asciiChars :: String Source #

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

freetypePicture Source #

Arguments

:: MonadIO m 
=> Atlas

The Atlas from which to read font textures word geometry.

-> String

The word to render.

-> TexturePictureT m ()

Returns a textured picture computation representing the texture and geometry of the input word.

Constructs a TexturePictureT of one word in all red. Colorization can then be done using setReplacementColor in the picture computation, or by using redChannelReplacement and passing that to the renderer after compilation, at render time. Keep in mind that any new word geometry will be discarded, since this computation does not return a new Atlas. For that reason it is advised that you load the needed words before using this function. For loading words, see loadWords.

This is used in freetypeRenderer2 to construct the geometry of each word. freetypeRenderer2 goes further and stores these geometries, looking them up and constructing a string of word renderers for each input String.

freetypeRenderer2 Source #

Arguments

:: MonadIO m 
=> Backend GLuint e V2V2 (V2 Float) Float Raster

The V2V2 backend to use for compilation.

-> Atlas

The Atlas to read character textures from and load word geometry into.

-> V4 Float

The solid color to render the string with.

-> String

The string to render. This string can contain newlines, which will be respected.

-> m (Renderer2, V2 Float, Atlas)

Returns the Renderer2, the size of the text and the new Atlas with the loaded geometry of the string.

Constructs a Renderer2 from the given color and string. The WordMap record of the given Atlas is used to construct the string geometry, greatly improving performance and allowing longer strings to be compiled and renderered in real time. To create a new Atlas see allocAtlas.

Note that since word geometries are stored in the Atlas WordMap and multiple renderers can reference the same Atlas, the returned Renderer2 contains a clean up operation that does nothing. It is expected that the programmer will call freeAtlas manually when the Atlas is no longer needed.