Module Sdlttf


module Sdlttf: sig .. end
This module provides TTF (TrueType Font) support

exception SDLttf_exception of string
Exception for reporting errors
val init : unit -> unit
Initialise SDL_tff and freetype
val quit : unit -> unit
Quits the system

General operations on font datatype


type font 
abstract font datatype
val open_font : string -> ?index:int -> int -> font
open a font file and create a font of the specified point size
Returns font datatype

Set and retrieve the font style This font style is implemented by modifying the font glyphs, and doesn't reflect any inherent properties of the truetype font file.

type font_style =
| NORMAL
| BOLD
| ITALIC
| UNDERLINE
val get_font_style : font -> font_style list
Retrieve the font style : either NORMAL or a combination of BOLD, ITALIC and UNDERLINE
val set_font_style : font -> font_style list -> unit

Font information


val font_height : font -> int
Returns the total height(int) of the font (usually equal to point size)
val font_ascent : font -> int
Returns the offset(int) from the baseline to the top of the font this is a positive value, relative to the baseline
val font_descent : font -> int
Returns the offset from the baseline to the bottom of the font this is a negative value, relative to the baseline
val font_lineskip : font -> int
Get the recommended spacing between lines of text for this font
val font_faces : font -> int
Get the number of faces of the font

Get some font face attributes, if any
val is_fixed_width : font -> bool
val family_name : font -> string
val style_name : font -> string

Text rendering functions


val size_text : font -> string -> int * int
Get the dimensions of a rendered string of text
val size_utf8 : font -> string -> int * int
val glyph_metrics : font -> char -> int * int * int * int
Returns the metrics (minx,maxx,miny,maxy) of a glyph

type render_kind =
| SOLID of Sdlvideo.color
| SHADED of Sdlvideo.color * Sdlvideo.color
| BLENDED of Sdlvideo.color
Variant type for the generic rendering functions

Text rendering functions


val render_text_solid : font -> string -> fg:Sdlvideo.color -> Sdlvideo.surface
val render_text_shaded : font ->
string -> fg:Sdlvideo.color -> bg:Sdlvideo.color -> Sdlvideo.surface
val render_text_blended : font -> string -> fg:Sdlvideo.color -> Sdlvideo.surface
val render_utf8_solid : font -> string -> fg:Sdlvideo.color -> Sdlvideo.surface
val render_utf8_shaded : font ->
string -> fg:Sdlvideo.color -> bg:Sdlvideo.color -> Sdlvideo.surface
val render_utf8_blended : font -> string -> fg:Sdlvideo.color -> Sdlvideo.surface
val render_text : font -> render_kind -> string -> Sdlvideo.surface

Glyph rendering functions


val render_glyph_solid : font -> char -> fg:Sdlvideo.color -> Sdlvideo.surface
val render_glyph_shaded : font ->
char -> fg:Sdlvideo.color -> bg:Sdlvideo.color -> Sdlvideo.surface
val render_glyph_blended : font -> char -> fg:Sdlvideo.color -> Sdlvideo.surface
val render_glyph : font -> render_kind -> char -> Sdlvideo.surface