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.Store

Description

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

Documentation

data FontStore n Source #

Stored fonts at specific sizes.

Constructors

FontStore 

Fields

data Font Source #

An opened font. In Harfbuzz, FreeType, & Atlas formats.

Constructors

Font 

Fields

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 -> 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.