gitify last commit
parent
616ade56d7
commit
3008fb5b65
|
@ -2323,6 +2323,12 @@ FONT_TH =2097152,
|
|||
FONT_VI =4194304,
|
||||
FONT_CJK = FONT_ZH|FONT_JP|FONT_KR,
|
||||
};
|
||||
typedef struct font_metrics_t {
|
||||
float ascent;
|
||||
float descent;
|
||||
float linegap;
|
||||
float linedist;
|
||||
} font_metrics_t;
|
||||
void font_face(const char *face_tag, const char *filename_ttf, float font_size, unsigned flags);
|
||||
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);
|
||||
|
@ -2332,6 +2338,7 @@ FONT_CJK = FONT_ZH|FONT_JP|FONT_KR,
|
|||
void font_goto(float x, float y);
|
||||
vec2 font_print(const char *text);
|
||||
vec2 font_rect(const char *text);
|
||||
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);
|
||||
int input_use( int controller_id );
|
||||
|
@ -3342,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,3963)___COUNTER__; typedef struct { unsigned static_assert_on_L__LINE__ : !!(sizeof(sprite_t)); } static_assert_on_Lconcat(_L,3963)___COUNTER__;;
|
||||
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__;;
|
||||
void sprite_ctor(sprite_t *s);
|
||||
void sprite_dtor(sprite_t *s);
|
||||
void sprite_tick(sprite_t *s);
|
||||
|
|
|
@ -16115,6 +16115,13 @@ enum FONT_FLAGS {
|
|||
// FONT_DEFAULTS = FONT_512 | FONT_NO_OVERSAMPLE | FONT_ASCII,
|
||||
};
|
||||
|
||||
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 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;
|
||||
|
||||
// configures
|
||||
API void font_face(const char *face_tag, const char *filename_ttf, float font_size, unsigned flags);
|
||||
API void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
|
||||
|
@ -16127,6 +16134,7 @@ API vec2 font_xy();
|
|||
API void font_goto(float x, float y);
|
||||
API vec2 font_print(const char *text);
|
||||
API vec2 font_rect(const char *text);
|
||||
API font_metrics_t font_metrics(const char *text);
|
||||
// void font_clip(vec2 topleft, vec2 bottomright);
|
||||
// void font_wrap(vec2 topleft, vec2 bottomright);
|
||||
|
||||
|
@ -360722,6 +360730,37 @@ vec2 font_highlight(const char *text, const void *colors) {
|
|||
vec2 font_rect(const char *str) {
|
||||
return font_draw_ex(str, gotoxy, NULL, NULL);
|
||||
}
|
||||
|
||||
font_metrics_t font_metrics(const char *text) {
|
||||
font_metrics_t m={0};
|
||||
int S = 3;
|
||||
font_t *f = &fonts[0];
|
||||
|
||||
// utf8 to utf32
|
||||
array(uint32_t) unicode = string32(text);
|
||||
|
||||
// parse string
|
||||
for( int i = 0, end = array_count(unicode); i < end; ++i ) {
|
||||
uint32_t ch = unicode[i];
|
||||
if( ch >= 1 && ch <= 6 ) {
|
||||
S = ch;
|
||||
continue;
|
||||
}
|
||||
if( ch >= 0x1a && ch <= 0x1f ) {
|
||||
if( fonts[ ch - 0x1a ].initialized) {
|
||||
// change face
|
||||
f = &fonts[ ch - 0x1a ];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
m.ascent = f->ascent*f->factor*f->scale[S];
|
||||
m.descent = f->descent*f->factor*f->scale[S];
|
||||
m.linegap = f->linegap*f->factor*f->scale[S];
|
||||
m.linedist = f->linedist*f->factor*f->scale[S];
|
||||
return m;
|
||||
}
|
||||
#line 0
|
||||
|
||||
#line 1 "v4k_gui.c"
|
||||
|
|
|
@ -2396,3 +2396,34 @@ vec2 font_highlight(const char *text, const void *colors) {
|
|||
vec2 font_rect(const char *str) {
|
||||
return font_draw_ex(str, gotoxy, NULL, NULL);
|
||||
}
|
||||
|
||||
font_metrics_t font_metrics(const char *text) {
|
||||
font_metrics_t m={0};
|
||||
int S = 3;
|
||||
font_t *f = &fonts[0];
|
||||
|
||||
// utf8 to utf32
|
||||
array(uint32_t) unicode = string32(text);
|
||||
|
||||
// parse string
|
||||
for( int i = 0, end = array_count(unicode); i < end; ++i ) {
|
||||
uint32_t ch = unicode[i];
|
||||
if( ch >= 1 && ch <= 6 ) {
|
||||
S = ch;
|
||||
continue;
|
||||
}
|
||||
if( ch >= 0x1a && ch <= 0x1f ) {
|
||||
if( fonts[ ch - 0x1a ].initialized) {
|
||||
// change face
|
||||
f = &fonts[ ch - 0x1a ];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
m.ascent = f->ascent*f->factor*f->scale[S];
|
||||
m.descent = f->descent*f->factor*f->scale[S];
|
||||
m.linegap = f->linegap*f->factor*f->scale[S];
|
||||
m.linedist = f->linedist*f->factor*f->scale[S];
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,13 @@ enum FONT_FLAGS {
|
|||
// FONT_DEFAULTS = FONT_512 | FONT_NO_OVERSAMPLE | FONT_ASCII,
|
||||
};
|
||||
|
||||
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 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;
|
||||
|
||||
// configures
|
||||
API void font_face(const char *face_tag, const char *filename_ttf, float font_size, unsigned flags);
|
||||
API void font_face_from_mem(const char *tag, const void *ttf_buffer, unsigned ttf_len, float font_size, unsigned flags);
|
||||
|
@ -82,6 +89,7 @@ API vec2 font_xy();
|
|||
API void font_goto(float x, float y);
|
||||
API vec2 font_print(const char *text);
|
||||
API vec2 font_rect(const char *text);
|
||||
API font_metrics_t font_metrics(const char *text);
|
||||
// void font_clip(vec2 topleft, vec2 bottomright);
|
||||
// void font_wrap(vec2 topleft, vec2 bottomright);
|
||||
|
||||
|
|
Loading…
Reference in New Issue