]> code.delx.au - gnu-emacs/blobdiff - src/xftfont.c
One more change by Ken Brown to avoid breaking Cygwin.
[gnu-emacs] / src / xftfont.c
index 181a1da9b384626400a2d2908a0771b2c00de84e..37b33b3ead8cf9d39a7f97b25617a5a9b513f60c 100644 (file)
@@ -1,5 +1,5 @@
 /* xftfont.c -- XFT font driver.
 /* xftfont.c -- XFT font driver.
-   Copyright (C) 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 2006-2013 Free Software Foundation, Inc.
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
@@ -58,7 +58,6 @@ struct xftfont_info
   int index;
   FT_Matrix matrix;
   Display *display;
   int index;
   FT_Matrix matrix;
   Display *display;
-  int screen;
   XftFont *xftfont;
 };
 
   XftFont *xftfont;
 };
 
@@ -70,17 +69,14 @@ struct xftface_info
   XftColor xft_bg;             /* color for face->background */
 };
 
   XftColor xft_bg;             /* color for face->background */
 };
 
-static void xftfont_get_colors (FRAME_PTR, struct face *, GC gc,
-                                struct xftface_info *,
-                                XftColor *fg, XftColor *bg);
-
-
 /* Setup foreground and background colors of GC into FG and BG.  If
    XFTFACE_INFO is not NULL, reuse the colors in it if possible.  BG
    may be NULL.  */
 
 static void
 /* Setup foreground and background colors of GC into FG and BG.  If
    XFTFACE_INFO is not NULL, reuse the colors in it if possible.  BG
    may be NULL.  */
 
 static void
-xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *xftface_info, XftColor *fg, XftColor *bg)
+xftfont_get_colors (struct frame *f, struct face *face, GC gc,
+                   struct xftface_info *xftface_info,
+                   XftColor *fg, XftColor *bg)
 {
   if (xftface_info && face->gc == gc)
     {
 {
   if (xftface_info && face->gc == gc)
     {
@@ -139,9 +135,9 @@ xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *
 struct font_driver xftfont_driver;
 
 static Lisp_Object
 struct font_driver xftfont_driver;
 
 static Lisp_Object
-xftfont_list (Lisp_Object frame, Lisp_Object spec)
+xftfont_list (struct frame *f, Lisp_Object spec)
 {
 {
-  Lisp_Object list = ftfont_driver.list (frame, spec), tail;
+  Lisp_Object list = ftfont_driver.list (f, spec), tail;
 
   for (tail = list; CONSP (tail); tail = XCDR (tail))
     ASET (XCAR (tail), FONT_TYPE_INDEX, Qxft);
 
   for (tail = list; CONSP (tail); tail = XCDR (tail))
     ASET (XCAR (tail), FONT_TYPE_INDEX, Qxft);
@@ -149,9 +145,9 @@ xftfont_list (Lisp_Object frame, Lisp_Object spec)
 }
 
 static Lisp_Object
 }
 
 static Lisp_Object
-xftfont_match (Lisp_Object frame, Lisp_Object spec)
+xftfont_match (struct frame *f, Lisp_Object spec)
 {
 {
-  Lisp_Object entity = ftfont_driver.match (frame, spec);
+  Lisp_Object entity = ftfont_driver.match (f, spec);
 
   if (! NILP (entity))
     ASET (entity, FONT_TYPE_INDEX, Qxft);
 
   if (! NILP (entity))
     ASET (entity, FONT_TYPE_INDEX, Qxft);
@@ -262,7 +258,7 @@ xftfont_add_rendering_parameters (FcPattern *pat, Lisp_Object entity)
 }
 
 static Lisp_Object
 }
 
 static Lisp_Object
-xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
+xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 {
   FcResult result;
   Display *display = FRAME_X_DISPLAY (f);
 {
   FcResult result;
   Display *display = FRAME_X_DISPLAY (f);
@@ -375,7 +371,6 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
 
   xftfont_info = (struct xftfont_info *) font;
   xftfont_info->display = display;
 
   xftfont_info = (struct xftfont_info *) font;
   xftfont_info->display = display;
-  xftfont_info->screen = FRAME_X_SCREEN_NUMBER (f);
   xftfont_info->xftfont = xftfont;
   /* This means that there's no need of transformation.  */
   xftfont_info->matrix.xx = 0;
   xftfont_info->xftfont = xftfont;
   /* This means that there's no need of transformation.  */
   xftfont_info->matrix.xx = 0;
@@ -484,22 +479,30 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
 }
 
 static void
 }
 
 static void
-xftfont_close (FRAME_PTR f, struct font *font)
+xftfont_close (struct font *font)
 {
   struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
 
 #ifdef HAVE_LIBOTF
   if (xftfont_info->otf)
 {
   struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
 
 #ifdef HAVE_LIBOTF
   if (xftfont_info->otf)
-    OTF_close (xftfont_info->otf);
+    {
+      OTF_close (xftfont_info->otf);
+      xftfont_info->otf = NULL;
+    }
 #endif
 #endif
-  block_input ();
-  XftUnlockFace (xftfont_info->xftfont);
-  XftFontClose (xftfont_info->display, xftfont_info->xftfont);
-  unblock_input ();
+
+  if (xftfont_info->xftfont)
+    {
+      block_input ();
+      XftUnlockFace (xftfont_info->xftfont);
+      XftFontClose (xftfont_info->display, xftfont_info->xftfont);
+      unblock_input ();
+      xftfont_info->xftfont = NULL;
+    }
 }
 
 static int
 }
 
 static int
-xftfont_prepare_face (FRAME_PTR f, struct face *face)
+xftfont_prepare_face (struct frame *f, struct face *face)
 {
   struct xftface_info *xftface_info;
 
 {
   struct xftface_info *xftface_info;
 
@@ -522,7 +525,7 @@ xftfont_prepare_face (FRAME_PTR f, struct face *face)
 }
 
 static void
 }
 
 static void
-xftfont_done_face (FRAME_PTR f, struct face *face)
+xftfont_done_face (struct frame *f, struct face *face)
 {
   struct xftface_info *xftface_info;
 
 {
   struct xftface_info *xftface_info;
 
@@ -595,7 +598,7 @@ xftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct
 }
 
 static XftDraw *
 }
 
 static XftDraw *
-xftfont_get_xft_draw (FRAME_PTR f)
+xftfont_get_xft_draw (struct frame *f)
 {
   XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);
 
 {
   XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);
 
@@ -617,7 +620,7 @@ static int
 xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
               bool with_background)
 {
 xftfont_draw (struct glyph_string *s, int from, int to, int x, int y,
               bool with_background)
 {
-  FRAME_PTR f = s->f;
+  struct frame *f = s->f;
   struct face *face = s->face;
   struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font;
   struct xftface_info *xftface_info = NULL;
   struct face *face = s->face;
   struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font;
   struct xftface_info *xftface_info = NULL;
@@ -677,7 +680,7 @@ xftfont_shape (Lisp_Object lgstring)
 #endif
 
 static int
 #endif
 
 static int
-xftfont_end_for_frame (FRAME_PTR f)
+xftfont_end_for_frame (struct frame *f)
 {
   XftDraw *xft_draw;
 
 {
   XftDraw *xft_draw;