main
Dominik Madarász 2023-12-12 10:15:19 +01:00
parent 22d3929b19
commit 427c957e49
8 changed files with 161 additions and 137 deletions

View File

@ -2333,7 +2333,6 @@ float linedist;
void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
void font_scales(const char *face_tag, float h1, float h2, float h3, float h4, float h5, float h6);
void font_color(const char *color_tag, uint32_t color);
void ui_font();
vec2 font_xy();
void font_goto(float x, float y);
vec2 font_print(const char *text);
@ -2341,6 +2340,7 @@ float linedist;
font_metrics_t font_metrics(const char *text);
void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords);
vec2 font_highlight(const char *text, const void *colors);
void ui_font();
int input_use( int controller_id );
float input( int vk );
vec2 input2( int vk );
@ -3349,7 +3349,7 @@ unsigned play;
bool paused;
struct atlas_t *a;
} sprite_t;
enum { OBJTYPE_sprite_t = 10 }; typedef struct { unsigned static_assert_on_L__LINE__ : !!(10 <= 255); } static_assert_on_Lconcat(_L,3971)___COUNTER__; typedef struct { unsigned static_assert_on_L__LINE__ : !!(sizeof(sprite_t)); } static_assert_on_Lconcat(_L,3971)___COUNTER__;;
enum { OBJTYPE_sprite_t = 10 }; typedef struct { unsigned static_assert_on_L__LINE__ : !!(10 <= 255); } static_assert_on_Lconcat(_L,3973)___COUNTER__; typedef struct { unsigned static_assert_on_L__LINE__ : !!(sizeof(sprite_t)); } static_assert_on_Lconcat(_L,3973)___COUNTER__;;
void sprite_ctor(sprite_t *s);
void sprite_dtor(sprite_t *s);
void sprite_tick(sprite_t *s);

View File

