]> code.delx.au - gnu-emacs/blobdiff - src/font.c
* src/macfont.m (mac_font_shape): Make sure that total_advance is increasing.
[gnu-emacs] / src / font.c
index ce144e78a08620636f6f4d272202f34f6068e7d9..144ba07c42a09385f2f7e12562be46e39a953256 100644 (file)
@@ -1,6 +1,6 @@
 /* font.c -- "Font" primitives.
 
-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
@@ -9,8 +9,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
@@ -36,6 +36,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "composite.h"
 #include "fontset.h"
 #include "font.h"
+#include "termhooks.h"
 
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
@@ -1770,7 +1771,8 @@ font_parse_family_registry (Lisp_Object family, Lisp_Object registry, Lisp_Objec
       p1 = strchr (p0, '-');
       if (! p1)
        {
-         AUTO_STRING (extra, ("*-*" + (len && p0[len - 1] == '*')));
+         bool asterisk = len && p0[len - 1] == '*';
+         AUTO_STRING_WITH_LEN (extra, &"*-*"[asterisk], 3 - asterisk);
          registry = concat2 (registry, extra);
        }
       registry = Fdowncase (registry);
@@ -2232,7 +2234,8 @@ font_sort_entities (Lisp_Object list, Lisp_Object prefer,
   struct font_sort_data *data;
   unsigned best_score;
   Lisp_Object best_entity;
-  Lisp_Object tail, vec IF_LINT (= Qnil);
+  Lisp_Object tail;
+  Lisp_Object vec UNINIT;
   USE_SAFE_ALLOCA;
 
   for (i = FONT_WEIGHT_INDEX; i <= FONT_AVGWIDTH_INDEX; i++)
@@ -2860,7 +2863,7 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size)
   struct font_driver_list *driver_list;
   Lisp_Object objlist, size, val, font_object;
   struct font *font;
-  int min_width, height, psize;
+  int height, psize;
 
   eassert (FONT_ENTITY_P (entity));
   size = AREF (entity, FONT_SIZE_INDEX);
@@ -2904,10 +2907,12 @@ font_open_entity (struct frame *f, Lisp_Object entity, int pixel_size)
        Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX)));
 
   font = XFONT_OBJECT (font_object);
-  min_width = (font->min_width ? font->min_width
-              : font->average_width ? font->average_width
-              : font->space_width ? font->space_width
-              : 1);
+#ifdef HAVE_WINDOW_SYSTEM
+  int min_width = (font->min_width ? font->min_width
+                  : font->average_width ? font->average_width
+                  : font->space_width ? font->space_width
+                  : 1);
+#endif
 
   int font_ascent, font_descent;
   get_font_ascent_descent (font, &font_ascent, &font_descent);
@@ -3981,7 +3986,10 @@ copy_font_spec (Lisp_Object font)
   pcdr = spec->props + FONT_EXTRA_INDEX;
   for (tail = AREF (font, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail))
     if (!EQ (XCAR (XCAR (tail)), QCfont_entity))
-      *pcdr = Fcons (XCAR (tail), Qnil), pcdr = xcdr_addr (*pcdr);
+      {
+        *pcdr = Fcons (Fcons (XCAR (XCAR (tail)), CDR (XCAR (tail))), Qnil);
+        pcdr = xcdr_addr (*pcdr);
+      }
 
   XSETFONT (new_spec, spec);
   return new_spec;
@@ -4032,7 +4040,13 @@ The value of :otf is a cons (GSUB . GPOS) where GSUB and GPOS are lists
 representing the OpenType features supported by the font by this form:
   ((SCRIPT (LANGSYS FEATURE ...) ...) ...)
 SCRIPT, LANGSYS, and FEATURE are all symbols representing OpenType
-Layout tags.  */)
+Layout tags.
+
+In addition to the keys listed abobe, the following keys are reserved
+for the specific meanings as below:
+
+The value of :combining-capability is non-nil if the font-backend of
+FONT supports rendering of combining characters for non-OTF fonts.  */)
   (Lisp_Object font, Lisp_Object key)
 {
   int idx;
@@ -4047,14 +4061,22 @@ Layout tags.  */)
   if (idx >= 0 && idx < FONT_EXTRA_INDEX)
     return AREF (font, idx);
   val = Fassq (key, AREF (font, FONT_EXTRA_INDEX));
-  if (NILP (val) && EQ (key, QCotf) && FONT_OBJECT_P (font))
+  if (NILP (val) && FONT_OBJECT_P (font))
     {
       struct font *fontp = XFONT_OBJECT (font);
 
-      if (fontp->driver->otf_capability)
-       val = fontp->driver->otf_capability (fontp);
-      else
-       val = Fcons (Qnil, Qnil);
+      if (EQ (key, QCotf))
+       {
+         if (fontp->driver->otf_capability)
+           val = fontp->driver->otf_capability (fontp);
+         else
+           val = Fcons (Qnil, Qnil);
+       }
+      else if (EQ (key, QCcombining_capability))
+       {
+         if (fontp->driver->combining_capability)
+           val = fontp->driver->combining_capability (fontp);
+       }
     }
   else
     val = Fcdr (val);
@@ -4068,7 +4090,7 @@ DEFUN ("font-face-attributes", Ffont_face_attributes, Sfont_face_attributes, 1,
 FONT is a font name, a font-spec, a font-entity, or a font-object.
 The return value is a list of the form
 
-(:family FAMILY :height HEIGHT :weight WEIGHT :slant SLANT :width WIDTH)
+\(:family FAMILY :height HEIGHT :weight WEIGHT :slant SLANT :width WIDTH)
 
 where FAMILY, HEIGHT, WEIGHT, SLANT, and WIDTH are face attribute values
 compatible with `set-face-attribute'.  Some of these key-attribute pairs
@@ -5286,6 +5308,7 @@ syms_of_font (void)
   DEFSYM (QCscalable, ":scalable");
   DEFSYM (QCavgwidth, ":avgwidth");
   DEFSYM (QCfont_entity, ":font-entity");
+  DEFSYM (QCcombining_capability, ":combining-capability");
 
   /* Symbols representing values of font spacing property.  */
   DEFSYM (Qc, "c");
@@ -5298,7 +5321,7 @@ syms_of_font (void)
   DEFSYM (Qja, "ja");
   DEFSYM (Qko, "ko");
 
-  DEFSYM (QCuser_spec, "user-spec");
+  DEFSYM (QCuser_spec, ":user-spec");
 
   staticpro (&scratch_font_spec);
   scratch_font_spec = Ffont_spec (0, NULL);
@@ -5359,7 +5382,7 @@ where ENCODING is a charset or a char-table,
 and REPERTORY is a charset, a char-table, or nil.
 
 If ENCODING and REPERTORY are the same, the element can have the form
-(REGEXP . ENCODING).
+\(REGEXP . ENCODING).
 
 ENCODING is for converting a character to a glyph code of the font.
 If ENCODING is a charset, encoding a character by the charset gives