summaryrefslogtreecommitdiff
path: root/src/ftfont.c
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2006-07-28 12:45:58 +0000
committerKenichi Handa <handa@m17n.org>2006-07-28 12:45:58 +0000
commitc9c0c42905ae7c22d4628caca6a0cdf0e2194328 (patch)
tree6ad7235ad04923df3a2121ca62b89a1bfb0535a2 /src/ftfont.c
parent056360d007c86327ac5abfe0a44d9950d8c1f04a (diff)
downloademacs-c9c0c42905ae7c22d4628caca6a0cdf0e2194328.tar.gz
emacs-c9c0c42905ae7c22d4628caca6a0cdf0e2194328.tar.bz2
emacs-c9c0c42905ae7c22d4628caca6a0cdf0e2194328.zip
(ftfont_open): Set font->font.full_name and
font->font.name properly. Fix calculation of font->font.height and font->min_width.
Diffstat (limited to 'src/ftfont.c')
-rw-r--r--src/ftfont.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/ftfont.c b/src/ftfont.c
index 37e4f2563b4..d327035e00b 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -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;