/* font.c -- "Font" primitives.
- Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
- Copyright (C) 2006, 2007, 2008, 2009, 2010
- National Institute of Advanced Industrial Science and Technology (AIST)
- Registration Number H13PRO009
+
+Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright (C) 2006, 2007, 2008, 2009, 2010
+ National Institute of Advanced Industrial Science and Technology (AIST)
+ Registration Number H13PRO009
This file is part of GNU Emacs.
#include <config.h>
#include <stdio.h>
-#include <stdlib.h>
#include <ctype.h>
#include <setjmp.h>
{ 200, { "ultra-expanded", "ultraexpanded", "wide" }}
};
-Lisp_Object QCfoundry, QCadstyle, QCregistry;
+Lisp_Object QCfoundry;
+static Lisp_Object QCadstyle, QCregistry;
/* Symbols representing keys of font extra info. */
Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClang, QCscript, QCavgwidth;
Lisp_Object QCantialias, QCfont_entity, QCfc_unknown_spec;
/* Creaters of font-related Lisp object. */
-Lisp_Object
+static Lisp_Object
font_make_spec (void)
{
Lisp_Object font_spec;
static Lisp_Object font_open_entity (FRAME_PTR, Lisp_Object, int);
static Lisp_Object font_matching_entity (FRAME_PTR, Lisp_Object *,
Lisp_Object);
+static unsigned font_encode_char (Lisp_Object, int);
/* Number of registered font drivers. */
static int num_font_drivers;
int i;
Lisp_Object tem;
Lisp_Object obarray;
- int nbytes, nchars;
+ EMACS_INT nbytes, nchars;
if (len == 1 && *str == '*')
return Qnil;
This function tries to guess which format it is. */
-int
+static int
font_parse_fcname (char *name, Lisp_Object font)
{
char *p, *q;
return (p - name);
}
-/* Store GTK-style font name of FONT (font-spec or font-entity) in
- NAME (NBYTES length), and return the name length. F is the frame
- on which the font is displayed; it is used to calculate the point
- size. */
-
-int
-font_unparse_gtkname (Lisp_Object font, struct frame *f, char *name, int nbytes)
-{
- char *p;
- int len = 1;
- Lisp_Object family, weight, slant, size;
- int point_size = -1;
-
- family = AREF (font, FONT_FAMILY_INDEX);
- if (! NILP (family))
- {
- if (! SYMBOLP (family))
- return -1;
- family = SYMBOL_NAME (family);
- len += SBYTES (family);
- }
-
- weight = font_style_symbolic (font, FONT_WEIGHT_INDEX, 0);
- if (EQ (weight, Qnormal))
- weight = Qnil;
- else if (! NILP (weight))
- {
- weight = SYMBOL_NAME (weight);
- len += SBYTES (weight);
- }
-
- slant = font_style_symbolic (font, FONT_SLANT_INDEX, 0);
- if (EQ (slant, Qnormal))
- slant = Qnil;
- else if (! NILP (slant))
- {
- slant = SYMBOL_NAME (slant);
- len += SBYTES (slant);
- }
-
- size = AREF (font, FONT_SIZE_INDEX);
- /* Convert pixel size to point size. */
- if (INTEGERP (size))
- {
- Lisp_Object font_dpi = AREF (font, FONT_DPI_INDEX);
- int dpi = 75;
- if (INTEGERP (font_dpi))
- dpi = XINT (font_dpi);
- else if (f)
- dpi = f->resy;
- point_size = PIXEL_TO_POINT (XINT (size), dpi);
- len += 11;
- }
- else if (FLOATP (size))
- {
- point_size = (int) XFLOAT_DATA (size);
- len += 11;
- }
-
- if (len > nbytes)
- return -1;
-
- p = name + sprintf (name, "%s", SDATA (family));
-
- if (! NILP (weight))
- {
- char *q = p;
- p += sprintf (p, " %s", SDATA (weight));
- q[1] = toupper (q[1]);
- }
-
- if (! NILP (slant))
- {
- char *q = p;
- p += sprintf (p, " %s", SDATA (slant));
- q[1] = toupper (q[1]);
- }
-
- if (point_size > 0)
- p += sprintf (p, " %d", point_size);
-
- return (p - name);
-}
-
/* Parse NAME (null terminated) and store information in FONT
(font-spec or font-entity). If NAME is successfully parsed, return
0. Otherwise return -1. */
/* Return the glyph ID of FONT_OBJECT for character C. */
-unsigned
+static unsigned
font_encode_char (Lisp_Object font_object, int c)
{
struct font *font;
attrs[LFACE_FONT_INDEX] = font;
}
-void
-font_update_lface (FRAME_PTR f, Lisp_Object *attrs)
-{
- Lisp_Object spec;
-
- spec = attrs[LFACE_FONT_INDEX];
- if (! FONT_SPEC_P (spec))
- return;
-
- if (! NILP (AREF (spec, FONT_FOUNDRY_INDEX)))
- attrs[LFACE_FOUNDRY_INDEX] = SYMBOL_NAME (AREF (spec, FONT_FOUNDRY_INDEX));
- if (! NILP (AREF (spec, FONT_FAMILY_INDEX)))
- attrs[LFACE_FAMILY_INDEX] = SYMBOL_NAME (AREF (spec, FONT_FAMILY_INDEX));
- if (! NILP (AREF (spec, FONT_WEIGHT_INDEX)))
- attrs[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (spec);
- if (! NILP (AREF (spec, FONT_SLANT_INDEX)))
- attrs[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (spec);
- if (! NILP (AREF (spec, FONT_WIDTH_INDEX)))
- attrs[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (spec);
- if (! NILP (AREF (spec, FONT_SIZE_INDEX)))
- {
- int point;
-
- if (INTEGERP (AREF (spec, FONT_SIZE_INDEX)))
- {
- Lisp_Object val;
- int dpi = f->resy;
-
- val = Ffont_get (spec, QCdpi);
- if (! NILP (val))
- dpi = XINT (val);
- point = PIXEL_TO_POINT (XINT (AREF (spec, FONT_SIZE_INDEX)) * 10,
- dpi);
- attrs[LFACE_HEIGHT_INDEX] = make_number (point);
- }
- else if (FLOATP (AREF (spec, FONT_SIZE_INDEX)))
- {
- point = XFLOAT_DATA (AREF (spec, FONT_SIZE_INDEX)) * 10;
- attrs[LFACE_HEIGHT_INDEX] = make_number (point);
- }
- }
-}
-
-
/* Selecte a font from ENTITIES (list of font-entity vectors) that
supports C and matches best with ATTRS and PIXEL_SIZE. */
if (NILP (entity))
return Qnil;
}
- /* Don't loose the original name that was put in initially. We need
+ /* Don't lose the original name that was put in initially. We need
it to re-apply the font when font parameters (like hinting or dpi) have
changed. */
entity = font_open_for_lface (f, entity, attrs, spec);
args[1] = make_unibyte_string (name, strlen (name));
spec = Ffont_spec (2, args);
ret = font_open_by_spec (f, spec);
- /* Do not loose name originally put in. */
+ /* Do not lose name originally put in. */
if (!NILP (ret))
font_put_extra (ret, QCuser_spec, args[1]);
}
+/* Sets attributes on a font. Any properties that appear in ALIST and
+ BOOLEAN_PROPERTIES or NON_BOOLEAN_PROPERTIES are set on the font.
+ BOOLEAN_PROPERTIES and NON_BOOLEAN_PROPERTIES are NULL-terminated
+ arrays of strings. This function is intended for use by the font
+ drivers to implement their specific font_filter_properties. */
+void
+font_filter_properties (Lisp_Object font,
+ Lisp_Object alist,
+ const char *const boolean_properties[],
+ const char *const non_boolean_properties[])
+{
+ Lisp_Object it;
+ int i;
+
+ /* Set boolean values to Qt or Qnil */
+ for (i = 0; boolean_properties[i] != NULL; ++i)
+ for (it = alist; ! NILP (it); it = XCDR (it))
+ {
+ Lisp_Object key = XCAR (XCAR (it));
+ Lisp_Object val = XCDR (XCAR (it));
+ char *keystr = SDATA (SYMBOL_NAME (key));
+
+ if (strcmp (boolean_properties[i], keystr) == 0)
+ {
+ const char *str = INTEGERP (val) ? (XINT (val) ? "true" : "false")
+ : SYMBOLP (val) ? (const char *) SDATA (SYMBOL_NAME (val))
+ : "true";
+
+ if (strcmp ("false", str) == 0 || strcmp ("False", str) == 0
+ || strcmp ("FALSE", str) == 0 || strcmp ("FcFalse", str) == 0
+ || strcmp ("off", str) == 0 || strcmp ("OFF", str) == 0
+ || strcmp ("Off", str) == 0)
+ val = Qnil;
+ else
+ val = Qt;
+
+ Ffont_put (font, key, val);
+ }
+ }
+
+ for (i = 0; non_boolean_properties[i] != NULL; ++i)
+ for (it = alist; ! NILP (it); it = XCDR (it))
+ {
+ Lisp_Object key = XCAR (XCAR (it));
+ Lisp_Object val = XCDR (XCAR (it));
+ char *keystr = SDATA (SYMBOL_NAME (key));
+ if (strcmp (non_boolean_properties[i], keystr) == 0)
+ Ffont_put (font, key, val);
+ }
+}
+
+
/* Return the font used to draw character C by FACE at buffer position
POS in window W. If STRING is non-nil, it is a string containing C
at index POS. If C is negative, get C from the current buffer or
STRING. */
-Lisp_Object
-font_at (int c, EMACS_INT pos, struct face *face, struct window *w, Lisp_Object string)
+static Lisp_Object
+font_at (int c, EMACS_INT pos, struct face *face, struct window *w,
+ Lisp_Object string)
{
FRAME_PTR f;
int multibyte;
doc: /* Return a list of variation glyphs for CHAR in FONT-OBJECT.
Each element of the value is a cons (VARIATION-SELECTOR . GLYPH-ID),
where
- VARIATION-SELECTOR is a chracter code of variation selection
+ VARIATION-SELECTOR is a character code of variation selection
(#xFE00..#xFE0F or #xE0100..#xE01EF)
GLYPH-ID is a glyph code of the corresponding variation glyph. */)
(Lisp_Object font_object, Lisp_Object character)
Vfont_log = egetenv ("EMACS_FONT_LOG") ? Qnil : Qt;
}
-/* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846
- (do not change this comment) */