Copyright | (c) 2018 Schell Scivally |
---|---|
License | MIT |
Maintainer | Schell Scivally <schell@takt.com> |
Safe Haskell | None |
Language | Haskell2010 |
This module provides a font-character atlas to use in font rendering with opengl.
Synopsis
- data TypograffitiError
- data Atlas = Atlas {}
- emptyAtlas :: FT_Library -> FT_Face -> GLuint -> Atlas
- data AtlasMeasure = AM {}
- emptyAM :: AtlasMeasure
- spacing :: Int
- measure :: FT_Face -> Int -> (IntMap AtlasMeasure, AtlasMeasure) -> Char -> FreeTypeIO (IntMap AtlasMeasure, AtlasMeasure)
- texturize :: IntMap (V2 Int) -> Atlas -> Char -> FreeTypeIO Atlas
- allocAtlas :: (MonadIO m, MonadError TypograffitiError m) => FilePath -> GlyphSize -> String -> m Atlas
- freeAtlas :: MonadIO m => Atlas -> m ()
- makeCharQuad :: (MonadIO m, MonadError TypograffitiError m) => Atlas -> Bool -> Int -> Maybe FT_UInt -> Char -> m (Vector (V2 Float, V2 Float), Int, Maybe FT_UInt)
- asciiChars :: String
- stringTris :: (MonadIO m, MonadError TypograffitiError m) => Atlas -> Bool -> String -> m (Vector (V2 Float, V2 Float))
Documentation
data TypograffitiError Source #
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. |
Instances
Eq TypograffitiError Source # | |
Defined in Typograffiti.Atlas (==) :: TypograffitiError -> TypograffitiError -> Bool # (/=) :: TypograffitiError -> TypograffitiError -> Bool # | |
Show TypograffitiError Source # | |
Defined in Typograffiti.Atlas showsPrec :: Int -> TypograffitiError -> ShowS # show :: TypograffitiError -> String # showList :: [TypograffitiError] -> ShowS # |
emptyAtlas :: FT_Library -> FT_Face -> GLuint -> Atlas Source #
data AtlasMeasure Source #
Instances
Eq AtlasMeasure Source # | |
Defined in Typograffiti.Atlas (==) :: AtlasMeasure -> AtlasMeasure -> Bool # (/=) :: AtlasMeasure -> AtlasMeasure -> Bool # | |
Show AtlasMeasure Source # | |
Defined in Typograffiti.Atlas showsPrec :: Int -> AtlasMeasure -> ShowS # show :: AtlasMeasure -> String # showList :: [AtlasMeasure] -> ShowS # |
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.
:: (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 |
-> m Atlas |
freeAtlas :: MonadIO m => Atlas -> m () Source #
Releases all resources associated with the given Atlas
.
:: (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
.