Commit e5d05978 authored by Kenichi Handa's avatar Kenichi Handa
Browse files

(ftfont_text_extents): Fix initial setting of metrics.

parent 73353585
......@@ -22,6 +22,7 @@
* xfont.c (xfont_open): Adjust it for the change of
font_make_object.
(xfont_text_extents): Fix initial setting of metrics.
* ftfont.c (struct ftfont_info): New member index, delete member
fc_charset_idx. Make the member order compatible with struct
......@@ -49,6 +50,7 @@
(ftfont_has_char): Use ftfont_get_fc_charset.
(ftfont_otf_features, ftfont_otf_capability): New functions.
(ftfont_shape): Use ftfont_get_otf.
(ftfont_text_extents): Fix initial setting of metrics.
* xftfont.c (struct xftfont_info): New member ft_size. Make the
member order compatible with struct ftfont_info.
......
......@@ -1171,18 +1171,29 @@ ftfont_text_extents (font, code, nglyphs, metrics)
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
FT_Face ft_face = ftfont_info->ft_size->face;
int width = 0;
int i;
int i, first;
if (ftfont_info->ft_size != ft_face->size)
FT_Activate_Size (ftfont_info->ft_size);
if (metrics)
bzero (metrics, sizeof (struct font_metrics));
for (i = 0; i < nglyphs; i++)
for (i = 0, first = 1; i < nglyphs; i++)
{
if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0)
{
FT_Glyph_Metrics *m = &ft_face->glyph->metrics;
if (first)
{
if (metrics)
{
metrics->lbearing = m->horiBearingX >> 6;
metrics->rbearing = (m->horiBearingX + m->width) >> 6;
metrics->ascent = m->horiBearingY >> 6;
metrics->descent = (m->horiBearingY + m->height) >> 6;
}
first = 0;
}
if (metrics)
{
if (metrics->lbearing > width + (m->horiBearingX >> 6))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment