Rename GlyphSetA to GlyphSet
This commit is contained in:
parent
3a8cb05ea6
commit
4c6e15b66c
|
@ -13,16 +13,16 @@ struct RenImage {
|
||||||
int width, height;
|
int width, height;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GlyphSetA {
|
struct GlyphSet {
|
||||||
RenImage *image;
|
RenImage *image;
|
||||||
GlyphBitmapInfo glyphs[256];
|
GlyphBitmapInfo glyphs[256];
|
||||||
};
|
};
|
||||||
typedef struct GlyphSetA GlyphSetA;
|
typedef struct GlyphSet GlyphSet;
|
||||||
|
|
||||||
struct RenFont {
|
struct RenFont {
|
||||||
void *data;
|
void *data;
|
||||||
stbtt_fontinfo stbfont;
|
stbtt_fontinfo stbfont;
|
||||||
GlyphSetA *sets[MAX_GLYPHSET];
|
GlyphSet *sets[MAX_GLYPHSET];
|
||||||
float size;
|
float size;
|
||||||
int height;
|
int height;
|
||||||
FontRenderer *renderer;
|
FontRenderer *renderer;
|
||||||
|
@ -108,8 +108,8 @@ void ren_free_image(RenImage *image) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GlyphSetA* load_glyphset(RenFont *font, int idx) {
|
static GlyphSet* load_glyphset(RenFont *font, int idx) {
|
||||||
GlyphSetA *set = check_alloc(calloc(1, sizeof(GlyphSetA)));
|
GlyphSet *set = check_alloc(calloc(1, sizeof(GlyphSet)));
|
||||||
|
|
||||||
/* init image */
|
/* init image */
|
||||||
int width = 128;
|
int width = 128;
|
||||||
|
@ -150,7 +150,7 @@ retry:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GlyphSetA* get_glyphset(RenFont *font, int codepoint) {
|
static GlyphSet* get_glyphset(RenFont *font, int codepoint) {
|
||||||
int idx = (codepoint >> 8) % MAX_GLYPHSET;
|
int idx = (codepoint >> 8) % MAX_GLYPHSET;
|
||||||
if (!font->sets[idx]) {
|
if (!font->sets[idx]) {
|
||||||
font->sets[idx] = load_glyphset(font, idx);
|
font->sets[idx] = load_glyphset(font, idx);
|
||||||
|
@ -211,7 +211,7 @@ fail:
|
||||||
|
|
||||||
void ren_free_font(RenFont *font) {
|
void ren_free_font(RenFont *font) {
|
||||||
for (int i = 0; i < MAX_GLYPHSET; i++) {
|
for (int i = 0; i < MAX_GLYPHSET; i++) {
|
||||||
GlyphSetA *set = font->sets[i];
|
GlyphSet *set = font->sets[i];
|
||||||
if (set) {
|
if (set) {
|
||||||
ren_free_image(set->image);
|
ren_free_image(set->image);
|
||||||
free(set);
|
free(set);
|
||||||
|
@ -223,7 +223,7 @@ void ren_free_font(RenFont *font) {
|
||||||
|
|
||||||
|
|
||||||
void ren_set_font_tab_width(RenFont *font, int n) {
|
void ren_set_font_tab_width(RenFont *font, int n) {
|
||||||
GlyphSetA *set = get_glyphset(font, '\t');
|
GlyphSet *set = get_glyphset(font, '\t');
|
||||||
set->glyphs['\t'].xadvance = n;
|
set->glyphs['\t'].xadvance = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ int ren_get_font_width(RenFont *font, const char *text) {
|
||||||
unsigned codepoint;
|
unsigned codepoint;
|
||||||
while (*p) {
|
while (*p) {
|
||||||
p = utf8_to_codepoint(p, &codepoint);
|
p = utf8_to_codepoint(p, &codepoint);
|
||||||
GlyphSetA *set = get_glyphset(font, codepoint);
|
GlyphSet *set = get_glyphset(font, codepoint);
|
||||||
GlyphBitmapInfo *g = &set->glyphs[codepoint & 0xff];
|
GlyphBitmapInfo *g = &set->glyphs[codepoint & 0xff];
|
||||||
x += g->xadvance;
|
x += g->xadvance;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ int ren_draw_text(RenFont *font, const char *text, int x, int y, RenColor color)
|
||||||
unsigned codepoint;
|
unsigned codepoint;
|
||||||
while (*p) {
|
while (*p) {
|
||||||
p = utf8_to_codepoint(p, &codepoint);
|
p = utf8_to_codepoint(p, &codepoint);
|
||||||
GlyphSetA *set = get_glyphset(font, codepoint);
|
GlyphSet *set = get_glyphset(font, codepoint);
|
||||||
GlyphBitmapInfo *g = &set->glyphs[codepoint & 0xff];
|
GlyphBitmapInfo *g = &set->glyphs[codepoint & 0xff];
|
||||||
rect.x = g->x0;
|
rect.x = g->x0;
|
||||||
rect.y = g->y0;
|
rect.y = g->y0;
|
||||||
|
|
Loading…
Reference in New Issue