Skip to content

Commit 688fe63

Browse files
committed
2023.10
new: object v2 API new: reflection API new: tween API (@zpl-zak) new: tests API, --test, --test-break=NUM new: ID + quarks + semver APIs, time sortable GUIDs new: support for fused binaries (exe + zipfiles) new: -DENABLE_RETAIL to disable printfs, asserts, stdout/stderr, tests, cook and titlebar stats (@zpl-zak) new: allow search filtering in most ui widgets ^F (fwk_ui, 3rd_nuklear_filebrowser) new: display menu on MAKE.bat when double-clicked (win) new: ALLOCA() new: APP_SINGLETON_GUID new: AUTORUN snippets new: MAKE fuse new: VA_COUNT(), VA_SPLIT(), VA_FIRST(), VA_REST(), TODO(), FIXME() new: app_beep(), app_hang(), app_crash(), app_singleton(), app_open() new: atof1()/ftoa1(), itoa2/3/4(), ftoa2/3/4() (with expression evaluators) new: audio_mute(), audio_muted() new: byte2/3/4, int2/3/4, uint2/3/4, float2/3/4, double2/3/4 storage types new: crc64(), arc4(), entropy(), cobs, base92, ddelta de/encoders new: print2i(), print3i() new: ease_enum(), ease_enums(), ease_pong() new: have_tools() new: input_eval(), input_enum() new: ui_audio() new: unique() macro new: window_has_icon(), window_dpi() (@zpl-zak) new: vle,int,float,half packers new: tools/ark new: ability open zip files by handles given at any seek address (3rd_archive) new: added BUILD_VERSION, that gets printed at boot time and at window title new: added benchmark_ms {} new: added fxColorMapVis new: added material design icons webfont fork into editor assets new: allow file_list() to specify multiple dirs, semi-colon separated new: support for material-icons-webfont chg: --debug-font-atlas > --font-debug chg: --test-only > --test chg: added frame weight into benchmark() chg: added support for AUTORUN on clang-cl chg: allowed multiple AUTORUNs within same line chg: allowed tools/timer to be used as a pipe too chg: allowed ui_buffer(), ui_string(), ui_label2 to use null labels chg: allowed multiple STATIC_ASSERT() to be used within same line chg: allowed reflection module to process const, union and struct types chg: centered properties chg: changed NDEBUG to match the compiler optimization levels chg: changed font module to use RGBA textures chg: disable .ico icon support chg: eval() extended to use & | ! operators, _ in symbols (3rd_eval.h) chg: eval() extended to use many input constants and some input functions (3rd_eval.h) chg: failed autorun tests will stop game from launching chg: file_list reimplemented chg: hide all system folders by default (file_list) chg: improve reflection printers chg: increase max size per obj instance (up to 1KiB) chg: larger ui_contextual() popup chg: made annotations optional in all reflection macros chg: made arguments optional in both panic and printf macros chg: made file browser to fit better within the parent space (3rd_nuklear_filebrowser) chg: made optional annotations in reflection macros (ENUM,STRUCT,FUNCTION) chg: made quarks caching more mem friendly chg: made split/join commands to regenerate single-header distribution too (MAKE.bat) chg: made tcc the default compiler on windows. vc will only be used when specified, or when instanced within a VS terminal chg: made test() failures reddish chg: minor ui styling chg: obj_make() will return an empty obj type before failing chg: obj_name() as meta chg: optimize number of extra bits in obj header (4->19) chg: optimized cook time by redistributing workload much better into existing cookjobs (higher bits of FNV hashes were too stable) chg: potentially exclude .dSYM and .o files from cook chg: promoted time api to their own fwk_time file chg: quarks up to 64 chars each and 64M addressing by default chg: re-enable icon mounting from vfs volumes (@zpl-zak) chg: rebuilt tools/cook (win) chg: reduce some ms at quit time (win) chg: reduced severity in shader errors chg: renamed 3rd_font_md.h > 3rd_icon_md.h chg: reordered endianness utils chg: retail builds (MAKE retail) chg: stylized 99-nodes.c demo chg: ui_notify() beeps now chg: unrolled different ui_beep() implementations chg: updated 3rd_icon_mdi.h chg: updated docs chg: upgraded miniaudio to latest fix: --cook-debug not working when using multiple jobs fix: 4-byte unicodes not being printed (3rd_nuklear) fix: AUTORUN macro being executed in reverse order (gcc,clang,clang-cl,mingw...) fix: adjusted spacing webfont fix: allowed ///- document tags to be included anywhere within a line fix: app_beep() not working in retail builds fix: benchmark() not reporting while executed within first ms fix: cc_t compilation error on emscripten fix: detached from parent before deleting (obj_free) fix: detached objects no longer create holes within children array (obj_detach) fix: each_objchild() fix: editor compilation error on osx fix: fix profiler being rendered while filtering is on fix: fixed canvas scaling artifacts (html5) @zpl-zak fix: fixed display of long string names when doing vfs lookups fix: fixed editor_pick() (@zpl-zak) fix: fixed potential argument in each_substring() evaluated twice fix: fixed utterly broken shader params after the atof1/2/3/4() upgrade fix: font demo broken after opening debug panel fix: font shader modulates color by alpha now (@zpl-zak) fix: format warnings (gcc+linux) fix: fused executables not being mounted while launched from a different work directory fix: handled SEH exceptions (trap_install) fix: include objname as member in debug builds (obj) fix: initial cwd in python runs fix: initialize ui in mono thread. could prevent stack corruption in MT fix: invalid tar files not being marked as such (3rd_archive) fix: leaks in 3rd_archive.h while compressing fix: lua demo fix: made alert() visible always fix: made cache api MT safe fix: made cache_lookup() threadsafe fix: made compile-time cc4,cc8 macros fix: mingw compilation fix fix: mingw warnings fix: miniaudio not working on latest osx fix: missing folders in filebrowser since file_list() upgrade (3rd_nuklear_filebrowser) fix: mouse in shadertoys fix: obj stack not working properly fix: obj_make() clears payload now fix: opengl scissor issue when window is minimized (3rd_nuklear_glfw3.h) fix: pixel aligned combo arrows fix: popups outside window client (3rd_nuklear) fix: popups snapping to the left border (3rd_nuklear) fix: popups with vertical scrollbars (3rd_nuklear) fix: potential crash unless rounded up to 8-byte boundaries (obj_malloc) fix: python demo fix: redudant each_array(), each_array_ptr() calls when T was a function call fix: removed all audio spamming messages on webaudio (html5) @zpl-zak fix: reverted webaudio initialization (html5) fix: symbol visiblity in quark api fix: using filelocks for zip (should hopefully match OSX behavior from now) fix: video recordings from debug panel included a stamped ui_notify() on them fix: visual studio solutions were broken fix: vsmcube ifdefs on osx fix: wrong BRDF texture in 99-pbr + retail builds fix: wrong app_path() in linux/osx fix: wrong boids nearby check fix: wrong mouse cursors when resizing panels/windows (3rd_nuklear) fix: wrong pointer cast (each_objchild) fix: wrong program assignment in model rendering (@zpl-zak) fix: wrong rgba() endianness (@zpl-zak) fix: zip_open_handle closing file handles after an error brk: KEY_(R)ALT,KEY_(R)CTRL,KEY_(R)SHIFT to check both L+R keys brk: added argument to request a contextual close in ui_contextual_end() brk: array_erase() split into array_erase_slow() (preserves order) and array_erase_fast() (alters order) (@zpl-zak) brk: breakpoint() changed signature brk: changed behavior nk_selectable_text() brk: deprecated obj api in favor of upcoming objv2 api brk: dialog_load() > app_loadfile(), dialog_save() > app_savefile() brk: ease_ping_pong(), ease_pong_ping() signatures brk: file_list() and vfs_list() signatures brk: reflected_t -> reflect_t brk: signals api renamed to trap api lab: editor v3, bindings, console and selection (^A,^D,^I,^LMB) lab: editor_send() lab: tween sub-editor lab: old editor api > engine api lab: interleave(), netstring() lab: internal do_threadlock() lab: made va() allowed to grow on demand lab: msgpack api
1 parent 0a350a1 commit 688fe63

