--- deliantra/Deliantra-Client/pango-render.c 2006/07/04 23:23:32 1.1 +++ deliantra/Deliantra-Client/pango-render.c 2006/07/04 23:56:34 1.3 @@ -102,6 +102,8 @@ static void font_render_glyph (Glyph *glyph, PangoFont *font, int glyph_index) { + FT_Face face; + if (glyph_index & PANGO_GLYPH_UNKNOWN_FLAG) { PangoFontMetrics *metrics; @@ -122,7 +124,7 @@ return; } - FT_Face face = pango_opengl_font_get_face (font); + face = pango_opengl_font_get_face (font); if (face) { @@ -146,6 +148,7 @@ typedef struct glyph_info { tc_area tex; int left, top; + int generation; } glyph_info; static void @@ -159,6 +162,8 @@ draw_glyph (PangoRenderer *renderer_, PangoFont *font, PangoGlyph glyph, double x, double y) { PangoOpenGLRenderer *renderer = PANGO_OPENGL_RENDERER (renderer_); + glyph_info *g; + float x1, y1, x2, y2; if (glyph & PANGO_GLYPH_UNKNOWN_FLAG) { @@ -168,14 +173,22 @@ glyph = PANGO_GLYPH_UNKNOWN_FLAG; } - glyph_info *g = _pango_opengl_font_get_cache_glyph_data (font, glyph); + g = _pango_opengl_font_get_cache_glyph_data (font, glyph); - if (!g) + if (!g || g->generation != tc_generation) { Glyph bm; font_render_glyph (&bm, font, glyph); - g = g_slice_new (glyph_info); + if (g) + g->generation = tc_generation; + else + { + g = g_slice_new (glyph_info); + + _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info); + _pango_opengl_font_set_cache_glyph_data (font, glyph, g); + } tc_get (&g->tex, bm.width, bm.height); @@ -194,18 +207,15 @@ glTexSubImage2D (GL_TEXTURE_2D, 0, g->tex.x, g->tex.y, bm.width, bm.height, GL_ALPHA, GL_UNSIGNED_BYTE, bm.bitmap); glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); glPixelStorei (GL_UNPACK_ALIGNMENT, 4); - - _pango_opengl_font_set_glyph_cache_destroy (font, (GDestroyNotify)free_glyph_info); - _pango_opengl_font_set_cache_glyph_data (font, glyph, g); } x += g->left; y -= g->top; - float x1 = g->tex.x * (1. / TC_WIDTH ); - float y1 = g->tex.y * (1. / TC_HEIGHT); - float x2 = g->tex.w * (1. / TC_WIDTH ) + x1; - float y2 = g->tex.h * (1. / TC_HEIGHT) + y1; + x1 = g->tex.x * (1. / TC_WIDTH ); + y1 = g->tex.y * (1. / TC_HEIGHT); + x2 = g->tex.w * (1. / TC_WIDTH ) + x1; + y2 = g->tex.h * (1. / TC_HEIGHT) + y1; if (g->tex.name != renderer->curtex) {