]> code.delx.au - gnu-emacs/blobdiff - src/ftfont.c
Don't install keyboard hook when debugged on MS-Windows
[gnu-emacs] / src / ftfont.c
index 17e41a9339e2f00f87063750d67e9905ba422c13..1ae3f88daa31911e635cea8e0709d7f0dd4ac896 100644 (file)
@@ -1,5 +1,5 @@
 /* ftfont.c -- FreeType font driver.
-   Copyright (C) 2006-2015 Free Software Foundation, Inc.
+   Copyright (C) 2006-2016 Free Software Foundation, Inc.
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
@@ -8,8 +8,8 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -30,6 +30,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "dispextern.h"
 #include "character.h"
 #include "charset.h"
+#include "category.h"
 #include "composite.h"
 #include "font.h"
 #include "ftfont.h"
@@ -81,6 +82,8 @@ static Lisp_Object ftfont_lookup_cache (Lisp_Object,
 
 static void ftfont_filter_properties (Lisp_Object font, Lisp_Object alist);
 
+static Lisp_Object ftfont_combining_capability (struct font *);
+
 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
 
 static struct
@@ -547,6 +550,10 @@ struct font_driver ftfont_driver =
 #endif
 
     ftfont_filter_properties, /* filter_properties */
+
+    NULL,                      /* cached_font_ok */
+
+    ftfont_combining_capability,
   };
 
 static Lisp_Object
@@ -561,7 +568,6 @@ ftfont_get_charset (Lisp_Object registry)
   char *str = SSDATA (SYMBOL_NAME (registry));
   USE_SAFE_ALLOCA;
   char *re = SAFE_ALLOCA (SBYTES (SYMBOL_NAME (registry)) * 2 + 1);
-  Lisp_Object regexp;
   int i, j;
 
   for (i = j = 0; i < SBYTES (SYMBOL_NAME (registry)); i++, j++)
@@ -575,13 +581,13 @@ ftfont_get_charset (Lisp_Object registry)
        re[j] = '.';
     }
   re[j] = '\0';
-  regexp = make_unibyte_string (re, j);
-  SAFE_FREE ();
+  AUTO_STRING_WITH_LEN (regexp, re, j);
   for (i = 0; fc_charset_table[i].name; i++)
     if (fast_c_string_match_ignore_case
        (regexp, fc_charset_table[i].name,
         strlen (fc_charset_table[i].name)) >= 0)
       break;
+  SAFE_FREE ();
   if (! fc_charset_table[i].name)
     return -1;
   if (! fc_charset_table[i].fc_charset)
@@ -2533,7 +2539,7 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
 
   len = i;
 
-  if (with_variation_selector)
+  if (otf && with_variation_selector)
     {
       setup_otf_gstring (len);
       for (i = 0; i < len; i++)
@@ -2589,9 +2595,21 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
         language information, and select a proper flt for them
         here.  */
       int c1 = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 1));
-      if (0x300 <= c1 && c1 <= 0x36F)
+      /* For the combining characters in the range U+300..U+36F,
+        "combining" is the sole FLT provided by the m17n-lib.  In
+        addition, it is the sole FLT that can handle the other
+        combining characters with non-OTF fonts.  */
+      if ((0x300 <= c1 && c1 <= 0x36F)
+         || (! otf && CHAR_HAS_CATEGORY (c1, '^')))
        flt = mflt_get (msymbol ("combining"));
     }
+  if (! flt && ! otf)
+    {
+      flt = mflt_find (LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, 0)),
+                      &flt_font_ft.flt_font);
+      if (! flt)
+       return make_number (0);
+    }
 
   MFLTGlyphFT *glyphs = (MFLTGlyphFT *) gstring.glyphs;
   ptrdiff_t allocated = gstring.allocated;
@@ -2675,8 +2693,6 @@ ftfont_shape (Lisp_Object lgstring)
   struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
   OTF *otf = ftfont_get_otf (ftfont_info);
 
-  if (! otf)
-    return make_number (0);
   return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf,
                              &ftfont_info->matrix);
 }
@@ -2750,6 +2766,16 @@ ftfont_filter_properties (Lisp_Object font, Lisp_Object alist)
 }
 
 
+static Lisp_Object
+ftfont_combining_capability (struct font *font)
+{
+#ifdef HAVE_M17N_FLT
+  return Qt;
+#else
+  return Qnil;
+#endif
+}
+
 void
 syms_of_ftfont (void)
 {