Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

upload_fonts

Function upload_fonts 

Source
pub fn upload_fonts<R: VramRegionSource>(
    fonts: &[&'static BitmapFont],
    alloc: &mut R,
    scratch: &mut [u16],
    out: &mut [Option<FontAtlas>],
) -> Option<FontSetVram>
Expand description

Upload several fonts in a single GP0(A0h) image transfer.

Repeated per-font VRAM uploads desync the GPU command stream on some targets and corrupt subsequent (world) rendering; packing every glyph atlas side-by-side into one reserved page run and emitting one transfer avoids that entirely. Multiple atlas rectangles share each 256x256 4bpp tpage through page-local UV origins; all fonts share one 2-entry CLUT (transparent, white) which tint recolours per draw.

scratch is a caller-owned buffer (put it in static mut BSS, not on the stack); query font_pack_metrics for the exact required length. out receives one Some(FontAtlas) per font; trailing slots are set to None. Returns the handles to free the set later, or None (uploading nothing) if a font is too wide, scratch/out is too small, or the allocator is out of space. Every failure clears all of out, so a caller can never mistake stale or partially prepared handles for the set.