File tree

1,613 files changed

+1998703
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,613 files changed

+1998703
-0
lines changed

2023.10/MAKE.bat

Lines changed: 887 additions & 0 deletions
Large diffs are not rendered by default.

2023.10/README.md

Lines changed: 417 additions & 0 deletions
Large diffs are not rendered by default.

2023.10/demos/00-loop.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "fwk.h" // Minimal C sample
2+
3+
int main() {
4+
window_create(75.0, 0); // 75% size, no extra flags
5+
6+
while( window_swap() && !input(KEY_ESC) ) { // game loop
7+
puts("hello FWK from C!");
8+
}
9+
}

2023.10/demos/00-script.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "fwk.h"
2+
3+
#define SCRIPT(...) #__VA_ARGS__
4+
5+
#if 0 // teal
6+
script_run("local tl=require(\"tl\")\ntl.loader()");
7+
script_run("addsub = require(\"s2\"); print (addsub.add(10, 20))");
8+
s2.tl:
9+
local function add(a: number, b: number): number
10+
return a + b
11+
end
12+
local s = add(1,2)
13+
print(s)
14+
#endif
15+
16+
int main() {
17+
script_init();
18+
19+
script_run(SCRIPT(
20+
window_create(75.0,0);
21+
while window_swap() do
22+
ddraw_grid(10);
23+
if ui_panel("Hello from Lua!", 0) then
24+
ui_panel_end();
25+
end;
26+
end;
27+
));
28+
29+
// script test (lua)
30+
script_run( "-- Bye.lua\nio.write(\"script test: Bye world!, from \", _VERSION, \"\\n\")" );
31+
}

