[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117491: * font.c (font_build_object) [HAVE_XFT || H
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] trunk r117491: * font.c (font_build_object) [HAVE_XFT || HAVE_FREETYPE || HAVE_NS]: |
Date: |
Tue, 08 Jul 2014 14:54:26 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117491
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Tue 2014-07-08 18:50:45 +0400
message:
* 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.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/font.c font.c-20091113204419-o5vbwnq5f7feedwu-8540
src/font.h font.h-20091113204419-o5vbwnq5f7feedwu-8541
src/ftfont.c ftfont.c-20091113204419-o5vbwnq5f7feedwu-8542
src/macfont.m macfont.m-20130915173740-04lgloz0557bz98l-2
src/xftfont.c xftfont.c-20091113204419-o5vbwnq5f7feedwu-8548
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-07-08 14:19:34 +0000
+++ b/src/ChangeLog 2014-07-08 14:50:45 +0000
@@ -5,7 +5,16 @@
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 <address@hidden>
=== modified file 'src/font.c'
--- a/src/font.c 2014-07-03 12:20:00 +0000
+++ b/src/font.c 2014-07-08 14:50:45 +0000
@@ -225,7 +225,33 @@
return font_object;
}
-
+#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);
=== modified file 'src/font.h'
--- a/src/font.h 2014-07-04 02:28:54 +0000
+++ b/src/font.h 2014-07-08 14:50:45 +0000
@@ -719,6 +719,9 @@
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 **,
=== modified file 'src/ftfont.c'
--- a/src/ftfont.c 2014-07-04 02:28:54 +0000
+++ b/src/ftfont.c 2014-07-08 14:50:45 +0000
@@ -1183,8 +1183,7 @@
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));
@@ -1221,17 +1220,8 @@
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);
=== modified file 'src/macfont.m'
--- a/src/macfont.m 2014-07-04 02:28:54 +0000
+++ b/src/macfont.m 2014-07-08 14:50:45 +0000
@@ -2444,8 +2444,7 @@
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;
@@ -2472,17 +2471,8 @@
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;
=== modified file 'src/xftfont.c'
--- a/src/xftfont.c 2014-07-03 12:20:00 +0000
+++ b/src/xftfont.c 2014-07-08 14:50:45 +0000
@@ -270,8 +270,7 @@
double size = 0;
XftFont *xftfont = NULL;
int spacing;
- char name[256];
- int len, i;
+ int i;
XGlyphInfo extents;
FT_Face ft_face;
FcMatrix *matrix;
@@ -341,17 +340,8 @@
/* 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));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117491: * font.c (font_build_object) [HAVE_XFT || HAVE_FREETYPE || HAVE_NS]:,
Dmitry Antipov <=