#resource Region

Purpose

The #resource region declares assets embedded directly into the binary. No runtime file loading needed.

tape
#resource
icon app_icon "assets/icon.png";
image splash "assets/splash.png" { max_size: 256; format: rgba; };
font main_font "assets/Inter-Regular.ttf" { sizes: [12, 14, 16, 18, 24]; };
sound click "assets/click.wav";
binary shader_data "shaders/compiled.spv";

Resource types

KeywordPurposeOptions
iconApplication/toolbar iconsmax_size
imageRaster imagesmax_size, format
fontFont filessizes (pre-rasterization)
soundAudio clipsformat
binaryRaw binary datanone

Accessing from #code

tape
#code
fn setup_window() {
    ui.set_icon(app_icon);
    ui.show_splash(splash);
}

fn play_feedback() {
    audio.play(click);
}

Resources are available as typed constants in #code.

Font pre-rasterization

tape
font ui_font "assets/JetBrainsMono.ttf" { sizes: [12, 14, 16]; };

The sizes option pre-rasterizes the font at the specified pixel sizes during compilation. At runtime, rendering is instant — no font parsing needed.

@exeicon — Executable icon

tape
#resource
@exeicon("assets/app.ico")

Sets the application icon for the compiled executable. The path is resolved relative to the source file. This is a compile-time-only directive — it does not create a runtime-accessible resource.

  • Windows: embeds the icon into the PE resource section (.rsrc) with RT_ICON and RT_GROUP_ICON entries, visible in Explorer, taskbar, and Alt+Tab
  • Uusi/ELF: stores the icon in a .note.icon ELF section for the desktop shell
  • Only one @exeicon per build target (multiple is a compile error)
  • Supported format: .ico
  • Only applies to tape build — ignored in tape run (VM mode)

This is different from icon resource declarations, which create runtime-accessible constants for UI use (toolbar icons, tray icons, etc.).

Image format options

tape
image texture "assets/tile.png" {
    max_size: 512;    // resize if larger
    format: rgba;     // store as raw RGBA pixels
};

Last modified: