diff options
Diffstat (limited to 'platform/gl/gl-font.c')
-rw-r--r-- | platform/gl/gl-font.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/platform/gl/gl-font.c b/platform/gl/gl-font.c index 3b7c3e77..b286d8a6 100644 --- a/platform/gl/gl-font.c +++ b/platform/gl/gl-font.c @@ -29,6 +29,7 @@ struct key { fz_font *font; + float size; short gid; unsigned char subx; unsigned char suby; @@ -56,7 +57,6 @@ static int g_cache_row_x = 0; static int g_cache_row_h = 0; static fz_font *g_font = NULL; -static float g_font_size = 16; static void clear_font_cache(void) { @@ -76,7 +76,7 @@ static void clear_font_cache(void) g_cache_row_h = 0; } -void ui_init_fonts(float pixelsize) +void ui_init_fonts(void) { const unsigned char *data; int size; @@ -95,7 +95,6 @@ void ui_init_fonts(float pixelsize) if (!data) data = fz_lookup_builtin_font(ctx, "Times", 0, 0, &size); g_font = fz_new_font_from_memory(ctx, NULL, data, size, 0, 0); - g_font_size = pixelsize; } void ui_finish_fonts(void) @@ -127,7 +126,7 @@ static unsigned int lookup_table(struct key *key) } } -static struct glyph *lookup_glyph(fz_font *font, int gid, float *xp, float *yp) +static struct glyph *lookup_glyph(fz_font *font, float size, int gid, float *xp, float *yp) { fz_matrix trm, subpix_trm; unsigned char subx, suby; @@ -137,7 +136,7 @@ static struct glyph *lookup_glyph(fz_font *font, int gid, float *xp, float *yp) int w, h; /* match fitz's glyph cache quantization */ - trm = fz_scale(g_font_size, -g_font_size); + trm = fz_scale(size, -size); trm.e = *xp; trm.f = *yp; fz_subpixel_adjust(ctx, &trm, &subpix_trm, &subx, &suby); @@ -150,6 +149,7 @@ static struct glyph *lookup_glyph(fz_font *font, int gid, float *xp, float *yp) memset(&key, 0, sizeof key); key.font = font; + key.size = size; key.gid = gid; key.subx = subx; key.suby = suby; @@ -225,12 +225,12 @@ static struct glyph *lookup_glyph(fz_font *font, int gid, float *xp, float *yp) return &g_table[pos].glyph; } -static float ui_draw_glyph(fz_font *font, int gid, float x, float y) +static float ui_draw_glyph(fz_font *font, float size, int gid, float x, float y) { struct glyph *glyph; float s0, t0, s1, t1, xc, yc; - glyph = lookup_glyph(font, gid, &x, &y); + glyph = lookup_glyph(font, size, gid, &x, &y); if (!glyph) return 0; @@ -246,21 +246,21 @@ static float ui_draw_glyph(fz_font *font, int gid, float x, float y) glTexCoord2f(s1, t1); glVertex2f(xc + glyph->w, yc); glTexCoord2f(s0, t1); glVertex2f(xc, yc); - return fz_advance_glyph(ctx, font, gid, 0) * g_font_size; + return fz_advance_glyph(ctx, font, gid, 0) * size; } float ui_measure_character(int ucs) { fz_font *font; int gid = fz_encode_character_with_fallback(ctx, g_font, ucs, 0, 0, &font); - return fz_advance_glyph(ctx, font, gid, 0) * g_font_size; + return fz_advance_glyph(ctx, font, gid, 0) * ui.fontsize; } float ui_draw_character(int ucs, float x, float y) { fz_font *font; int gid = fz_encode_character_with_fallback(ctx, g_font, ucs, 0, 0, &font); - return ui_draw_glyph(font, gid, x, y); + return ui_draw_glyph(font, ui.fontsize, gid, x, y); } void ui_begin_text(void) |