Avoid Faref and assume that args are always valid. This helps to
speedup search, which is especially important for a huge buffers.
* lisp.h (char_table_translate): Remove prototype.
+
* nsfont.m (nsfont_close): Free glyphs and metrics arrays as well.
+ * font.c (font_build_object) [HAVE_XFT || HAVE_FREETYPE || HAVE_NS]:
+ New function, with an intention to avoid code duplication between
+ a few font drivers.
+ * font.h (font_build_object) [HAVE_XFT || HAVE_FREETYPE || HAVE_NS]:
+ Add prototype.
+ * ftfont.c (ftfont_open):
+ * macfont.m (macfont_open):
+ * xftfont.c (xftfont_open): Use it.
2014-07-08 Paul Eggert <eggert@cs.ucla.edu>
return font_object;
}
-\f
+#if defined (HAVE_XFT) || defined (HAVE_FREETYPE) || defined (HAVE_NS)
+
+/* Like above, but also set `type', `name' and `fullname' properties
+ of font-object. */
+
+Lisp_Object
+font_build_object (int vectorsize, Lisp_Object type,
+ Lisp_Object entity, double pixelsize)
+{
+ int len;
+ char name[256];
+ Lisp_Object font_object = font_make_object (vectorsize, entity, pixelsize);
+
+ ASET (font_object, FONT_TYPE_INDEX, type);
+ len = font_unparse_xlfd (entity, pixelsize, name, sizeof name);
+ if (len > 0)
+ ASET (font_object, FONT_NAME_INDEX, make_string (name, len));
+ len = font_unparse_fcname (entity, pixelsize, name, sizeof name);
+ if (len > 0)
+ ASET (font_object, FONT_FULLNAME_INDEX, make_string (name, len));
+ else
+ ASET (font_object, FONT_FULLNAME_INDEX,
+ AREF (font_object, FONT_NAME_INDEX));
+ return font_object;
+}
+
+#endif /* HAVE_XFT || HAVE_FREETYPE || HAVE_NS */
static int font_pixel_size (struct frame *f, Lisp_Object);
static Lisp_Object font_open_entity (struct frame *, Lisp_Object, int);
extern Lisp_Object font_make_entity (void);
extern Lisp_Object font_make_object (int, Lisp_Object, int);
+#if defined (HAVE_XFT) || defined (HAVE_FREETYPE) || defined (HAVE_NS)
+extern Lisp_Object font_build_object (int, Lisp_Object, Lisp_Object, double);
+#endif
extern Lisp_Object find_font_encoding (Lisp_Object);
extern int font_registry_charsets (Lisp_Object, struct charset **,
Lisp_Object val, filename, idx, cache, font_object;
bool scalable;
int spacing;
- char name[256];
- int i, len;
+ int i;
int upEM;
val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX));
return Qnil;
}
- font_object = font_make_object (VECSIZE (struct ftfont_info), entity, size);
- ASET (font_object, FONT_TYPE_INDEX, Qfreetype);
- len = font_unparse_xlfd (entity, size, name, 256);
- if (len > 0)
- ASET (font_object, FONT_NAME_INDEX, make_string (name, len));
- len = font_unparse_fcname (entity, size, name, 256);
- if (len > 0)
- ASET (font_object, FONT_FULLNAME_INDEX, make_string (name, len));
- else
- ASET (font_object, FONT_FULLNAME_INDEX,
- AREF (font_object, FONT_NAME_INDEX));
+ font_object = font_build_object (VECSIZE (struct ftfont_info),
+ Qfreetype, entity, size);
ASET (font_object, FONT_FILE_INDEX, filename);
ASET (font_object, FONT_FORMAT_INDEX, ftfont_font_format (NULL, filename));
font = XFONT_OBJECT (font_object);
int size;
FontRef macfont;
FontSymbolicTraits sym_traits;
- char name[256];
- int len, i, total_width;
+ int i, total_width;
CGGlyph glyph;
CGFloat ascent, descent, leading;
if (! macfont)
return Qnil;
- font_object = font_make_object (VECSIZE (struct macfont_info), entity, size);
- ASET (font_object, FONT_TYPE_INDEX, macfont_driver.type);
- len = font_unparse_xlfd (entity, size, name, 256);
- if (len > 0)
- ASET (font_object, FONT_NAME_INDEX, make_string (name, len));
- len = font_unparse_fcname (entity, size, name, 256);
- if (len > 0)
- ASET (font_object, FONT_FULLNAME_INDEX, make_string (name, len));
- else
- ASET (font_object, FONT_FULLNAME_INDEX,
- AREF (font_object, FONT_NAME_INDEX));
+ font_object = font_build_object (VECSIZE (struct macfont_info),
+ Qmac_ct, entity, size);
font = XFONT_OBJECT (font_object);
font->pixel_size = size;
font->driver = &macfont_driver;
double size = 0;
XftFont *xftfont = NULL;
int spacing;
- char name[256];
- int len, i;
+ int i;
XGlyphInfo extents;
FT_Face ft_face;
FcMatrix *matrix;
/* We should not destroy PAT here because it is kept in XFTFONT and
destroyed automatically when XFTFONT is closed. */
- font_object = font_make_object (VECSIZE (struct xftfont_info), entity, size);
- ASET (font_object, FONT_TYPE_INDEX, Qxft);
- len = font_unparse_xlfd (entity, size, name, 256);
- if (len > 0)
- ASET (font_object, FONT_NAME_INDEX, make_string (name, len));
- len = font_unparse_fcname (entity, size, name, 256);
- if (len > 0)
- ASET (font_object, FONT_FULLNAME_INDEX, make_string (name, len));
- else
- ASET (font_object, FONT_FULLNAME_INDEX,
- AREF (font_object, FONT_NAME_INDEX));
+ font_object = font_build_object (VECSIZE (struct xftfont_info),
+ Qxft, entity, size);
ASET (font_object, FONT_FILE_INDEX, filename);
ASET (font_object, FONT_FORMAT_INDEX,
ftfont_font_format (xftfont->pattern, filename));