This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: TTF support, S3M/IT support, revisit MOD/XM/FLAC,
new: font_face(), font_scales(), font_color(), font atlases, font ranges, --debug-font-atlas, new: camera_enable(), --with-camera-smooth new: .glb models, RELEASE/OPTIMIZE/O_FLAG directives, sort_u64(), new: VIDEO_RGB, VIDEO_NO_AUDIO, video_textures(), new: sponza model, shaderball model for upcoming materials demo, fix: reduce font atlas occupancy, simplify each_array(), bugfix array_unique(), each_set(), each_set_ptr(), del: MOD/XM/FLAC decoders, ren: sprite_update() > sprite_flush(), viewport_color() > viewport_color3(), --cook-jobs=N > --with-jobs=N
- Loading branch information
Showing
81 changed files
with
168,493 additions
and
9,897 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#include "fwk.h" | ||
|
||
int main() { | ||
window_create(0.75, WINDOW_MSAA8); | ||
|
||
// style: our aliases | ||
#define FONT_REGULAR FONT_FACE1 | ||
#define FONT_ITALIC FONT_FACE2 | ||
#define FONT_BOLD FONT_FACE3 | ||
#define FONT_JAPANESE FONT_FACE4 | ||
#define FONT_MONOSPACE FONT_FACE5 | ||
|
||
#define FONT_GRAY FONT_COLOR2 | ||
#define FONT_ORANGE FONT_COLOR3 | ||
#define FONT_LIME FONT_COLOR4 | ||
#define FONT_GREEN FONT_COLOR5 | ||
#define FONT_CYAN FONT_COLOR6 | ||
|
||
#define FONT_LARGEST FONT_H1 | ||
#define FONT_LARGE FONT_H2 | ||
#define FONT_MEDIUM FONT_H3 | ||
#define FONT_NORMAL FONT_H4 | ||
#define FONT_SMALL FONT_H5 | ||
#define FONT_TINY FONT_H6 | ||
|
||
// style: atlas size, unicode ranges and font faces (up to 6 faces) | ||
font_face(FONT_REGULAR, "Carlito-Regular.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048); | ||
font_face(FONT_ITALIC, "Carlito-Italic.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048); | ||
font_face(FONT_BOLD, "Carlito-Bold.ttf", 48.f, FONT_EU|FONT_AR|FONT_RU|FONT_2048); | ||
font_face(FONT_JAPANESE, "mplus-1p-medium.ttf", 48.f, FONT_JP|FONT_2048); // CJK|FONT_2048|FONT_OVERSAMPLE_Y); | ||
font_face(FONT_MONOSPACE, "Inconsolata-Regular.ttf", 24.f, FONT_EU|FONT_512); | ||
|
||
// style: colors (up to 10 colors) | ||
font_color(FONT_GRAY, RGB4(100,100,100,255)); | ||
font_color(FONT_ORANGE, RGB4(255,192,0,255)); | ||
font_color(FONT_LIME, RGB4(192,255,0,255)); | ||
font_color(FONT_GREEN, RGB4(0,255,192,255)); | ||
font_color(FONT_CYAN, RGB4(0,192,255,255)); | ||
|
||
// prepare color highlighting for following code snippet | ||
const char *source = | ||
FONT_MONOSPACE FONT_LARGEST | ||
"int main(int argc, char **argv) {\n" | ||
" for( int i = 0; i < 10; ++i)\n" | ||
" puts(\"hello world\");\n" | ||
" return 0;\n" | ||
"}\n"; | ||
const void *colors = font_colorize(source, "void,int,char", "if,else,for,do,while,return,switch,case,break,default,"); | ||
|
||
// demo loop | ||
while( window_swap() && !input(KEY_ESC) ) { | ||
ddraw_grid(0); | ||
|
||
// initial spacing | ||
font_goto(0, 50); | ||
|
||
// print a code snippet with syntax highlighting | ||
font_highlight(source, colors); | ||
|
||
// print a few strings with markup codes | ||
font_print( | ||
FONT_REGULAR | ||
FONT_LARGEST FONT_GRAY "The quick " | ||
FONT_LARGE FONT_LIME "brown " | ||
FONT_MEDIUM FONT_GRAY "fox " | ||
FONT_NORMAL "jumps over " | ||
FONT_SMALL "the lazy " | ||
FONT_TINY "dog.\n"); | ||
|
||
font_print( | ||
FONT_REGULAR FONT_LARGE FONT_CYAN | ||
"Now is the time for all " FONT_ITALIC "good men " FONT_REGULAR "to come to the aid of " FONT_BOLD "the party.\n"); | ||
|
||
font_print( | ||
FONT_ITALIC FONT_LARGE FONT_GREEN | ||
"Ég get etið gler án þess að meiða mig!\n"); | ||
|
||
font_print( | ||
FONT_BOLD FONT_LARGE FONT_ORANGE | ||
"Эх, чужак! Общий съём цен шляп (юфть)—вдрызг!.\n"); | ||
|
||
font_print( | ||
FONT_JAPANESE | ||
"私はガラスを食べられます。それは私を傷つけません。\n"); | ||
|
||
font_print( "This text "); | ||
font_print( "should be concatenated, "); | ||
font_print( "as there are no linefeeds.\n" ); | ||
|
||
// i18n: pangrams.txt file, line browser | ||
static int counter; | ||
static array(char*) lines; do_once lines = strsplit( vfs_read("pangrams.txt"), "\r\n" ); | ||
counter += (counter += input_down(KEY_RIGHT)-input_down(KEY_LEFT)) < 0 ? array_count(lines) : 0; | ||
font_print( stringf("<< %s >>\n", lines[counter % array_count(lines)]) ); | ||
|
||
// this does not work yet. you cant chain alignments yet... | ||
//font_print(FONT_TOP "Top" FONT_MIDDLE "Middle" FONT_BASELINE "Baseline" FONT_BOTTOM "Bottom\n"); | ||
//font_print(FONT_LEFT "Left" FONT_CENTER "Center" FONT_RIGHT "Right\n"); | ||
|
||
// ... alignment must be the first tag in a string for now. this is a temporary hack. | ||
font_print(FONT_LEFT "left"); | ||
font_print(FONT_CENTER "center"); | ||
font_print(FONT_RIGHT "right"); | ||
|
||
font_print(FONT_TOP FONT_CENTER "top\n"); | ||
font_print(FONT_MIDDLE FONT_RIGHT "middle\n"); | ||
font_print(FONT_BASELINE FONT_RIGHT "baseline\n"); | ||
font_print(FONT_BOTTOM FONT_CENTER "bottom\n"); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.