Skip to content

stdlib/fontView source ↗

font

19 items · generated by scribe fromstdlib/font.fd· synced 2026-11-15

stdlib/font19 items

Contents

Font

pub struct Font {

Fields:

NameType
infoi64
dataVec<i64>
scalef64
ascentf64
descentf64
line_gapf64
line_heightf64

Defined at line 25


Glyph

pub struct Glyph {

Fields:

NameType
codepointi64
widthi64
heighti64
xoffi64
yoffi64
advancef64
bitmapVec<i64>

Defined at line 41


font_load

Load a TrueType font from a file path at the given pixel size. Returns a Font with info=0 on failure.

pub fn font_load(path: str, pixel_size: f64) -> Font {

Parameters:

  • path: str
  • pixel_size: f64

Returns: Font

Defined at line 88


font_free

Free a font’s resources.

pub fn font_free(font: & mut Font) -> void {

Parameters:

  • font: & mut Font

Returns: void

Defined at line 111


font_get_glyph

Get a single glyph bitmap for a codepoint. Returns a Glyph with width=0 if the codepoint is not in the font.

pub fn font_get_glyph(font: & Font, codepoint: i64) -> Glyph {

Parameters:

  • font: & Font
  • codepoint: i64

Returns: Glyph

Defined at line 123


font_kern

Get the kerning advance between two codepoints (in pixels).

pub fn font_kern(font: & Font, ch1: i64, ch2: i64) -> f64 {

Parameters:

  • font: & Font
  • ch1: i64
  • ch2: i64

Returns: f64

Defined at line 153


font_text_width

Measure the width of a text string in pixels.

pub fn font_text_width(font: & Font, text: str) -> i64 {

Parameters:

  • font: & Font
  • text: str

Returns: i64

Defined at line 163


font_text_height

Measure the height of a text string (line height * number of lines).

pub fn font_text_height(font: & Font, text: str) -> i64 {

Parameters:

  • font: & Font
  • text: str

Returns: i64

Defined at line 172


font_render_text

Render a text string to an Image (RGBA pixels, transparent background). The image width is the text width, height is the line height.

pub fn font_render_text(font: & Font, text: str) -> Image {

Parameters:

  • font: & Font
  • text: str

Returns: Image

Defined at line 189


font_render_text_colored

Render text with a specific color (r, g, b, a).

pub fn font_render_text_colored(font: & Font, text: str, r: i64, g: i64, b: i64, a: i64) -> Image {

Parameters:

  • font: & Font
  • text: str
  • r: i64
  • g: i64
  • b: i64
  • a: i64

Returns: Image

Defined at line 255


BITMAP_FONT_WIDTH:

pub const BITMAP_FONT_WIDTH: i64 = 8; pub const BITMAP_FONT_HEIGHT: i64 = 8;

Defined at line 286


font_bitmap_char

Render a single character using the built-in 8x8 bitmap font. Returns an 8x8 RGBA Image.

pub fn font_bitmap_char(ch: i64) -> Image {

Parameters:

  • ch: i64

Returns: Image

Defined at line 289


font_bitmap_text

Render text using the built-in 8x8 bitmap font (no FFI needed).

pub fn font_bitmap_text(text: str) -> Image {

Parameters:

  • text: str

Returns: Image

Defined at line 320


Generated by scribe, the Fides documentation generator