| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
KB.Text.Shape.Font
Synopsis
- extractBlob :: ByteString -> Int -> IO ByteString
- data FontData = FontData {}
- createFont :: ByteString -> Int -> IO FontData
- destroyFont :: FontData -> IO ()
- withFontData :: FontData -> (Font -> IO r) -> IO r
- data Font
- getFontInfo :: Font -> IO Info
- data Info = Info {
- strings :: [(FontInfoStringId, Text)]
- styleFlags :: FontStyleFlags
- weight :: FontWeight
- width :: FontWidth
- emToCaps :: Fractional a => Font -> a
- capHeight :: Num a => Font -> a
- unitsPerEm :: Num a => Font -> a
- withLoader :: (FontData -> Ptr LoadFontState -> IO a) -> IO a
- loadFont :: ByteString -> Int -> FontData -> Ptr LoadFontState -> IO (Either LoadFontError LoadFontResult)
- data LoadFontResult
- = LoadFontReady
- | LoadFontNeedsBlob {
- scratchSize :: Int
- outputSize :: Int
- placeBlob :: FontData -> Ptr LoadFontState -> Int -> Int -> IO ByteString
Distillation
Arguments
| :: ByteString | TTF font data |
| -> Int | Font index (use 0 for the first/only font) |
| -> IO ByteString | KBTS blob data |
Extract and pre-process font data needed for shaping.
Loading
Haskell-owned font data
Constructors
| FontData | |
Fields
| |
Instances
createFont :: ByteString -> Int -> IO FontData Source #
destroyFont :: FontData -> IO () Source #
Using
An opaque handle to the font data.
Querying
Constructors
| Info | |
Fields
| |
Font metrics
emToCaps :: Fractional a => Font -> a Source #
Scaling factor to go from font-specific Em units to a cap-height normalized units.
This results in more consistent font sizing when using multiple fonts. You may even have a chance to align something vertically!
capHeight :: Num a => Font -> a Source #
Get the height of font's capital letters, in the font's logical units.
unitsPerEm :: Num a => Font -> a Source #
Get the font's "Em square" size, in the font's logical units.
Loading internals
withLoader :: (FontData -> Ptr LoadFontState -> IO a) -> IO a Source #
loadFont :: ByteString -> Int -> FontData -> Ptr LoadFontState -> IO (Either LoadFontError LoadFontResult) Source #
data LoadFontResult Source #
Constructors
| LoadFontReady | |
| LoadFontNeedsBlob | |
Fields
| |
placeBlob :: FontData -> Ptr LoadFontState -> Int -> Int -> IO ByteString Source #