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

(ftfont_open): Set font->font.full_name and

font->font.name properly.  Fix calculation of font->font.height
and font->min_width.
parent 056360d0
......@@ -629,6 +629,8 @@ ftfont_open (f, entity, pixel_size)
FcPattern *pattern;
FcChar8 *file;
int spacing;
char *name;
int len;
val = AREF (entity, FONT_EXTRA_INDEX);
if (XTYPE (val) != Lisp_Misc
......@@ -681,15 +683,28 @@ ftfont_open (f, entity, pixel_size)
font->entity = entity;
font->pixel_size = size;
font->driver = &ftfont_driver;
font->font.name = font->font.full_name = NULL;
len = 96;
name = malloc (len);
while (name && font_unparse_fcname (entity, pixel_size, name, len) < 0)
{
char *new = realloc (name, len += 32);
if (! new)
free (name);
name = new;
}
font->font.full_name = font->font.name = name;
font->file_name = (char *) file;
font->font.size = ft_face->size->metrics.max_advance >> 6;
if (font->font.size <= 0)
font->font.size = size;
font->font.charset = font->encoding_charset = font->repertory_charset = -1;
font->ascent = ft_face->size->metrics.ascender >> 6;
font->descent = - ft_face->size->metrics.descender >> 6;
font->font.height = ft_face->size->metrics.height >> 6;
if (FcPatternGetInteger (pattern, FC_SPACING, 0, &spacing) != FcResultMatch
|| spacing != FC_PROPORTIONAL)
font->font.height = font->ascent + font->descent;
if (FcPatternGetInteger (pattern, FC_SPACING, 0, &spacing) != FcResultMatch)
spacing = FC_PROPORTIONAL;
if (spacing != FC_PROPORTIONAL)
font->font.average_width = font->font.space_width = font->font.size;
else
{
......@@ -716,6 +731,10 @@ ftfont_open (f, entity, pixel_size)
}
}
/* Unfortunately FreeType doesn't provide a way to get minimum char
width. So, we use space_width instead. */
font->min_width = font->font.space_width;
font->font.baseline_offset = 0;
font->font.relative_compose = 0;
font->font.default_ascent = 0;
......
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