Copyright | (c) 2018 Schell Scivally 2023 Adrian Cochrane |
---|---|
License | MIT |
Maintainer | Schell Scivally <schell@takt.com> & Adrian Cochrane <alcinnz@argonaut-constellation.org> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A storage context an ops for rendering text with multiple fonts and sizes, hiding the details of the Atlas, Cache, and the Harfbuzz library.
Synopsis
- data FontStore n = FontStore {
- fontMap :: TMVar (Map (FilePath, GlyphSize, Int, FontOptions) Font)
- drawGlyphs :: Atlas -> [(GlyphInfo, GlyphPos)] -> n (AllocatedRendering [TextTransform])
- lib :: FT_Library
- data Font = Font {}
- makeDrawTextCached :: (MonadIO m, MonadFail m, MonadError TypograffitiError m, MonadIO n, MonadFail n, MonadError TypograffitiError n) => FontStore n -> FilePath -> Int -> GlyphSize -> SampleText -> m (RichText -> n (AllocatedRendering [TextTransform]))
- allocFont :: (MonadIO m, MonadError TypograffitiError m) => FontStore n -> FilePath -> Int -> GlyphSize -> FontOptions -> m Font
- allocAtlas' :: (MonadIO m, MonadFail m, MonadError TypograffitiError m) => TMVar [(IntSet, Atlas)] -> FT_Face -> IntSet -> (Float, Float) -> m Atlas
- freeFonts :: (MonadIO m, MonadError TypograffitiError m) => FontStore n -> Maybe FilePath -> Maybe Int -> Maybe GlyphSize -> m IntSet
- withFontStore :: (MonadIO n, MonadError TypograffitiError n, MonadFail n) => (FontStore n -> ExceptT TypograffitiError IO a) -> IO (Either TypograffitiError a)
- newFontStore :: (MonadIO m, MonadError TypograffitiError m, MonadIO n, MonadError TypograffitiError n, MonadFail n) => FT_Library -> m (FontStore n)
Documentation
Stored fonts at specific sizes.
FontStore | |
|
An opened font. In Harfbuzz, FreeType, & Atlas formats.
makeDrawTextCached :: (MonadIO m, MonadFail m, MonadError TypograffitiError m, MonadIO n, MonadFail n, MonadError TypograffitiError n) => FontStore n -> FilePath -> Int -> GlyphSize -> SampleText -> m (RichText -> n (AllocatedRendering [TextTransform])) Source #
Opens a font sized to given value & prepare to render text in it. The fonts are cached for later reuse.
allocFont :: (MonadIO m, MonadError TypograffitiError m) => FontStore n -> FilePath -> Int -> GlyphSize -> FontOptions -> m Font Source #
Opens & sizes the given font using both FreeType & Harfbuzz,
loading it into the FontStore
before returning.
allocAtlas' :: (MonadIO m, MonadFail m, MonadError TypograffitiError m) => TMVar [(IntSet, Atlas)] -> FT_Face -> IntSet -> (Float, Float) -> m Atlas Source #
Allocates a new Atlas for the given font & glyphset, loading it into the atlas cache before returning.
freeFonts :: (MonadIO m, MonadError TypograffitiError m) => FontStore n -> Maybe FilePath -> Maybe Int -> Maybe GlyphSize -> m IntSet Source #
Frees fonts identified by filepath, index, and/or fontsize. Returns the glyphsets covered by their newly-freed atlases in case callers wish to make an informed reallocation.
withFontStore :: (MonadIO n, MonadError TypograffitiError n, MonadFail n) => (FontStore n -> ExceptT TypograffitiError IO a) -> IO (Either TypograffitiError a) Source #
Runs the given callback with a new FontStore
.
Due to FreeType limitations this font store should not persist outside the callback.
newFontStore :: (MonadIO m, MonadError TypograffitiError m, MonadIO n, MonadError TypograffitiError n, MonadFail n) => FT_Library -> m (FontStore n) Source #
Allocates a new FontStore wrapping given FreeType state.