Module OgamlGraphics.Font

Information about a font

Submodules

Glyph Representation of a character

This module stores a font and dynamically loads sizes and glyphs as requested by the user

exception Font_error of string
Raised when an error occur in this module
type t
Type of a font
type code = [ `Char of char | `Code of int]
Type alias for a character given in ASCII or UTF-8
val load : string -> t
Loads a font from a file
val glyph : t -> code -> int -> bool -> Glyph.t
glyph font code size bold returns the glyph representing the character code in font of size size and with the modifier bold
val kerning : t -> code -> code -> int -> float
Returns the kerning between two chars of a given size, that is the horizontal offset that must be applied between the two glyphs (usually negative)
val ascent : t -> int -> float
Returns the coordinate above the baseline the font extends
val descent : t -> int -> float
Returns the coordinate below the baseline the font extends (usually negative)
val linegap : t -> int -> float
Returns the distance between the descent of a line and the ascent of the next line
val spacing : t -> int -> float
Returns the space between the baseline of two lines (equals ascent + linegap - descent)
val texture : (module RenderTarget.T with type t = 'a) -> 'a -> t -> Texture.Texture2DArray.t
Returns the texture associated to a font. In this texture, every layer correspond to a font size (in loading order). Use Font.size_index to get the layer associated to a font size. This texture is not mipmapped.
val size_index : t -> int -> int
Returns the index associated to a font size in the font's texture. Raises Font_error if the font size has not been loaded yet.