FontyFruity-0.3: A true type file format loader

Safe HaskellNone

Graphics.Text.TrueType

Contents

Description

Module in charge of loading fonts.

Synopsis

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)

getStringCurveAtPointSource

Arguments

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

data FontCache Source

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.

Constructors

FontDescriptor 

Fields

_descriptorFamilyName :: Text

The family name of the font

_descriptorStyle :: FontStyle

The desired style

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

data Font Source

Type representing a font.

Constructors

Font 

Fields

_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
 

Instances

data FontStyle Source

Describe the basic stylistic properties of a font.

Constructors

FontStyle 

Fields

_fontStyleBold :: !Bool

If the font is bold.

_fontStyleItalic :: !Bool

If the font is italic.

type Dpi = IntSource

Express device resolution in dot per inch.

type PointSize = IntSource

Font size expressed in points.