FontyFruity-0.5.3.3: A true type file format loader

Graphics.Text.TrueType

Contents

Description

Synopsis

# Functions

Decode a in-memory true type file.

Load a font file, the file path must be pointing to the true type file (.ttf)

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.

Return the number of pixels relative to the point size.

True if the character is not present in the font, therefore it will appear as a placeholder in renderings.

Arguments

 :: Font -> Char -> (Float, Vector RawGlyph) Advance and glyph information.

Retrive the glyph contours and associated transformations. The coordinate system is assumed to be the TTF one (y upward). No transformation is performed.

getGlyphForStrings :: Dpi -> [(Font, PointSize, String)] -> [[Vector (Float, Float)]] #

This function return the list of all contour for all char with the given font in a string. All glyph are at the same position, they are not placed like with getStringCurveAtPoint. It is a function helpful to extract the glyph geometry for further external manipulation.

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.

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 #

A font cache is a cache listing all the found fonts on the system, allowing faster font lookup once created

FontCache is an instance of binary, to get okish performance you should save it in a file somewhere instead of rebuilding it everytime!

The font cache is dependent on the version of rasterific, you must rebuild it for every version.

Instances

 # MethodsshowList :: [FontCache] -> ShowS # # Methodsput :: FontCache -> Put #putList :: [FontCache] -> Put #

data FontDescriptor #

A font descriptor is a key used to find a font in a font cache.

Constructors

 FontDescriptor Fields_descriptorFamilyName :: !TextThe family name of the font_descriptorStyle :: !FontStyleThe desired style

Instances

 # Methods # Methods # MethodsshowList :: [FontDescriptor] -> ShowS # # MethodsputList :: [FontDescriptor] -> Put #

Font cache with no pre-existing fonts in it.

Try to find a font with the given properties in the font cache.

This function will search in the system for truetype files and index them in a cache for further fast search.

Returns a list of descriptors of fonts stored in the given cache.

If possible, returns a descriptor of the Font.

# Types

data Font #

Type representing a font.

Instances

 # MethodsshowsPrec :: Int -> Font -> ShowS #show :: Font -> String #showList :: [Font] -> ShowS # # Methodsrnf :: Font -> () #

data FontStyle #

Describe the basic stylistic properties of a font.

Constructors

 FontStyle Fields_fontStyleBold :: !BoolIf the font is bold._fontStyleItalic :: !BoolIf the font is italic.

Instances

 # Methods # Methods # MethodsshowList :: [FontStyle] -> ShowS # # Methodsput :: FontStyle -> Put #putList :: [FontStyle] -> Put #

data RawGlyph #

This type represent unscaled glyph information, everything is still in its raw form.

Constructors

 RawGlyph Fields_rawGlyphCompositionScale :: ![CompositeScaling]List of transformations to apply to the contour in order to get their correct placement._rawGlyphIndex :: !IntGlyph index in the current font._rawGlyphContour :: ![Vector (Int16, Int16)]Real Geometry of glyph, each vector contain one contour.

type Dpi = Int #

Express device resolution in dot per inch.

newtype PointSize #

Font size expressed in points. You must convert size expressed in pixels to point using the DPI information. See pixelSizeInPointAtDpi

Constructors

 PointSize FieldsgetPointSize :: Float

Instances

 # Methods # MethodsshowList :: [PointSize] -> ShowS #

Transformation matrix used to transform composite glyph

  | a b |
| c d |


Constructors

 CompositeScaling Fields_a :: !Int16a coeff._b :: !Int16b coeff._c :: !Int16c coeff._d :: !Int16d coeff.

Instances

 # Methods # MethodsshowList :: [CompositeScaling] -> ShowS #

data BoundingBox #

String bounding box. with value for min/max.

Constructors

 BoundingBox Fields_xMin :: !Float _yMin :: !Float _xMax :: !Float _yMax :: !Float _baselineHeight :: !FloatShould be 0 most of the times.

Instances

 # Methods