} 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
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;
}
} 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)
{
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)