2023.10/demos/01-demo2d.c

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
// 2d demo: window, audio, camera, font, tiled, render, fx, spritesheet, input, ui. @todo: spine
2+
// - rlyeh, public domain.
3+
//
4+
// Compile with:
5+
// `make demos\01-demo2d.c` (windows)
6+
// `sh MAKE.bat demos/01-demo2d.c` (linux, osx)
7+
8+
#include "fwk.h"
9+
10+
void demo_kids(vec3 offs) {
11+
// init
12+
static texture_t kids; do_once kids = texture( "spriteSheetExample.png", TEXTURE_LINEAR );
13+
static vec3 pos[2] = {{490,362},{442,362}}, vel[2] = {0};
14+
static int row[2] = {0,3}, frame[2] = {0};
15+
static int inputs[2][4] = {{KEY_W,KEY_A,KEY_S,KEY_D},{KEY_UP,KEY_LEFT,KEY_DOWN,KEY_RIGHT}};
16+
17+
// move
18+
for( int i = 0; i < countof(pos); ++i ) {
19+
vel[i].x = input(inputs[i][3]) - input(inputs[i][1]);
20+
vel[i].y = input(inputs[i][2]) - input(inputs[i][0]);
21+
pos[i].x = fmod(pos[i].x + vel[i].x, window_width() + 128);
22+
pos[i].y = fmod(pos[i].y + vel[i].y, window_height() + 128);
23+
frame[i] += vel[i].x || vel[i].y;
24+
}
25+
26+
// render
27+
for( int i = 0; i < countof(pos); ++i ) {
28+
int col = frame[i] / 10, num_frame = row[i] * 4 + col % 4; // 4x4 tilesheet
29+
float position[3] = {pos[i].x,pos[i].y,pos[i].y}, offset[2]={0,0}, scale[2]={0.5,0.5};
30+
float spritesheet[3]={num_frame,4,4};
31+
sprite_sheet(kids,
32+
spritesheet, // num_frame in a 4x4 spritesheet
33+
position, 0, // position(x,y,depth:sort-by-Y), angle
34+
offset, scale, // offset(x,y), scale(x,y)
35+
false, WHITE, false // is_additive, tint color, resolution-independent
36+
);
37+
}
38+
}
39+
40+
void demo_hud() {
41+
// draw pixel-art hud, 16x16 ui element, scaled and positioned in resolution-independant way
42+
static texture_t inputs; do_once inputs = texture( "prompts_tilemap_34x24_16x16x1.png", TEXTURE_LINEAR );
43+
float spritesheet[3] = {17,34,24}, offset[2] = {0, - 2*absf(sin(window_time()*5))}; // sprite cell and animation
44+
float scale[2] = {3, 3}, tile_w = 16 * scale[0], tile_h = 16 * scale[1]; // scaling
45+
float position[3] = {window_width() - tile_w, window_height() - tile_h, window_height() }; // position in screen-coordinates (x,y,z-index)
46+
sprite_sheet(inputs, spritesheet, position, 0/*deg*/, offset, scale, false, WHITE, 1);
47+
}
48+
49+
int main() {
50+
// window (80% sized, MSAA x4 flag)
51+
window_create(80.0, WINDOW_MSAA4);
52+
window_title(__FILE__);
53+
54+
// tiled map
55+
tiled_t tmx = tiled(vfs_read("castle.tmx"));
56+
// tmx.parallax = true;
57+
58+
// spine model
59+
//spine_t *spn = spine("goblins.json", "goblins.atlas", 0);
60+
61+
// camera 2d
62+
camera_t cam = camera();
63+
cam.position = vec3(window_width()/2, window_height()/2, 3); // at(CX,CY) zoom(x3)
64+
camera_enable(&cam);
65+
66+
// audio (both clips & streams)
67+
audio_t clip1 = audio_clip( "coin.wav" );
68+
audio_t clip2 = audio_clip( "pew.sfxr" );
69+
audio_t stream1 = audio_stream( "larry.mid" );
70+
audio_t stream2 = audio_stream( "waterworld-map.fur" );
71+
audio_t BGM = stream1;
72+
audio_play(BGM, 0);
73+
74+
// font config: faces (6 max) and colors (10 max)
75+
#define FONT_CJK FONT_FACE3
76+
#define FONT_YELLOW FONT_COLOR2
77+
#define FONT_LIME FONT_COLOR3
78+
font_face(FONT_CJK, "mplus-1p-medium.ttf", 48.f, FONT_JP|FONT_2048); // CJK|FONT_2048|FONT_OVERSAMPLE_Y);
79+
font_color(FONT_YELLOW, RGB4(255,255,0,255));
80+
font_color(FONT_LIME, RGB4(128,255,0,255));
81+
82+
// fx: load all post fx files in all subdirs. enable a few filters by default
83+
fx_load("fx**.fs");
84+
fx_enable(fx_find("fxCRT2.fs"), 1);
85+
fx_enable(fx_find("fxGrain.fs"), 1);
86+
fx_enable(fx_find("fxContrast.fs"), 1);
87+
fx_enable(fx_find("fxVignette.fs"), 1);
88+
89+
// demo loop
90+
while (window_swap() && !input_down(KEY_ESC)) {
91+
92+
// handle input
93+
if( input_down(KEY_F5) ) window_reload();
94+
if( input_down(KEY_F11) ) window_fullscreen( !window_has_fullscreen() );
95+
96+
// camera panning (x,y) & zooming (z)
97+
if( !ui_hover() && !ui_active() ) {
98+
if( input(MOUSE_L) ) cam.position.x += input_diff(MOUSE_X);
99+
if( input(MOUSE_L) ) cam.position.y += input_diff(MOUSE_Y);
100+
cam.position.z += input_diff(MOUSE_W) * 0.1;
101+
}
102+
103+
// apply post-fxs from here
104+
fx_begin();
105+
106+
profile("Rendering") {
107+
vec3 center = add3(cam.position,vec3(-window_width()/1,-window_height()/2,0));
108+
// render tiled map
109+
tiled_render(tmx, center);
110+
//
111+
demo_kids(vec3(0,0,1));
112+
demo_hud();
113+
// render spine model
114+
// spine_animate(spn, !window_has_pause() * window_delta());
115+
// spine_render(spn, vec3(cam.position.x, cam.position.y, 1), true );
116+
// sprite_flush();
117+
}
118+
119+
// subtitle sample
120+
font_print(
121+
FONT_BOTTOM FONT_CENTER
122+
FONT_CJK FONT_H1
123+
FONT_YELLOW "私はガラスを食べられます。" FONT_LIME "それは私を傷つけません。\n"
124+
);
125+
126+
// post-fxs end here
127+
fx_end();
128+
129+
// ui
130+
if( ui_panel("Audio", 0)) {
131+
if( ui_label2_toolbar("BGM: Track #1", ICON_MD_VOLUME_UP)) audio_stop(BGM), audio_play(BGM = stream1, AUDIO_SINGLE_INSTANCE);
132+
if( ui_label2_toolbar("BGM: Track #2", ICON_MD_VOLUME_UP)) audio_stop(BGM), audio_play(BGM = stream2, AUDIO_SINGLE_INSTANCE);
133+
if( ui_label2_toolbar("SFX: Coin", ICON_MD_VOLUME_UP)) audio_play(clip1, 0);
134+
if( ui_label2_toolbar("SFX: Pew", ICON_MD_VOLUME_UP)) audio_play(clip2, 0);
135+
ui_panel_end();
136+
}
137+
if( ui_panel("Tiled", 0)) {
138+
ui_float("Zoom in", &cam.position.z);
139+
tiled_ui(&tmx);
140+
ui_panel_end();
141+
}
142+
/*if( ui_panel("Spine", 0)) {
143+
spine_ui(spn);
144+
ui_panel_end();
145+
}*/
146+
}
147+
}
148+
149+
// this demo supersedes following old sources:
150+
// https://github.com/r-lyeh/FWK/blob/45e34d7890b2b8fe1f4994f4b76e496280d83cb6/demos/00-audio.c
151+
// https://github.com/r-lyeh/FWK/blob/45e34d7890b2b8fe1f4994f4b76e496280d83cb6/demos/00-font.c
152+
// https://github.com/r-lyeh/FWK/blob/45e34d7890b2b8fe1f4994f4b76e496280d83cb6/demos/00-spine.c
153+
// https://github.com/r-lyeh/FWK/blob/45e34d7890b2b8fe1f4994f4b76e496280d83cb6/demos/00-sprite.c
154+
// https://github.com/r-lyeh/FWK/blob/45e34d7890b2b8fe1f4994f4b76e496280d83cb6/demos/00-tiled.c
155+
// https://github.com/r-lyeh/FWK/blob/45e34d7890b2b8fe1f4994f4b76e496280d83cb6/demos/00-tilemap.c

