# HG changeset patch # User Kenichi Handa # Date 1154090758 0 # Node ID 45553626fa76f774544aee6dc6b0f1df9823d556 # Parent d0351223b22a9068c9735f8fd92bb9e65720815f (ftfont_open): Set font->font.full_name and font->font.name properly. Fix calculation of font->font.height and font->min_width. diff -r d0351223b22a -r 45553626fa76 src/ftfont.c --- a/src/ftfont.c Fri Jul 28 12:44:45 2006 +0000 +++ b/src/ftfont.c Fri Jul 28 12:45:58 2006 +0000 @@ -629,6 +629,8 @@ 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 @@ 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 @@ } } + /* 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;