Stk.FontFonts.
This module provides functions to use fonts through Tsdl_ttf.Ttf.
Tsdl_ttf.Ttf.fonts are accessed through font descriptions font_desc. A caching mecanism avoids loading a SDL font each time a it is required.
Initializing. This function is called from App.init.
type font_metrics = {font_height : int;font_ascent : int;font_descent : int;font_line_skip : int;font_is_fixed_width : int;}Font metrics, to gather information from Tsdl_ttf.
val font_metrics : font -> font_metricsGet all font metrics from the given font.
type font_desc = {size : int;italic : bool;bold : bool;family : string;underline : bool;strikethrough : bool;kerning : bool;outline : int;}A font description describes a font: family, size, style, ...
val default_font_desc : font_descA default font description.
val font_desc_wrapper : font_desc Ocf.Wrapper.tval font_desc :
?size:int ->
?italic:bool ->
?bold:bool ->
?underline:bool ->
?strikethrough:bool ->
?kerning:bool ->
?outline:int ->
string ->
font_descConvenient function to create a font_desc. Default value for optional arguments are:
size: !default_font_size,italic: false,bold: false,strikethrough: false,kerning: true,outline: 0.val pp_font_desc : Stdlib.Format.formatter -> font_desc -> unitGet a fallback font family associated to given unicode codepoint.
add_fallback_font start stop family adds a font family to use as fallback font for the given range (start..stop) of unicode codepoints.
Font file extensions. Use when looking for font files in directories. Default is [".ttf"].
font_dirs () returns thee list of directories where to look for fonts, in the form (directory, rec-flag) where rec-flag indicates whether this directory should be inspected recursively when looking for fonts. App.init will call load_fonts which uses font_dirs () to look for available fonts. See Config.options to specifiy font directories.
val load_fonts :
?size:int ->
?dirs:(string * bool) list ->
unit ->
font_desc list Lwt.tload_fonts () looks for available fonts. Optional arguments are:
size: size used to load a font; default is default_font_size.dirs: directories to inspect. Default is font_dirs.val load_fonts_from_dir :
?size:int ->
?recur:bool ->
?override:bool ->
string ->
font_desc list Lwt.tload_fonts_from_dir dir looks for available fonts in the given directory. Optional arguments are:
size: size used to load a font; default is default_font_size.recur: whether to look recursively in sub directories; default is true.override: whether to replace existing fonts when a new one with same name is found; default is false.val string_of_font_desc : font_desc -> stringShort string for given font desc.
Close open fonts unused since some time. A font file remains open because of our caching system.
val fonts : unit -> font_desc listAvailable fonts. The available fonts are added by calls to load_fonts.
These functions correspond to those of Tsdl_ttf.Ttf, but using font value.
val glyph_metrics : font -> int -> Tsdl_ttf.Ttf.GlyphMetrics.t Tsdl.Sdl.resultval get_font_hinting : font -> Tsdl_ttf.Ttf.Hinting.tval get_font_kerning_size : font -> int -> int -> intval font_height : font -> intval font_ascent : font -> intval font_descent : font -> intval font_line_skip : font -> intval get_font_kerning : font -> boolval font_faces : font -> int64val font_face_is_fixed_width : font -> intval font_face_family_name : font -> stringval font_face_style_name : font -> stringval size_utf8 : font -> string -> (int * int) Tsdl.Sdl.resultval glyph_is_provided : font -> int -> boolval render_utf8_blended :
font ->
string ->
Tsdl.Sdl.color ->
Tsdl.Sdl.surface Tsdl.Sdl.resultval render_glyph_blended :
font ->
int ->
Tsdl.Sdl.color ->
Tsdl.Sdl.surface Tsdl.Sdl.result