2023.10/demos/01-easing.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include "fwk.h"
2+
3+
struct {
4+
float (*ease)(float);
5+
const char *name;
6+
} easings[] = {
7+
{ease_nop, "ease_nop"},
8+
{ease_linear, "ease_linear"},
9+
{ease_out_sine, "ease_out_sine"},
10+
{ease_out_quad, "ease_out_quad"},
11+
{ease_out_cubic, "ease_out_cubic"},
12+
{ease_out_quart, "ease_out_quart"},
13+
{ease_out_quint, "ease_out_quint"},
14+
{ease_out_expo, "ease_out_expo"},
15+
{ease_out_circ, "ease_out_circ"},
16+
{ease_out_back, "ease_out_back"},
17+
{ease_out_elastic, "ease_out_elastic"},
18+
{ease_out_bounce, "ease_out_bounce"},
19+
{ease_in_sine, "ease_in_sine"},
20+
{ease_in_quad, "ease_in_quad"},
21+
{ease_in_cubic, "ease_in_cubic"},
22+
{ease_in_quart, "ease_in_quart"},
23+
{ease_in_quint, "ease_in_quint"},
24+
{ease_in_expo, "ease_in_expo"},
25+
{ease_in_circ, "ease_in_circ"},
26+
{ease_in_back, "ease_in_back"},
27+
{ease_in_elastic, "ease_in_elastic"},
28+
{ease_in_bounce, "ease_in_bounce"},
29+
{ease_inout_sine, "ease_inout_sine"},
30+
{ease_inout_quad, "ease_inout_quad"},
31+
{ease_inout_cubic, "ease_inout_cubic"},
32+
{ease_inout_quart, "ease_inout_quart"},
33+
{ease_inout_quint, "ease_inout_quint"},
34+
{ease_inout_expo, "ease_inout_expo"},
35+
{ease_inout_circ, "ease_inout_circ"},
36+
{ease_inout_back, "ease_inout_back"},
37+
{ease_inout_elastic, "ease_inout_elastic"},
38+
{ease_inout_bounce, "ease_inout_bounce"},
39+
{ease_inout_perlin, "ease_inout_perlin"},
40+
};
41+
42+
int main() {
43+
window_create(0.75, WINDOW_SQUARE);
44+
while(window_swap()) {
45+
static double timer = 0; timer = fmod(timer+window_delta(), 2); // loops every 2s
46+
47+
static int open = 1;
48+
if( ui_window("ease", &open) ) {
49+
float linear_delta = timer / 2.f; // delta is [0..1]
50+
for( int i = 0; i < countof(easings); ++i) {
51+
float nonlinear_delta = easings[i].ease(linear_delta);
52+
// visualize
53+
ui_slider( easings[i].name, &nonlinear_delta );
54+
}
55+
ui_window_end();
56+
}
57+
}
58+
}

