summaryrefslogtreecommitdiff
path: root/src/xftfont.c
diff options
context:
space:
mode:
authorRobert Pluim <rpluim@gmail.com>2019-01-26 12:31:02 +0100
committerRobert Pluim <rpluim@gmail.com>2019-02-08 09:05:11 +0100
commit9e0d69b5a17a0fa3b0dd099a51584a85f3ddb5bf (patch)
treeb6dcbce3d3d4ff5a6719814d26a95747118b4f67 /src/xftfont.c
parent24905e92179c2ee8cd02c26b4a7058fbd238ece7 (diff)
downloademacs-9e0d69b5a17a0fa3b0dd099a51584a85f3ddb5bf.tar.gz
Unify three font info structures
* src/ftfont.h (struct font_info): New type, unifies similar types from ftcrfont.c, ftfont.c and xftfont.c * src/xftfont.c (struct xftfont_info): Remove, replace with struct font_info. Adjust all uses. * src/ftcrfont.c (struct ftcrfont_info): Likewise. * src/ftfont.c (struct ftfont_info): Likewise.
Diffstat (limited to 'src/xftfont.c')
-rw-r--r--src/xftfont.c45
1 files changed, 11 insertions, 34 deletions
diff --git a/src/xftfont.c b/src/xftfont.c
index ea8572f4242..8a4516f7f91 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -36,29 +36,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
/* Xft font driver. */
-
-/* The actual structure for Xft font that can be cast to struct
- font. */
-
-struct xftfont_info
-{
- struct font font;
- /* The following members up to and including 'matrix' must be here
- in this order to be compatible with struct ftfont_info (in
- ftfont.c). */
-#ifdef HAVE_LIBOTF
- bool maybe_otf; /* Flag to tell if this may be OTF or not. */
- OTF *otf;
-#endif /* HAVE_LIBOTF */
- FT_Size ft_size;
- int index;
- FT_Matrix matrix;
-
- Display *display;
- XftFont *xftfont;
- unsigned x_display_id;
-};
-
/* Structure pointed by (struct face *)->extra */
struct xftface_info
@@ -258,7 +235,7 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
Display *display = FRAME_X_DISPLAY (f);
Lisp_Object val, filename, idx, font_object;
FcPattern *pat = NULL, *match;
- struct xftfont_info *xftfont_info = NULL;
+ struct font_info *xftfont_info = NULL;
struct font *font;
double size = 0;
XftFont *xftfont = NULL;
@@ -333,7 +310,7 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
/* We should not destroy PAT here because it is kept in XFTFONT and
destroyed automatically when XFTFONT is closed. */
- font_object = font_build_object (VECSIZE (struct xftfont_info),
+ font_object = font_build_object (VECSIZE (struct font_info),
Qxft, entity, size);
ASET (font_object, FONT_FILE_INDEX, filename);
font = XFONT_OBJECT (font_object);
@@ -341,7 +318,7 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
font->driver = &xftfont_driver;
font->encoding_charset = font->repertory_charset = -1;
- xftfont_info = (struct xftfont_info *) font;
+ xftfont_info = (struct font_info *) font;
xftfont_info->display = display;
xftfont_info->xftfont = xftfont;
xftfont_info->x_display_id = FRAME_DISPLAY_INFO (f)->x_id;
@@ -463,7 +440,7 @@ static void
xftfont_close (struct font *font)
{
struct x_display_info *xdi;
- struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
+ struct font_info *xftfont_info = (struct font_info *) font;
#ifdef HAVE_LIBOTF
if (xftfont_info->otf)
@@ -529,7 +506,7 @@ xftfont_done_face (struct frame *f, struct face *face)
static int
xftfont_has_char (Lisp_Object font, int c)
{
- struct xftfont_info *xftfont_info;
+ struct font_info *xftfont_info;
struct charset *cs = NULL;
if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qja)
@@ -543,7 +520,7 @@ xftfont_has_char (Lisp_Object font, int c)
if (FONT_ENTITY_P (font))
return ftfont_has_char (font, c);
- xftfont_info = (struct xftfont_info *) XFONT_OBJECT (font);
+ xftfont_info = (struct font_info *) XFONT_OBJECT (font);
return (XftCharExists (xftfont_info->display, xftfont_info->xftfont,
(FcChar32) c) == FcTrue);
}
@@ -551,7 +528,7 @@ xftfont_has_char (Lisp_Object font, int c)
static unsigned
xftfont_encode_char (struct font *font, int c)
{
- struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
+ struct font_info *xftfont_info = (struct font_info *) font;
unsigned code = XftCharIndex (xftfont_info->display, xftfont_info->xftfont,
(FcChar32) c);
@@ -562,7 +539,7 @@ static void
xftfont_text_extents (struct font *font, unsigned int *code,
int nglyphs, struct font_metrics *metrics)
{
- struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
+ struct font_info *xftfont_info = (struct font_info *) font;
XGlyphInfo extents;
block_input ();
@@ -604,7 +581,7 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
struct frame *f = s->f;
struct face *face = s->face;
- struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font;
+ struct font_info *xftfont_info = (struct font_info *) s->font;
struct xftface_info *xftface_info = NULL;
XftDraw *xft_draw = xftfont_get_xft_draw (f);
FT_UInt *code;
@@ -667,7 +644,7 @@ static Lisp_Object
xftfont_shape (Lisp_Object lgstring)
{
struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
- struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
+ struct font_info *xftfont_info = (struct font_info *) font;
FT_Face ft_face = XftLockFace (xftfont_info->xftfont);
xftfont_info->ft_size = ft_face->size;
Lisp_Object val = ftfont_shape (lgstring);
@@ -711,7 +688,7 @@ static bool
xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object,
Lisp_Object entity)
{
- struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object);
+ struct font_info *info = (struct font_info *) XFONT_OBJECT (font_object);
FcPattern *oldpat = info->xftfont->pattern;
Display *display = FRAME_X_DISPLAY (f);
FcPattern *pat = FcPatternCreate ();