free (rfont);
}
+static void
+get_glyph_metric (FT_Face ft_face, MGlyph *g)
+{
+ FT_Glyph_Metrics *metrics;
+
+ FT_Load_Glyph (ft_face, (FT_UInt) g->code, FT_LOAD_DEFAULT);
+ metrics = &ft_face->glyph->metrics;
+ g->lbearing = metrics->horiBearingX;
+ g->rbearing = metrics->horiBearingX + metrics->width;
+ g->width = metrics->horiAdvance;
+ g->ascent = metrics->horiBearingY;
+ g->descent = metrics->height - metrics->horiBearingY;
+}
\f
/* Internal API */
#define DEVICE_DELTA(table, size) \
(((size) >= (table).StartSize && (size) <= (table).EndSize) \
- ? (table).DeltaValue[(size) - (table).StartSize] \
+ ? (table).DeltaValue[(size) - (table).StartSize] << 6 \
: 0)
void
else if (anchor->AnchorFormat == 3)
{
if (anchor->f.f2.XDeviceTable.offset)
- *x += (DEVICE_DELTA (anchor->f.f2.XDeviceTable, x_ppem)) << 6;
+ *x += DEVICE_DELTA (anchor->f.f2.XDeviceTable, x_ppem);
if (anchor->f.f2.YDeviceTable.offset)
- *y += (DEVICE_DELTA (anchor->f.f2.YDeviceTable, y_ppem)) << 6;
+ *y += DEVICE_DELTA (anchor->f.f2.YDeviceTable, y_ppem);
}
}
MLIST_APPEND1 (gstring, glyphs, temp, MERROR_FONT_OTF);
}
- (rfont->driver->find_metric) (rfont, gstring, gidx, gstring->used);
-
- if (gpos_features)
+ if (gpos_features
+ && (OTF_drive_gpos (otf, &otf_gstring, script, langsys, gpos_features)
+ >= 0))
{
- FT_Face face;
+ FT_Face ft_face;
MGlyph *base = NULL, *mark = NULL;
int x_ppem, y_ppem, x_scale, y_scale;
- if (OTF_drive_gpos (otf, &otf_gstring, script, langsys, gpos_features)
- < 0)
- return to;
-
- face = ((MRealizedFontFT *) rfont->info)->ft_face;
- x_ppem = face->size->metrics.x_ppem;
- y_ppem = face->size->metrics.y_ppem;
- x_scale = face->size->metrics.x_scale;
- y_scale = face->size->metrics.y_scale;
+ ft_face = ((MRealizedFontFT *) rfont->info)->ft_face;
+ x_ppem = ft_face->size->metrics.x_ppem;
+ y_ppem = ft_face->size->metrics.y_ppem;
+ x_scale = ft_face->size->metrics.x_scale;
+ y_scale = ft_face->size->metrics.y_scale;
for (i = 0, otfg = otf_gstring.glyphs, g = MGLYPH (gidx);
i < otf_gstring.used; i++, otfg++, g++)
{
MGlyph *prev;
+ get_glyph_metric (ft_face, g);
if (! otfg->glyph_id)
continue;
switch (otfg->positioning_type)
int format = otfg->f.f1.format;
if (format & OTF_XPlacement)
- g->xoff = otfg->f.f1.value->XPlacement * x_scale / 0x400000;
+ g->xoff = otfg->f.f1.value->XPlacement * x_scale / 0x10000;
if (format & OTF_XPlaDevice)
g->xoff
+= DEVICE_DELTA (otfg->f.f1.value->XPlaDevice, x_ppem);
if (format & OTF_YPlacement)
g->yoff
- = - (otfg->f.f1.value->YPlacement * y_scale / 0x400000);
+ = - (otfg->f.f1.value->YPlacement * y_scale / 0x10000);
if (format & OTF_YPlaDevice)
g->yoff
-= DEVICE_DELTA (otfg->f.f1.value->YPlaDevice, y_ppem);
if (format & OTF_XAdvance)
g->width
- += otfg->f.f1.value->XAdvance * x_scale / 0x400000;
+ += otfg->f.f1.value->XAdvance * x_scale / 0x10000;
if (format & OTF_XAdvDevice)
g->width
+= DEVICE_DELTA (otfg->f.f1.value->XAdvDevice, y_ppem);
if (otfg->f.f4.mark_anchor->AnchorFormat != 1)
adjust_anchor (otfg->f.f4.mark_anchor, rfont->fontp,
g->code, x_ppem, y_ppem, &mark_x, &mark_y);
- g->xoff = prev->xoff - prev->width + ((base_x - mark_x) >> 6);
- g->yoff = prev->yoff + ((mark_y - base_y) >> 6);
+ g->xoff = prev->xoff - prev->width + (base_x - mark_x);
+ g->yoff = prev->yoff + (mark_y - base_y);
g->combining_code = MAKE_PRECOMPUTED_COMBINDING_CODE ();
}
}
else
base = g;
}
+
+ for (i = 0, g = MGLYPH (gidx); i < otf_gstring.used; i++, g++)
+ {
+ g->lbearing >>= 6;
+ g->rbearing >>= 6;
+ g->width >>= 6;
+ g->ascent >>= 6;
+ g->descent >>= 6;
+ g->xoff >>= 6;
+ g->yoff >>= 6;
+ }
}
+ else
+ rfont->driver->find_metric (rfont, gstring, gidx, gstring->used);
free (otf_gstring.glyphs);
return to;