2023.10/demos/01-font.c

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#include "fwk.h"
2+
3+
int main() {
4+
window_create(75.0, WINDOW_MSAA8);
5+
6+
// style: our aliases
7+
#define FONT_REGULAR FONT_FACE1
8+
#define FONT_ITALIC FONT_FACE2
9+
#define FONT_BOLD FONT_FACE3
10+
#define FONT_JAPANESE FONT_FACE4
11+
#define FONT_MONOSPACE FONT_FACE5
12+
13+
#define FONT_GRAY FONT_COLOR2
14+
#define FONT_ORANGE FONT_COLOR3
15+
#define FONT_LIME FONT_COLOR4
16+
#define FONT_GREEN FONT_COLOR5
17+
#define FONT_CYAN FONT_COLOR6
18+
19+
#define FONT_LARGEST FONT_H1
20+
#define FONT_LARGE FONT_H2
21+
#define FONT_MEDIUM FONT_H3
22+
#define FONT_NORMAL FONT_H4
23+
#define FONT_SMALL FONT_H5
24+
#define FONT_TINY FONT_H6
25+
26+
// style: atlas size, unicode ranges and font faces (up to 6 faces)
27+
font_face(FONT_REGULAR, "B612""-Regular.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048);
28+
font_face(FONT_ITALIC, "B612""-Italic.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048);
29+
font_face(FONT_BOLD, "B612""-Bold.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048);
30+
font_face(FONT_JAPANESE, "mplus-1p-medium.ttf", 48.f, FONT_JP|FONT_2048); // CJK|FONT_2048|FONT_OVERSAMPLE_Y);
31+
font_face(FONT_MONOSPACE, "B612Mono""-Regular.ttf", 24.f, FONT_EU|FONT_512);
32+
33+
// style: colors (up to 10 colors)
34+
font_color(FONT_GRAY, RGB4(100,100,100,255));
35+
font_color(FONT_ORANGE, RGB4(255,192,0,255));
36+
font_color(FONT_LIME, RGB4(192,255,0,255));
37+
font_color(FONT_GREEN, RGB4(0,255,192,255));
38+
font_color(FONT_CYAN, RGB4(0,192,255,255));
39+
40+
// prepare color highlighting for following code snippet
41+
const char *source =
42+
FONT_MONOSPACE FONT_LARGEST
43+
"int main(int argc, char **argv) {\n"
44+
" for( int i = 0; i < 10; ++i)\n"
45+
" puts(\"hello world\");\n"
46+
" return 0;\n"
47+
"}\n";
48+
const void *colors = font_colorize(source, "void,int,char", "if,else,for,do,while,return,switch,case,break,default,");
49+
50+
// read input file with strings to display
51+
array(char*) lines = 0;
52+
for each_substring( vfs_read("pangrams.txt"), "\r\n", it ) array_push(lines, STRDUP(it));
53+
54+
// demo loop
55+
while( window_swap() && !input(KEY_ESC) ) {
56+
ddraw_grid(0);
57+
58+
// initial spacing
59+
font_goto(0, 50);
60+
61+
// print a code snippet with syntax highlighting
62+
font_highlight(source, colors);
63+
64+
// print a few strings with markup codes
65+
font_print(
66+
FONT_REGULAR
67+
FONT_LARGEST FONT_GRAY "The quick "
68+
FONT_LARGE FONT_LIME "brown "
69+
FONT_MEDIUM FONT_GRAY "fox "
70+
FONT_NORMAL "jumps over "
71+
FONT_SMALL "the lazy "
72+
FONT_TINY "dog.\n");
73+
74+
font_print(
75+
FONT_REGULAR FONT_LARGE FONT_CYAN
76+
"Now is the time for all " FONT_ITALIC "good men " FONT_REGULAR "to come to the aid of " FONT_BOLD "the party.\n");
77+
78+
font_print(
79+
FONT_ITALIC FONT_LARGE FONT_GREEN
80+
"Ég get etið gler án þess að meiða mig!\n");
81+
82+
font_print(
83+
FONT_BOLD FONT_LARGE FONT_ORANGE
84+
"Эх, чужак! Общий съём цен шляп (юфть)—вдрызг!.\n");
85+
86+
font_print(
87+
FONT_JAPANESE
88+
"私はガラスを食べられます。それは私を傷つけません。\n");
89+
90+
font_print( "This text ");
91+
font_print( "should display concatenated, ");
92+
font_print( "as there are no linefeeds.\n" );
93+
94+
// i18n: pangrams.txt file, line browser
95+
static int counter = 0;
96+
counter += input_down(KEY_RIGHT)-input_down(KEY_LEFT);
97+
counter += counter < 0 ? array_count(lines) : 0;
98+
font_print( va("<< %s >>\n", lines[counter % array_count(lines)]) );
99+
100+
// this does not work yet. you cant chain alignments yet...
101+
//font_print(FONT_TOP "Top" FONT_MIDDLE "Middle" FONT_BASELINE "Baseline" FONT_BOTTOM "Bottom\n");
102+
//font_print(FONT_LEFT "Left" FONT_CENTER "Center" FONT_RIGHT "Right\n");
103+
104+
// ... alignment must be the first tag in a string for now. this is a temporary hack.
105+
font_print(FONT_LEFT "left");
106+
font_print(FONT_CENTER "center");
107+
font_print(FONT_RIGHT "right");
108+
109+
font_print(FONT_TOP FONT_CENTER "top\n");
110+
font_print(FONT_MIDDLE FONT_RIGHT "middle\n");
111+
font_print(FONT_BASELINE FONT_RIGHT "baseline\n");
112+
font_print(FONT_BOTTOM FONT_CENTER "bottom\n");
113+
}
114+
}

0 commit comments

Comments
 (0)