#resource Region
This feature is designed but not yet implemented. The syntax and behavior described here represent the target specification.
#resource region is designed but not implemented yet: the region splitter recognizes the marker, but its contents are not processed. This page describes the design.Purpose
The #resource region declares assets embedded directly into the binary. No runtime file loading needed.
#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";Each declaration is kind name = "path" [{ options }];. The path is
relative to the .tape file and resolved at compile time: a missing file,
a file that isn’t the declared kind, or a repeated name is a compile error.
Resource types
| Keyword | Type | Purpose | Options |
|---|---|---|---|
icon | resource.Icon | Application/toolbar icons | none |
image | resource.Image | Raster images | max_size, format |
font | resource.Font | Font files | sizes (pre-rasterization) |
sound | resource.Sound | Audio clips | sample_rate |
binary | []const u8 | Raw binary data | none |
Accessing from #code
#code
fn setup_window() {
ui.set_icon(app_icon.images); // its sizes, as gfx.Surfaces
ui.show_splash(splash);
}
fn play_feedback() {
audio.play(click);
}Resources are module-level typed constants, available in #code, #view
and #test by name. They don’t allocate at run time: the data lives in the
binary’s read-only data.
Font pre-rasterization
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
#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, and on the title bar of every window the program opens (ui,uwm, andgpuandgl, whose windows areuwmones) - Uusi/ELF: stores the icon in a
.note.iconELF section for the desktop shell - Only one
@exeiconper build target (multiple is a compile error) - Supported format:
.ico - Only valid inside
#resource - Only applies to
tape build— ignored intape run(VM mode)
This is different from icon resource declarations, which create runtime-accessible constants for UI use (toolbar icons, tray icons, etc.).
@windowed
#resource
@exeicon("assets/sulle.ico")
@windowed(BUILD != Build.Dev) // `@windowed` alone is `@windowed(true)`Says the executable is a windowed (GUI) program: on Windows it is built for the GUI subsystem instead of the console one, so starting it opens no console window. The subsystem is a field of the executable’s header, read before any of its code runs, so it is said here with the rest of what the executable says about itself, not decided by a library at run time and not guessed from what the program imports (a headless tool that imports ui wants its console).
- The argument is a compile-time
bool: a literal, aconst, a build setting,@targetcomparisons, and!,&&,||,==,!=of these. A dev build keeps its console for logs and a release has none, decided in the source. - At most one
@windowed, in the root file’s#resourceregion. One in a module the program imports (a library can’t decide how its program is packaged), or a second one, is a compile error. - Only
tape buildof an executable forwin64is windowed:tape run,tape test,tape check,--dlland--stoignore it, and so do the other targets, which have no such field. - There is no command-line flag for it:
tape build --windowedis an unknown flag whose message points here.
What a windowed program’s standard streams do, and what Windows’ shells make of one, is in tape build: Windowed programs.
Image format options
image texture = "assets/tile.png" {
max_size: 512; // compile error if either dimension is larger
format: rgba; // convert to raw RGBA pixels (rgba, rgb or gray)
};Last modified: