Safe Haskell | None |
---|
Module in charge of loading fonts.
- decodeFont :: ByteString -> Either String Font
- loadFontFile :: FilePath -> IO (Either String Font)
- getStringCurveAtPoint :: Dpi -> (Float, Float) -> [(Font, PointSize, String)] -> [[Vector (Float, Float)]]
- stringBoundingBox :: Font -> Dpi -> PointSize -> String -> (Float, Float)
- findFontOfFamily :: String -> FontStyle -> IO (Maybe FilePath)
- data FontCache
- data FontDescriptor = FontDescriptor {}
- findFontInCache :: FontCache -> FontDescriptor -> Maybe FilePath
- buildCache :: IO FontCache
- data Font = Font {
- _fontOffsetTable :: !OffsetTable
- _fontTables :: ![(ByteString, ByteString)]
- _fontNames :: Maybe NameTable
- _fontHeader :: Maybe FontHeader
- _fontMaxp :: Maybe MaxpTable
- _fontMap :: Maybe CharacterMaps
- _fontGlyph :: Maybe (Vector Glyph)
- _fontLoca :: Maybe (Vector Word32)
- _fontHorizontalHeader :: Maybe HorizontalHeader
- _fontHorizontalMetrics :: Maybe HorizontalMetricsTable
- data FontStyle = FontStyle {
- _fontStyleBold :: !Bool
- _fontStyleItalic :: !Bool
- type Dpi = Int
- type PointSize = Int
Functions
decodeFont :: ByteString -> Either String FontSource
Decode a in-memory true type file.
loadFontFile :: FilePath -> IO (Either String Font)Source
Load a font file, the file path must be pointing to the true type file (.ttf)
:: Dpi | Dot per inch of the output. |
-> (Float, Float) | Initial position of the baseline. |
-> [(Font, PointSize, String)] | Text to draw |
-> [[Vector (Float, Float)]] | List of contours for each char |
Extract a list of outlines for every char in the string. The given curves are in an image like coordinate system, with the origin point in the upper left corner.
stringBoundingBox :: Font -> Dpi -> PointSize -> String -> (Float, Float)Source
Compute the bounding box of a string displayed with a font at a given size. The resulting coordinate represent the width and the height in pixels.
findFontOfFamily :: String -> FontStyle -> IO (Maybe FilePath)Source
This function will scan the system's font folder to find a font with the desired properties. Favor using a FontCache to speed up the lookup process.
Font cache
A font cache is a cache listing all the found fonts on the system, allowing faster font lookup once created
data FontDescriptor Source
A font descriptor is a key used to find a font in a font cache.
FontDescriptor | |
|
findFontInCache :: FontCache -> FontDescriptor -> Maybe FilePathSource
Try to find a font with the given properties in the font cache.
buildCache :: IO FontCacheSource
This function will search in the system for truetype files and index them in a cache for further fast search.
Types
Type representing a font.
Font | |
|
Describe the basic stylistic properties of a font.
FontStyle | |
|