@ -35,8 +35,8 @@ int main() {
// font
do_once font_face(FONT_FACE2, "lilita_one_regular.ttf", 48.0f, FONT_EU | FONT_2048);
do_once font_color(FONT_COLOR9, WHITE);
font_print(va(FONT_MIDDLE FONT_CENTER FONT_FACE2 FONT_COLOR9 "%s", "Hello"));
do_once font_color(FONT_COLOR6, WHITE);
font_print(va(FONT_MIDDLE FONT_CENTER FONT_FACE2 FONT_COLOR6 "%s", "Hello"));
// background
vec4 panel_pos = vec4(0, 0, window_width(), window_height());

View File

@ -16056,24 +16056,24 @@ API bool ini_write(const char *filename, const char *section, const char
#define FONT_H6 "\6" // smallest
// font color tags
#define FONT_COLOR1 "\x10"
#define FONT_COLOR2 "\x11"
#define FONT_COLOR3 "\x12"
#define FONT_COLOR4 "\x13"
#define FONT_COLOR5 "\x14"
#define FONT_COLOR6 "\x15"
#define FONT_COLOR7 "\x16"
#define FONT_COLOR8 "\x17"
#define FONT_COLOR9 "\x18"
#define FONT_COLOR10 "\x19"
#define FONT_COLOR1 "\x1a"
#define FONT_COLOR2 "\x1b"
#define FONT_COLOR3 "\x1c"
#define FONT_COLOR4 "\x1d"
#define FONT_COLOR5 "\x1e"
#define FONT_COLOR6 "\x1f"
// font face tags
#define FONT_FACE1 "\x1a"
#define FONT_FACE2 "\x1b"
#define FONT_FACE3 "\x1c"
#define FONT_FACE4 "\x1d"
#define FONT_FACE5 "\x1e"
#define FONT_FACE6 "\x1f"
#define FONT_FACE1 "\x10"
#define FONT_FACE2 "\x11"
#define FONT_FACE3 "\x12"
#define FONT_FACE4 "\x13"
#define FONT_FACE5 "\x14"
#define FONT_FACE6 "\x15"
#define FONT_FACE7 "\x16"
#define FONT_FACE8 "\x17" // editor may override this one
#define FONT_FACE9 "\x18" // editor may override this one
#define FONT_FACE10 "\x19" // editor may override this one
// font align tags
#define FONT_LEFT "\\<"
@ -16118,7 +16118,7 @@ enum FONT_FLAGS {
typedef struct font_metrics_t {
float ascent; // max distance above baseline for all glyphs
float descent; // max distance below baseline for all glyphs
float linegap; // distance between ascent of next line and descent of current line
float linegap; // distance betwen ascent of next line and descent of current line
float linedist; // distance between the baseline of two lines (ascent - descent + linegap)
} font_metrics_t;
@ -16127,7 +16127,6 @@ API void font_face(const char *face_tag, const char *filename_ttf, float font_s
API void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
API void font_scales(const char *face_tag, float h1, float h2, float h3, float h4, float h5, float h6);
API void font_color(const char *color_tag, uint32_t color);
API void ui_font();
// commands
API vec2 font_xy();
@ -16141,6 +16140,9 @@ API font_metrics_t font_metrics(const char *text);
// syntax highlighting
API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result.
API vec2 font_highlight(const char *text, const void *colors);
// ui
API void ui_font();
#line 0
#line 1 "v4k_input.h"
@ -359948,7 +359950,9 @@ typedef struct font_t {
GLuint vbo_instances; // vec4: (char_pos_x, char_pos_y, char_index, color_index)
} font_t;
static font_t fonts[8] = {0};
enum { FONTS_MAX = 10 };
static font_t fonts[FONTS_MAX] = {0};
static
void font_init() {
@ -359959,6 +359963,10 @@ void font_init() {
font_face_from_mem(FONT_FACE4, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE5, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE6, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE7, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE8, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE9, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE10,bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
}
}
@ -359970,7 +359978,7 @@ void font_color(const char *tag, uint32_t color) {
if( index < FONT_MAX_COLORS ) {
font_palette[index] = color;
for( int i = 0; i < 8; ++i ) {
for( int i = 0; i < FONTS_MAX; ++i ) {
font_t *f = &fonts[i];
if( f->initialized ) {
glActiveTexture(GL_TEXTURE2);
@ -359998,7 +360006,7 @@ void font_scales(const char *tag, float h1, float h2, float h3, float h4, float
font_init();
unsigned index = *tag - FONT_FACE1[0];
if( index >= 8 ) return;
if( index > FONTS_MAX ) return;
font_t *f = &fonts[index];
if (!f->initialized) return;
@ -360018,7 +360026,7 @@ void font_scales(const char *tag, float h1, float h2, float h3, float h4, float
// 1. Calculate and save a bunch of useful variables and put them in the global font variable.
void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len, float font_size, unsigned flags) {
unsigned index = *tag - FONT_FACE1[0];
if( index >= 8 ) return;
if( index > FONTS_MAX ) return;
if( font_size <= 0 || font_size > 72 ) return;
if( !ttf_data || !ttf_len ) return;
@ -360369,8 +360377,8 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
}
// pre-init
static __thread float *text_glyph_data, **init = 0;
if(!init) *(init = &text_glyph_data) = (float*)MALLOC(4 * FONT_MAX_STRING_LEN * sizeof(float));
static __thread float *text_glyph_data;
do_once text_glyph_data = MALLOC(4 * FONT_MAX_STRING_LEN * sizeof(float));
// ready
font_t *f = &fonts[0];
@ -360412,18 +360420,18 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
if(L > LL) LL = L;
continue;
}
if( ch >= 0x10 && ch <= 0x19 ) {
color = ch - 0x10;
if( ch >= 0x1a && ch <= 0x1f ) {
color = ch - 0x1a;
continue;
}
if( ch >= 0x1a && ch <= 0x1f ) {
if( fonts[ ch - 0x1a ].initialized) {
if( ch >= 0x10 && ch <= 0x19 ) {
if( fonts[ ch - 0x10 ].initialized) {
// flush previous state
if(draw_cmd) draw_cmd(f, text_glyph_data, (t - text_glyph_data)/4, f->scale[S], offset);
t = text_glyph_data;
// change face
f = &fonts[ ch - 0x1a ];
f = &fonts[ ch - 0x10 ];
}
continue;
}
@ -379425,11 +379433,11 @@ void editor_setmouse(int x, int y) {
vec2 editor_glyph(int x, int y, const char *style, unsigned codepoint) {
do_once {
// style: atlas size, unicode ranges and 6 font faces max
font_face(FONT_FACE2, "B612-Regular.ttf", 12.f, 0);
font_face(FONT_FACE3, "MaterialIconsSharp-Regular.otf", 24.f, FONT_EM|FONT_2048);
font_face(FONT_FACE4, "materialdesignicons-webfont.ttf", 24.f, FONT_EM|FONT_2048); // {0xF68C /*ICON_MDI_MIN*/, 0xF1CC7/*ICON_MDI_MAX*/, 0}},
// style: 10 colors max
// style: atlas size, unicode ranges and 3 font faces max
font_face(FONT_FACE10, "B612-Regular.ttf", 12.f, 0);
font_face(FONT_FACE9, "MaterialIconsSharp-Regular.otf", 24.f, FONT_EM|FONT_2048);
font_face(FONT_FACE8, "materialdesignicons-webfont.ttf", 24.f, FONT_EM|FONT_2048); // {0xF68C /*ICON_MDI_MIN*/, 0xF1CC7/*ICON_MDI_MAX*/, 0}},
// style: 5 colors max
font_color(FONT_COLOR1, WHITE);
font_color(FONT_COLOR2, RGBX(0xE8F1FF,128)); // GRAY);
font_color(FONT_COLOR3, YELLOW);
@ -379440,7 +379448,7 @@ vec2 editor_glyph(int x, int y, const char *style, unsigned codepoint) {
font_goto(x,y);
vec2 pos = {x,y};
const char *sym = codepoint_to_utf8(codepoint);
return add2(pos, font_print(va("%s%s%s", style ? style : "", codepoint >= ICON_MDI_MIN ? FONT_FACE4 : codepoint >= ICON_MD_MIN ? FONT_FACE3 : FONT_FACE2, sym)));
return add2(pos, font_print(va("%s%s%s", style ? style : "", codepoint >= ICON_MDI_MIN ? FONT_FACE8 : codepoint >= ICON_MD_MIN ? FONT_FACE9 : FONT_FACE10, sym)));
}
vec2 editor_glyphs(int x, int y, const char *style, const char *utf8) {

View File

@ -513,11 +513,11 @@ void editor_setmouse(int x, int y) {
vec2 editor_glyph(int x, int y, const char *style, unsigned codepoint) {
do_once {
// style: atlas size, unicode ranges and 6 font faces max
font_face(FONT_FACE2, "B612-Regular.ttf", 12.f, 0);
font_face(FONT_FACE3, "MaterialIconsSharp-Regular.otf", 24.f, FONT_EM|FONT_2048);
font_face(FONT_FACE4, "materialdesignicons-webfont.ttf", 24.f, FONT_EM|FONT_2048); // {0xF68C /*ICON_MDI_MIN*/, 0xF1CC7/*ICON_MDI_MAX*/, 0}},
// style: 10 colors max
// style: atlas size, unicode ranges and 3 font faces max
font_face(FONT_FACE10, "B612-Regular.ttf", 12.f, 0);
font_face(FONT_FACE9, "MaterialIconsSharp-Regular.otf", 24.f, FONT_EM|FONT_2048);
font_face(FONT_FACE8, "materialdesignicons-webfont.ttf", 24.f, FONT_EM|FONT_2048); // {0xF68C /*ICON_MDI_MIN*/, 0xF1CC7/*ICON_MDI_MAX*/, 0}},
// style: 5 colors max
font_color(FONT_COLOR1, WHITE);
font_color(FONT_COLOR2, RGBX(0xE8F1FF,128)); // GRAY);
font_color(FONT_COLOR3, YELLOW);
@ -528,7 +528,7 @@ vec2 editor_glyph(int x, int y, const char *style, unsigned codepoint) {
font_goto(x,y);
vec2 pos = {x,y};
const char *sym = codepoint_to_utf8(codepoint);
return add2(pos, font_print(va("%s%s%s", style ? style : "", codepoint >= ICON_MDI_MIN ? FONT_FACE4 : codepoint >= ICON_MD_MIN ? FONT_FACE3 : FONT_FACE2, sym)));
return add2(pos, font_print(va("%s%s%s", style ? style : "", codepoint >= ICON_MDI_MIN ? FONT_FACE8 : codepoint >= ICON_MD_MIN ? FONT_FACE9 : FONT_FACE10, sym)));
}
vec2 editor_glyphs(int x, int y, const char *style, const char *utf8) {

View File

@ -1614,7 +1614,9 @@ typedef struct font_t {
GLuint vbo_instances; // vec4: (char_pos_x, char_pos_y, char_index, color_index)
} font_t;
static font_t fonts[8] = {0};
enum { FONTS_MAX = 10 };
static font_t fonts[FONTS_MAX] = {0};
static
void font_init() {
@ -1625,6 +1627,10 @@ void font_init() {
font_face_from_mem(FONT_FACE4, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE5, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE6, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE7, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE8, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE9, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE10,bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
}
}
@ -1636,7 +1642,7 @@ void font_color(const char *tag, uint32_t color) {
if( index < FONT_MAX_COLORS ) {
font_palette[index] = color;
for( int i = 0; i < 8; ++i ) {
for( int i = 0; i < FONTS_MAX; ++i ) {
font_t *f = &fonts[i];
if( f->initialized ) {
glActiveTexture(GL_TEXTURE2);
@ -1664,7 +1670,7 @@ void font_scales(const char *tag, float h1, float h2, float h3, float h4, float
font_init();
unsigned index = *tag - FONT_FACE1[0];
if( index >= 8 ) return;
if( index > FONTS_MAX ) return;
font_t *f = &fonts[index];
if (!f->initialized) return;
@ -1684,7 +1690,7 @@ void font_scales(const char *tag, float h1, float h2, float h3, float h4, float
// 1. Calculate and save a bunch of useful variables and put them in the global font variable.
void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len, float font_size, unsigned flags) {
unsigned index = *tag - FONT_FACE1[0];
if( index >= 8 ) return;
if( index > FONTS_MAX ) return;
if( font_size <= 0 || font_size > 72 ) return;
if( !ttf_data || !ttf_len ) return;
@ -2035,8 +2041,8 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
}
// pre-init
static __thread float *text_glyph_data, **init = 0;
if(!init) *(init = &text_glyph_data) = (float*)MALLOC(4 * FONT_MAX_STRING_LEN * sizeof(float));
static __thread float *text_glyph_data;
do_once text_glyph_data = MALLOC(4 * FONT_MAX_STRING_LEN * sizeof(float));
// ready
font_t *f = &fonts[0];
@ -2078,18 +2084,18 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
if(L > LL) LL = L;
continue;
}
if( ch >= 0x10 && ch <= 0x19 ) {
color = ch - 0x10;
if( ch >= 0x1a && ch <= 0x1f ) {
color = ch - 0x1a;
continue;
}
if( ch >= 0x1a && ch <= 0x1f ) {
if( fonts[ ch - 0x1a ].initialized) {
if( ch >= 0x10 && ch <= 0x19 ) {
if( fonts[ ch - 0x10 ].initialized) {
// flush previous state
if(draw_cmd) draw_cmd(f, text_glyph_data, (t - text_glyph_data)/4, f->scale[S], offset);
t = text_glyph_data;
// change face
f = &fonts[ ch - 0x1a ];
f = &fonts[ ch - 0x10 ];
}
continue;
}

View File

@ -11,24 +11,24 @@
#define FONT_H6 "\6" // smallest
// font color tags
#define FONT_COLOR1 "\x10"
#define FONT_COLOR2 "\x11"
#define FONT_COLOR3 "\x12"
#define FONT_COLOR4 "\x13"
#define FONT_COLOR5 "\x14"
#define FONT_COLOR6 "\x15"
#define FONT_COLOR7 "\x16"
#define FONT_COLOR8 "\x17"
#define FONT_COLOR9 "\x18"
#define FONT_COLOR10 "\x19"
#define FONT_COLOR1 "\x1a"
#define FONT_COLOR2 "\x1b"
#define FONT_COLOR3 "\x1c"
#define FONT_COLOR4 "\x1d"
#define FONT_COLOR5 "\x1e"
#define FONT_COLOR6 "\x1f"
// font face tags
#define FONT_FACE1 "\x1a"
#define FONT_FACE2 "\x1b"
#define FONT_FACE3 "\x1c"
#define FONT_FACE4 "\x1d"
#define FONT_FACE5 "\x1e"
#define FONT_FACE6 "\x1f"
#define FONT_FACE1 "\x10"
#define FONT_FACE2 "\x11"
#define FONT_FACE3 "\x12"
#define FONT_FACE4 "\x13"
#define FONT_FACE5 "\x14"
#define FONT_FACE6 "\x15"
#define FONT_FACE7 "\x16"
#define FONT_FACE8 "\x17" // editor may override this one
#define FONT_FACE9 "\x18" // editor may override this one
#define FONT_FACE10 "\x19" // editor may override this one
// font align tags
#define FONT_LEFT "\\<"
@ -73,7 +73,7 @@ enum FONT_FLAGS {
typedef struct font_metrics_t {
float ascent; // max distance above baseline for all glyphs
float descent; // max distance below baseline for all glyphs
float linegap; // distance between ascent of next line and descent of current line
float linegap; // distance betwen ascent of next line and descent of current line
float linedist; // distance between the baseline of two lines (ascent - descent + linegap)
} font_metrics_t;
@ -82,7 +82,6 @@ API void font_face(const char *face_tag, const char *filename_ttf, float font_s
API void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
API void font_scales(const char *face_tag, float h1, float h2, float h3, float h4, float h5, float h6);
API void font_color(const char *color_tag, uint32_t color);
API void ui_font();
// commands
API vec2 font_xy();
@ -96,3 +95,6 @@ API font_metrics_t font_metrics(const char *text);
// syntax highlighting
API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result.
API vec2 font_highlight(const char *text, const void *colors);
// ui
API void ui_font();

View File

@ -10268,7 +10268,9 @@ typedef struct font_t {
GLuint vbo_instances; // vec4: (char_pos_x, char_pos_y, char_index, color_index)
} font_t;
static font_t fonts[8] = {0};
enum { FONTS_MAX = 10 };
static font_t fonts[FONTS_MAX] = {0};
static
void font_init() {
@ -10279,6 +10281,10 @@ void font_init() {
font_face_from_mem(FONT_FACE4, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE5, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE6, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE7, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE8, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE9, bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
font_face_from_mem(FONT_FACE10,bm_mini_ttf,countof(bm_mini_ttf), 42.5f, 0);
}
}
@ -10290,7 +10296,7 @@ void font_color(const char *tag, uint32_t color) {
if( index < FONT_MAX_COLORS ) {
font_palette[index] = color;
for( int i = 0; i < 8; ++i ) {
for( int i = 0; i < FONTS_MAX; ++i ) {
font_t *f = &fonts[i];
if( f->initialized ) {
glActiveTexture(GL_TEXTURE2);
@ -10318,7 +10324,7 @@ void font_scales(const char *tag, float h1, float h2, float h3, float h4, float
font_init();
unsigned index = *tag - FONT_FACE1[0];
if( index >= 8 ) return;
if( index > FONTS_MAX ) return;
font_t *f = &fonts[index];
if (!f->initialized) return;
@ -10338,7 +10344,7 @@ void font_scales(const char *tag, float h1, float h2, float h3, float h4, float
// 1. Calculate and save a bunch of useful variables and put them in the global font variable.
void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len, float font_size, unsigned flags) {
unsigned index = *tag - FONT_FACE1[0];
if( index >= 8 ) return;
if( index > FONTS_MAX ) return;
if( font_size <= 0 || font_size > 72 ) return;
if( !ttf_data || !ttf_len ) return;
@ -10689,8 +10695,8 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
}
// pre-init
static __thread float *text_glyph_data, **init = 0;
if(!init) *(init = &text_glyph_data) = (float*)MALLOC(4 * FONT_MAX_STRING_LEN * sizeof(float));
static __thread float *text_glyph_data;
do_once text_glyph_data = MALLOC(4 * FONT_MAX_STRING_LEN * sizeof(float));
// ready
font_t *f = &fonts[0];
@ -10732,18 +10738,18 @@ vec2 font_draw_ex(const char *text, vec2 offset, const char *col, void (*draw_cm
if(L > LL) LL = L;
continue;
}
if( ch >= 0x10 && ch <= 0x19 ) {
color = ch - 0x10;
if( ch >= 0x1a && ch <= 0x1f ) {
color = ch - 0x1a;
continue;
}
if( ch >= 0x1a && ch <= 0x1f ) {
if( fonts[ ch - 0x1a ].initialized) {
if( ch >= 0x10 && ch <= 0x19 ) {
if( fonts[ ch - 0x10 ].initialized) {
// flush previous state
if(draw_cmd) draw_cmd(f, text_glyph_data, (t - text_glyph_data)/4, f->scale[S], offset);
t = text_glyph_data;
// change face
f = &fonts[ ch - 0x1a ];
f = &fonts[ ch - 0x10 ];
}
continue;
}
@ -29745,11 +29751,11 @@ void editor_setmouse(int x, int y) {
vec2 editor_glyph(int x, int y, const char *style, unsigned codepoint) {
do_once {
// style: atlas size, unicode ranges and 6 font faces max
font_face(FONT_FACE2, "B612-Regular.ttf", 12.f, 0);
font_face(FONT_FACE3, "MaterialIconsSharp-Regular.otf", 24.f, FONT_EM|FONT_2048);
font_face(FONT_FACE4, "materialdesignicons-webfont.ttf", 24.f, FONT_EM|FONT_2048); // {0xF68C /*ICON_MDI_MIN*/, 0xF1CC7/*ICON_MDI_MAX*/, 0}},
// style: 10 colors max
// style: atlas size, unicode ranges and 3 font faces max
font_face(FONT_FACE10, "B612-Regular.ttf", 12.f, 0);
font_face(FONT_FACE9, "MaterialIconsSharp-Regular.otf", 24.f, FONT_EM|FONT_2048);
font_face(FONT_FACE8, "materialdesignicons-webfont.ttf", 24.f, FONT_EM|FONT_2048); // {0xF68C /*ICON_MDI_MIN*/, 0xF1CC7/*ICON_MDI_MAX*/, 0}},
// style: 5 colors max
font_color(FONT_COLOR1, WHITE);
font_color(FONT_COLOR2, RGBX(0xE8F1FF,128)); // GRAY);
font_color(FONT_COLOR3, YELLOW);
@ -29760,7 +29766,7 @@ vec2 editor_glyph(int x, int y, const char *style, unsigned codepoint) {
font_goto(x,y);
vec2 pos = {x,y};
const char *sym = codepoint_to_utf8(codepoint);
return add2(pos, font_print(va("%s%s%s", style ? style : "", codepoint >= ICON_MDI_MIN ? FONT_FACE4 : codepoint >= ICON_MD_MIN ? FONT_FACE3 : FONT_FACE2, sym)));
return add2(pos, font_print(va("%s%s%s", style ? style : "", codepoint >= ICON_MDI_MIN ? FONT_FACE8 : codepoint >= ICON_MD_MIN ? FONT_FACE9 : FONT_FACE10, sym)));
}
vec2 editor_glyphs(int x, int y, const char *style, const char *utf8) {

View File

@ -2123,24 +2123,24 @@ API bool ini_write(const char *filename, const char *section, const char
#define FONT_H6 "\6" // smallest
// font color tags
#define FONT_COLOR1 "\x10"
#define FONT_COLOR2 "\x11"
#define FONT_COLOR3 "\x12"
#define FONT_COLOR4 "\x13"
#define FONT_COLOR5 "\x14"
#define FONT_COLOR6 "\x15"
#define FONT_COLOR7 "\x16"
#define FONT_COLOR8 "\x17"
#define FONT_COLOR9 "\x18"
#define FONT_COLOR10 "\x19"
#define FONT_COLOR1 "\x1a"
#define FONT_COLOR2 "\x1b"
#define FONT_COLOR3 "\x1c"
#define FONT_COLOR4 "\x1d"
#define FONT_COLOR5 "\x1e"
#define FONT_COLOR6 "\x1f"
// font face tags
#define FONT_FACE1 "\x1a"
#define FONT_FACE2 "\x1b"
#define FONT_FACE3 "\x1c"
#define FONT_FACE4 "\x1d"
#define FONT_FACE5 "\x1e"
#define FONT_FACE6 "\x1f"
#define FONT_FACE1 "\x10"
#define FONT_FACE2 "\x11"
#define FONT_FACE3 "\x12"
#define FONT_FACE4 "\x13"
#define FONT_FACE5 "\x14"
#define FONT_FACE6 "\x15"
#define FONT_FACE7 "\x16"
#define FONT_FACE8 "\x17" // editor may override this one
#define FONT_FACE9 "\x18" // editor may override this one
#define FONT_FACE10 "\x19" // editor may override this one
// font align tags
#define FONT_LEFT "\\<"
@ -2185,7 +2185,7 @@ enum FONT_FLAGS {
typedef struct font_metrics_t {
float ascent; // max distance above baseline for all glyphs
float descent; // max distance below baseline for all glyphs
float linegap; // distance between ascent of next line and descent of current line
float linegap; // distance betwen ascent of next line and descent of current line
float linedist; // distance between the baseline of two lines (ascent - descent + linegap)
} font_metrics_t;
@ -2194,7 +2194,6 @@ API void font_face(const char *face_tag, const char *filename_ttf, float font_s
API void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
API void font_scales(const char *face_tag, float h1, float h2, float h3, float h4, float h5, float h6);
API void font_color(const char *color_tag, uint32_t color);
API void ui_font();
// commands
API vec2 font_xy();
@ -2208,6 +2207,9 @@ API font_metrics_t font_metrics(const char *text);
// syntax highlighting
API void* font_colorize(const char *text, const char *comma_types, const char *comma_keywords); // comma separated tokens. expensive, please cache result.
API vec2 font_highlight(const char *text, const void *colors);
// ui
API void ui_font();
#line 0
#line 1 "v4k_input.h"