From: handa Date: Mon, 10 Sep 2007 04:50:49 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=6b138cd1062709392384c286dba3d2d9371e3c16;p=m17n%2Fm17n-test.git *** empty log message *** --- diff --git a/flt.c b/flt.c index 5b5c9c4..70e6abe 100644 --- a/flt.c +++ b/flt.c @@ -177,13 +177,20 @@ typedef struct { } FontInfo; int -get_glyph_id (MFLTFont *font, MFLTGlyph *g) +get_glyph_id (MFLTFont *font, MFLTGlyphString *gstring, int from, int to) { FT_Face face = ((FontInfo *) font)->face; - g->code = FT_Get_Char_Index (face, g->code); + for (; from < to; from++) + { + MFLTGlyph *g = gstring->glyphs + from; - return (g->code ? 0 : -1); + if (! g->encoded + && ! (g->code = FT_Get_Char_Index (face, g->code))) + return -1; + g->encoded = 1; + } + return 0; } int @@ -194,17 +201,22 @@ get_metric (MFLTFont *font, MFLTGlyphString *gstring, int from, int to) for (; from < to; from++) { MFLTGlyph *g = gstring->glyphs + from; - FT_Glyph_Metrics *metrics; - if (FT_Load_Glyph (face, g->code, FT_LOAD_DEFAULT)) - return -1; - metrics = &face->glyph->metrics; - g->lbearing = metrics->horiBearingX; - g->rbearing = metrics->horiBearingX + metrics->width; - g->xadv = metrics->horiAdvance; - g->yadv = metrics->vertAdvance; - g->ascent = metrics->horiBearingY; - g->descent = metrics->height - metrics->horiBearingY; + if (! g->measured) + { + FT_Glyph_Metrics *metrics; + + if (FT_Load_Glyph (face, g->code, FT_LOAD_DEFAULT)) + return -1; + metrics = &face->glyph->metrics; + g->lbearing = metrics->horiBearingX; + g->rbearing = metrics->horiBearingX + metrics->width; + g->xadv = metrics->horiAdvance; + g->yadv = metrics->vertAdvance; + g->ascent = metrics->horiBearingY; + g->descent = metrics->height - metrics->horiBearingY; + g->measured = 1; + } } return 0; } @@ -997,17 +1009,25 @@ typedef struct { } FontInfoPango; int -get_glyph_id (MFLTFont *font, MFLTGlyph *g) +get_glyph_id (MFLTFont *font, MFLTGlyphString *gstring, int from, int to) { FontInfoPango *font_info = (FontInfoPango *) font; - g->code = pango_fc_font_get_glyph (font_info->pango_font, g->code); - return (g->code ? 0 : -1); + for (; from < to; from++) + { + MFLTGlyph *g = gstring->glyphs + from; + + if (! g->encoded + && ! (g->code = pango_fc_font_get_glyph (font_info->pango_font, + g->code))) + return -1; + g->encoded = 1; + } + return 0; } #define PANGO_SCALE_TO_26_6 (PANGO_SCALE / (1<<6)) -#if 0 int get_metric (MFLTFont *font, MFLTGlyphString *gstring, int from, int to) { @@ -1017,22 +1037,25 @@ get_metric (MFLTFont *font, MFLTGlyphString *gstring, int from, int to) for (i = from; i < to; i++) { MFLTGlyph *g = gstring->glyphs + from; - PangoRectangle inc, logical; - pango_font_get_glyph_extents (PANGO_FONT (font_info->pango_font), - gstring->glyphs[i].code, &inc, &logical); - g->lbearing = inc.x / PANGO_SCALE_TO_26_6; - g->rbearing = (inc.x + inc.width) / PANGO_SCALE_TO_26_6; - g->xadv = logical.width / PANGO_SCALE_TO_26_6; - g->yadv = 0; - g->ascent = - inc.y / PANGO_SCALE_TO_26_6; - g->descent = (inc.height + inc.y) / PANGO_SCALE_TO_26_6; + if (! g->measured) + { + PangoRectangle inc, logical; + + pango_font_get_glyph_extents (PANGO_FONT (font_info->pango_font), + gstring->glyphs[i].code, &inc, &logical); + g->lbearing = inc.x / PANGO_SCALE_TO_26_6; + g->rbearing = (inc.x + inc.width) / PANGO_SCALE_TO_26_6; + g->xadv = logical.width / PANGO_SCALE_TO_26_6; + g->yadv = 0; + g->ascent = - inc.y / PANGO_SCALE_TO_26_6; + g->descent = (inc.height + inc.y) / PANGO_SCALE_TO_26_6; + g->measured = 1; + } } return 0; } -#else -int (*get_metric) (MFLTFont *font, MFLTGlyphString *gstring, int from, int to) = NULL; -#endif + #ifndef PANGO_OT_DEFAULT_LANGUAGE #define PANGO_OT_DEFAULT_LANGUAGE ((guint) 0xFFFF)