raylib/text
src/raylib/text.tur
defn
load-font
(load-font [path : cstr] :)
load a TrueType or AngelCode font from a file.
Parameters
| path | filesystem path to the font file (.ttf, .otf, .fnt, ...) |
Returns
Opaque :int handle to a heap-allocated Font struct.
Example
(let [f (load-font "roboto.ttf")] ...)
Since: P3
defn
unload-font
(unload-font [font : int] :)
free a font from GPU and CPU memory.
Parameters
| font | Font handle from load-font |
Example
(unload-font f)
Since: P3
defn
draw-text
(draw-text [text : cstr x : int y : int size : int col : int] :)
draw a string using the default built-in font.
Parameters
| text | NUL-terminated string to draw | |
| x | left edge (pixels) | |
| y | top edge (pixels) | |
| size | font size in pixels | |
| col | Color handle |
Example
(draw-text "Hello!" 10 10 24 (white))
Since: P3
defn
draw-text-ex
(draw-text-ex [font : int text : cstr px : float py : float size : float spacing : float col : int] :)
draw a string with a loaded Font, position, size, spacing, and color.
Parameters
| font | Font handle from load-font | |
| text | NUL-terminated string to draw | |
| px py -- position (pixels) as floats for sub-pixel accuracy | ||
| size | font size in pixels (float) | |
| spacing | extra spacing between glyphs (float) | |
| col | Color handle |
Example
(draw-text-ex f "Score: 42" 10.0 10.0 32.0 1.5 (white))
Since: P3
defn
measure-text
(measure-text [text : cstr size : int] :)
measure the pixel width of a string rendered at a given size.
Parameters
| text | NUL-terminated string | |
| size | font size in pixels (using the default built-in font) |
Returns
Width of the rendered string in pixels as :int.
Example
(let [w (measure-text "Hello" 24)] ...)
Since: P3