annotate src/font.c @ 91057:5e056bb0109f

Fix merge conflicts Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-271
author Miles Bader <miles@gnu.org>
date Fri, 19 Oct 2007 00:03:33 +0000
parents a9e96c4a1a90
children 2c767d9f0bb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 /* font.c -- "Font" primitives.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2 Copyright (C) 2006 Free Software Foundation, Inc.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3 Copyright (C) 2006
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 National Institute of Advanced Industrial Science and Technology (AIST)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 Registration Number H13PRO009
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 This file is part of GNU Emacs.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9 GNU Emacs is free software; you can redistribute it and/or modify
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2, or (at your option)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12 any later version.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14 GNU Emacs is distributed in the hope that it will be useful,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 GNU General Public License for more details.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 along with GNU Emacs; see the file COPYING. If not, write to
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 Boston, MA 02110-1301, USA. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 #include <config.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 #include <stdio.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 #include <stdlib.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 #include <ctype.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 #include "lisp.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 #include "buffer.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 #include "frame.h"
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
32 #include "window.h"
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 #include "dispextern.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 #include "charset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 #include "character.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 #include "composite.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 #include "fontset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 #include "font.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
40 #ifndef FONT_DEBUG
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 #define FONT_DEBUG
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
42 #endif
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 #ifdef FONT_DEBUG
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 #undef xassert
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 #define xassert(X) do {if (!(X)) abort ();} while (0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 #else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 #define xassert(X) (void) 0
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 #endif
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 int enable_font_backend;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 Lisp_Object Qfontp;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54
90677
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
55 Lisp_Object Qopentype;
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
56
90439
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
57 /* Important character set symbols. */
90622
bb9362e3a03b (Qunicode_sip): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90590
diff changeset
58 Lisp_Object Qiso8859_1, Qiso10646_1, Qunicode_bmp, Qunicode_sip;
90439
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
59
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 /* Like CHECK_FONT_SPEC but also validate properties of the font-spec,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 and set X to the validated result. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 #define CHECK_VALIDATE_FONT_SPEC(x) \
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 do { \
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65 if (! FONT_SPEC_P (x)) x = wrong_type_argument (Qfont, x); \
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 x = font_prop_validate (x); \
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 } while (0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 /* Number of pt per inch (from the TeXbook). */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 #define PT_PER_INCH 72.27
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
72 /* Return a pixel size (integer) corresponding to POINT size (double)
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
73 on resolution DPI. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
74 #define POINT_TO_PIXEL(POINT, DPI) ((POINT) * (DPI) / PT_PER_INCH + 0.5)
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
75
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
76 /* Return a point size (double) corresponding to POINT size (integer)
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
77 on resolution DPI. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
78 #define PIXEL_TO_POINT(PIXEL, DPI) ((PIXEL) * PT_PER_INCH * 10 / (DPI) + 0.5)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 /* Special string of zero length. It is used to specify a NULL name
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 in a font properties (e.g. adstyle). We don't use the symbol of
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 NULL name because it's confusing (Lisp printer prints nothing for
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 it). */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 Lisp_Object null_string;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 /* Special vector of zero length. This is repeatedly used by (struct
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 font_driver *)->list when a specified font is not found. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 Lisp_Object null_vector;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 /* Vector of 3 elements. Each element is an alist for one of font
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 style properties (weight, slant, width). The alist contains a
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 mapping between symbolic property values (e.g. `medium' for weight)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 and numeric property values (e.g. 100). So, it looks like this:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 [((thin . 0) ... (heavy . 210))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 ((ro . 0) ... (ot . 210))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 ((ultracondensed . 50) ... (wide . 200))] */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 static Lisp_Object font_style_table;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 /* Alist of font family vs the corresponding aliases.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 Each element has this form:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 (FAMILY ALIAS1 ALIAS2 ...) */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103 static Lisp_Object font_family_alist;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 /* Symbols representing keys of normal font properties. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 extern Lisp_Object QCtype, QCfamily, QCweight, QCslant, QCwidth, QCsize, QCname;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 Lisp_Object QCfoundry, QCadstyle, QCregistry, QCextra;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 /* Symbols representing keys of font extra info. */
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
109 Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClanguage, QCscript;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
110 /* Symbols representing values of font spacing property. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
111 Lisp_Object Qc, Qm, Qp, Qd;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113 /* List of all font drivers. All font-backends (XXXfont.c) call
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114 add_font_driver in syms_of_XXXfont to register the font-driver
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 here. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116 static struct font_driver_list *font_driver_list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
118 static int font_pixel_size P_ ((FRAME_PTR f, Lisp_Object));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 static Lisp_Object prop_name_to_numeric P_ ((enum font_property_index,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 Lisp_Object));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 static Lisp_Object prop_numeric_to_name P_ ((enum font_property_index, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 static Lisp_Object font_open_entity P_ ((FRAME_PTR, Lisp_Object, int));
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
123 static void build_font_family_alist P_ ((void));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 /* Number of registered font drivers. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
126 static int num_font_drivers;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
127
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
128 /* Return a pixel size of font-spec SPEC on frame F. */
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
129
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
130 static int
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
131 font_pixel_size (f, spec)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
132 FRAME_PTR f;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
133 Lisp_Object spec;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
134 {
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
135 Lisp_Object size = AREF (spec, FONT_SIZE_INDEX);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
136 double point_size;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
137 int pixel_size, dpi;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
138 Lisp_Object extra, val;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
139
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
140 if (INTEGERP (size))
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
141 return XINT (size);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
142 if (NILP (size))
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
143 return 0;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
144 point_size = XFLOAT_DATA (size);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
145 extra = AREF (spec, FONT_EXTRA_INDEX);
90903
c3e1394462ec (font_pixel_size): Reverse assq_no_quit args.
Jason Rumney <jasonr@gnu.org>
parents: 90888
diff changeset
146 val = assq_no_quit (QCdpi, extra);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
147 if (CONSP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
148 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
149 if (INTEGERP (XCDR (val)))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
150 dpi = XINT (XCDR (val));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
151 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
152 dpi = XFLOAT_DATA (XCDR (val)) + 0.5;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
153 }
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
154 else
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
155 dpi = f->resy;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
156 pixel_size = POINT_TO_PIXEL (point_size, dpi);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
157 return pixel_size;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
158 }
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
159
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
160 /* Return a numeric value corresponding to PROP's NAME (symbol). If
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
161 NAME is not registered in font_style_table, return Qnil. PROP must
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
162 be one of FONT_{WEIGHT|SLANT|SWIDTH}_INDEX. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
163
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
164 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
165 prop_name_to_numeric (prop, name)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
166 enum font_property_index prop;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
167 Lisp_Object name;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
168 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
169 int table_index = prop - FONT_WEIGHT_INDEX;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
170 Lisp_Object val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
171
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
172 val = assq_no_quit (name, AREF (font_style_table, table_index));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
173 return (NILP (val) ? Qnil : XCDR (val));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
174 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
175
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
176
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
177 /* Return a name (symbol) corresponding to PROP's NUMERIC value. If
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
178 no name is registered for NUMERIC in font_style_table, return a
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
179 symbol of integer name (e.g. `123'). PROP must be one of
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
180 FONT_{WEIGHT|SLANT|SWIDTH}_INDEX. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
181
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
182 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
183 prop_numeric_to_name (prop, numeric)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
184 enum font_property_index prop;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
185 int numeric;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
186 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
187 int table_index = prop - FONT_WEIGHT_INDEX;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
188 Lisp_Object table = AREF (font_style_table, table_index);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
189 char buf[10];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
190
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
191 while (! NILP (table))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
192 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
193 if (XINT (XCDR (XCAR (table))) >= numeric)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
194 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
195 if (XINT (XCDR (XCAR (table))) == numeric)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
196 return XCAR (XCAR (table));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
197 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
198 break;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
199 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
200 table = XCDR (table);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
201 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
202 sprintf (buf, "%d", numeric);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
203 return intern (buf);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
204 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
205
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
206
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
207 /* Return a symbol whose name is STR (length LEN). If STR contains
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
208 uppercase letters, downcase them in advance. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
209
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
210 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
211 intern_downcase (str, len)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
212 char *str;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
213 int len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
214 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
215 char *buf;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
216 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
217
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
218 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
219 if (isupper (str[i]))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
220 break;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
221 if (i == len)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
222 return Fintern (make_unibyte_string (str, len), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
223 buf = alloca (len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
224 if (! buf)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
225 return Fintern (null_string, Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
226 bcopy (str, buf, len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
227 for (; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
228 if (isascii (buf[i]))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
229 buf[i] = tolower (buf[i]);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
230 return Fintern (make_unibyte_string (buf, len), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
231 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
232
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
233 extern Lisp_Object Vface_alternative_font_family_alist;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
234
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
235 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
236 build_font_family_alist ()
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
237 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
238 Lisp_Object alist = Vface_alternative_font_family_alist;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
239
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
240 for (; CONSP (alist); alist = XCDR (alist))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
241 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
242 Lisp_Object tail, elt;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
243
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
244 for (tail = XCAR (alist), elt = Qnil ; CONSP (tail); tail = XCDR (tail))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
245 elt = nconc2 (elt, Fcons (Fintern (XCAR (tail), Qnil), Qnil));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
246 font_family_alist = Fcons (elt, font_family_alist);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
247 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
248 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
249
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
250
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
251 /* Font property validater. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
252
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
253 static Lisp_Object font_prop_validate_symbol P_ ((enum font_property_index,
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
254 Lisp_Object, Lisp_Object));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
255 static Lisp_Object font_prop_validate_style P_ ((enum font_property_index,
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
256 Lisp_Object, Lisp_Object));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
257 static Lisp_Object font_prop_validate_non_neg P_ ((enum font_property_index,
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
258 Lisp_Object, Lisp_Object));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
259 static Lisp_Object font_prop_validate_spacing P_ ((enum font_property_index,
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
260 Lisp_Object, Lisp_Object));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
261 static int get_font_prop_index P_ ((Lisp_Object, int));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
262 static Lisp_Object font_prop_validate P_ ((Lisp_Object));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
263
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
264 static Lisp_Object
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
265 font_prop_validate_symbol (prop_index, prop, val)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
266 enum font_property_index prop_index;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
267 Lisp_Object prop, val;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
268 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
269 if (EQ (prop, QCotf))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
270 return (SYMBOLP (val) ? val : Qerror);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
271 if (STRINGP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
272 val = (SCHARS (val) == 0 ? null_string
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
273 : intern_downcase ((char *) SDATA (val), SBYTES (val)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
274 else if (SYMBOLP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
275 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
276 if (SCHARS (SYMBOL_NAME (val)) == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277 val = null_string;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
278 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
279 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 val = Qerror;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 return val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
282 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
283
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
284 static Lisp_Object
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
285 font_prop_validate_style (prop_index, prop, val)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
286 enum font_property_index prop_index;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
287 Lisp_Object prop, val;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
288 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
289 if (! INTEGERP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
290 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
291 if (STRINGP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
292 val = intern_downcase ((char *) SDATA (val), SBYTES (val));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
293 if (! SYMBOLP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
294 val = Qerror;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
295 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
296 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
297 val = prop_name_to_numeric (prop_index, val);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
298 if (NILP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
299 val = Qerror;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
300 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
302 return val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
303 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
304
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
305 static Lisp_Object
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
306 font_prop_validate_non_neg (prop_index, prop, val)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
307 enum font_property_index prop_index;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
308 Lisp_Object prop, val;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
309 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
310 return (NATNUMP (val) || (FLOATP (val) && XFLOAT_DATA (val) >= 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
311 ? val : Qerror);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
312 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
313
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
314 static Lisp_Object
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
315 font_prop_validate_spacing (prop_index, prop, val)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
316 enum font_property_index prop_index;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
317 Lisp_Object prop, val;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
318 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
319 if (NILP (val) || (NATNUMP (val) && XINT (val) <= FONT_SPACING_CHARCELL))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
320 return val;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
321 if (EQ (val, Qc))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
322 return make_number (FONT_SPACING_CHARCELL);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
323 if (EQ (val, Qm))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
324 return make_number (FONT_SPACING_MONO);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
325 if (EQ (val, Qp))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
326 return make_number (FONT_SPACING_PROPORTIONAL);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
327 return Qerror;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
328 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
329
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
330 /* Structure of known font property keys and validater of the
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
331 values. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
332 struct
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
333 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
334 /* Pointer to the key symbol. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
335 Lisp_Object *key;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
336 /* Function to validate the value VAL, or NULL if any value is ok. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
337 Lisp_Object (*validater) P_ ((enum font_property_index prop_index,
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
338 Lisp_Object prop, Lisp_Object val));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
339 } font_property_table[] =
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
340 { { &QCtype, font_prop_validate_symbol },
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
341 { &QCfoundry, font_prop_validate_symbol },
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
342 { &QCfamily, font_prop_validate_symbol },
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
343 { &QCadstyle, font_prop_validate_symbol },
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
344 { &QCregistry, font_prop_validate_symbol },
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
345 { &QCweight, font_prop_validate_style },
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
346 { &QCslant, font_prop_validate_style },
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
347 { &QCwidth, font_prop_validate_style },
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
348 { &QCsize, font_prop_validate_non_neg },
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
349 { &QClanguage, font_prop_validate_symbol },
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
350 { &QCscript, font_prop_validate_symbol },
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
351 { &QCdpi, font_prop_validate_non_neg },
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
352 { &QCspacing, font_prop_validate_spacing },
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
353 { &QCscalable, NULL },
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
354 { &QCotf, font_prop_validate_symbol }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
355 };
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
356
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
357 #define FONT_PROPERTY_TABLE_SIZE \
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
358 ((sizeof font_property_table) / (sizeof *font_property_table))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
359
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
360 static int
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
361 get_font_prop_index (key, from)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
362 Lisp_Object key;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
363 int from;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
364 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
365 for (; from < FONT_PROPERTY_TABLE_SIZE; from++)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
366 if (EQ (key, *font_property_table[from].key))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
367 return from;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
368 return -1;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
369 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
370
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
371 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
372 font_prop_validate (spec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
373 Lisp_Object spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
374 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
375 int i;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
376 Lisp_Object prop, val, extra;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
377
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
378 for (i = FONT_TYPE_INDEX; i < FONT_EXTRA_INDEX; i++)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
379 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
380 if (! NILP (AREF (spec, i)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
381 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
382 prop = *font_property_table[i].key;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
383 val = (font_property_table[i].validater) (i, prop, AREF (spec, i));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
384 if (EQ (val, Qerror))
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
385 Fsignal (Qfont, list2 (build_string ("invalid font property"),
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
386 Fcons (prop, AREF (spec, i))));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
387 ASET (spec, i, val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
388 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
389 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
390 for (extra = AREF (spec, FONT_EXTRA_INDEX);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
391 CONSP (extra); extra = XCDR (extra))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
392 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
393 Lisp_Object elt = XCAR (extra);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
394
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
395 prop = XCAR (elt);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
396 i = get_font_prop_index (prop, FONT_EXTRA_INDEX);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
397 if (i >= 0
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
398 && font_property_table[i].validater)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
399 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
400 val = (font_property_table[i].validater) (i, prop, XCDR (elt));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
401 if (EQ (val, Qerror))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
402 Fsignal (Qfont, list2 (build_string ("invalid font property"),
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
403 elt));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
404 XSETCDR (elt, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
405 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
406 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
407 return spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
408 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
409
90888
5f03b3602143 (font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents: 90883
diff changeset
410 Lisp_Object
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
411 font_put_extra (font, prop, val)
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
412 Lisp_Object font, prop, val;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
413 {
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
414 Lisp_Object extra = AREF (font, FONT_EXTRA_INDEX);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
415 Lisp_Object slot = (NILP (extra) ? Qnil : assq_no_quit (prop, extra));
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
416
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
417 if (NILP (slot))
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
418 {
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
419 extra = Fcons (Fcons (prop, val), extra);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
420 ASET (font, FONT_EXTRA_INDEX, extra);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
421 return val;
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
422 }
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
423 XSETCDR (slot, val);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
424 return val;
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
425 }
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
426
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
427
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
428 /* Font name parser and unparser */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
429
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
430 static Lisp_Object intern_font_field P_ ((char *, int));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
431 static int parse_matrix P_ ((char *));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
432 static int font_expand_wildcards P_ ((Lisp_Object *, int));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
433 static int font_parse_name P_ ((char *, Lisp_Object));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
434
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
435 /* An enumerator for each field of an XLFD font name. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
436 enum xlfd_field_index
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
437 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
438 XLFD_FOUNDRY_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
439 XLFD_FAMILY_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
440 XLFD_WEIGHT_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
441 XLFD_SLANT_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
442 XLFD_SWIDTH_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
443 XLFD_ADSTYLE_INDEX,
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
444 XLFD_PIXEL_INDEX,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
445 XLFD_POINT_INDEX,
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
446 XLFD_RESX_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
447 XLFD_RESY_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
448 XLFD_SPACING_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
449 XLFD_AVGWIDTH_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
450 XLFD_REGISTRY_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
451 XLFD_ENCODING_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
452 XLFD_LAST_INDEX
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
453 };
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
454
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
455 /* An enumerator for mask bit corresponding to each XLFD field. */
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
456 enum xlfd_field_mask
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
457 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
458 XLFD_FOUNDRY_MASK = 0x0001,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
459 XLFD_FAMILY_MASK = 0x0002,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
460 XLFD_WEIGHT_MASK = 0x0004,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
461 XLFD_SLANT_MASK = 0x0008,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
462 XLFD_SWIDTH_MASK = 0x0010,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
463 XLFD_ADSTYLE_MASK = 0x0020,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
464 XLFD_PIXEL_MASK = 0x0040,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
465 XLFD_POINT_MASK = 0x0080,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
466 XLFD_RESX_MASK = 0x0100,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
467 XLFD_RESY_MASK = 0x0200,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
468 XLFD_SPACING_MASK = 0x0400,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
469 XLFD_AVGWIDTH_MASK = 0x0800,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
470 XLFD_REGISTRY_MASK = 0x1000,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
471 XLFD_ENCODING_MASK = 0x2000
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
472 };
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
473
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
474
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
475 /* Return a Lispy value of a XLFD font field at STR and LEN bytes.
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
476 If LEN is zero, it returns `null_string'.
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
477 If STR is "*", it returns nil.
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
478 If all characters in STR are digits, it returns an integer.
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
479 Otherwise, it returns a symbol interned from downcased STR. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
480
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
481 static Lisp_Object
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
482 intern_font_field (str, len)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
483 char *str;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
484 int len;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
485 {
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
486 int i;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
487
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
488 if (len == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
489 return null_string;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
490 if (*str == '*' && len == 1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
491 return Qnil;
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
492 if (isdigit (*str))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
493 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
494 for (i = 1; i < len; i++)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
495 if (! isdigit (str[i]))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
496 break;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
497 if (i == len)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
498 return make_number (atoi (str));
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
499 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
500 return intern_downcase (str, len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
501 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
502
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
503 /* Parse P pointing the pixel/point size field of the form
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
504 `[A B C D]' which specifies a transformation matrix:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
505
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
506 A B 0
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
507 C D 0
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
508 0 0 1
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
509
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
510 by which all glyphs of the font are transformed. The spec says
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
511 that scalar value N for the pixel/point size is equivalent to:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
512 A = N * resx/resy, B = C = 0, D = N.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
513
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
514 Return the scalar value N if the form is valid. Otherwise return
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
515 -1. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
516
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
517 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
518 parse_matrix (p)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
519 char *p;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
520 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
521 double matrix[4];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
522 char *end;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
523 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
524
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
525 for (i = 0, p++; i < 4 && *p && *p != ']'; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
526 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
527 if (*p == '~')
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
528 matrix[i] = - strtod (p + 1, &end);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
529 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
530 matrix[i] = strtod (p, &end);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
531 p = end;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
532 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
533 return (i == 4 ? (int) matrix[3] : -1);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
534 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
535
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
536 /* Expand a wildcard field in FIELD (the first N fields are filled) to
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
537 multiple fields to fill in all 14 XLFD fields while restring a
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
538 field position by its contents. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
539
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
540 static int
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
541 font_expand_wildcards (field, n)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
542 Lisp_Object field[XLFD_LAST_INDEX];
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
543 int n;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
544 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
545 /* Copy of FIELD. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
546 Lisp_Object tmp[XLFD_LAST_INDEX];
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
547 /* Array of information about where this element can go. Nth
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
548 element is for Nth element of FIELD. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
549 struct {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
550 /* Minimum possible field. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
551 int from;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
552 /* Maxinum possible field. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
553 int to;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
554 /* Bit mask of possible field. Nth bit corresponds to Nth field. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
555 int mask;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
556 } range[XLFD_LAST_INDEX];
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
557 int i, j;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
558 int range_from, range_to;
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
559 unsigned range_mask;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
560
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
561 #define XLFD_SYMBOL_MASK (XLFD_FOUNDRY_MASK | XLFD_FAMILY_MASK \
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
562 | XLFD_ADSTYLE_MASK | XLFD_REGISTRY_MASK)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
563 #define XLFD_NULL_MASK (XLFD_FOUNDRY_MASK | XLFD_ADSTYLE_MASK)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
564 #define XLFD_LARGENUM_MASK (XLFD_POINT_MASK | XLFD_RESX_MASK | XLFD_RESY_MASK \
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
565 | XLFD_AVGWIDTH_MASK)
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
566 #define XLFD_REGENC_MASK (XLFD_REGISTRY_MASK | XLFD_ENCODING_MASK)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
567
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
568 /* Initialize RANGE_MASK for FIELD[0] which can be 0th to (14 - N)th
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
569 field. The value is shifted to left one bit by one in the
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
570 following loop. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
571 for (i = 0, range_mask = 0; i <= 14 - n; i++)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
572 range_mask = (range_mask << 1) | 1;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
573
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
574 /* The triplet RANGE_FROM, RANGE_TO, and RANGE_MASK is a
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
575 position-based retriction for FIELD[I]. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
576 for (i = 0, range_from = 0, range_to = 14 - n; i < n;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
577 i++, range_from++, range_to++, range_mask <<= 1)
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
578 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
579 Lisp_Object val = field[i];
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
580
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
581 tmp[i] = val;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
582 if (NILP (val))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
583 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
584 /* Wildcard. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
585 range[i].from = range_from;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
586 range[i].to = range_to;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
587 range[i].mask = range_mask;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
588 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
589 else
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
590 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
591 /* The triplet FROM, TO, and MASK is a value-based
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
592 retriction for FIELD[I]. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
593 int from, to;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
594 unsigned mask;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
595
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
596 if (INTEGERP (val))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
597 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
598 int numeric = XINT (val);
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
599
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
600 if (i + 1 == n)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
601 from = to = XLFD_ENCODING_INDEX,
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
602 mask = XLFD_ENCODING_MASK;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
603 else if (numeric == 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
604 from = XLFD_PIXEL_INDEX, to = XLFD_AVGWIDTH_INDEX,
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
605 mask = XLFD_PIXEL_MASK | XLFD_LARGENUM_MASK;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
606 else if (numeric <= 48)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
607 from = to = XLFD_PIXEL_INDEX,
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
608 mask = XLFD_PIXEL_MASK;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
609 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
610 from = XLFD_POINT_INDEX, to = XLFD_AVGWIDTH_INDEX,
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
611 mask = XLFD_LARGENUM_MASK;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
612 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
613 else if (EQ (val, null_string))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
614 from = XLFD_FOUNDRY_INDEX, to = XLFD_ADSTYLE_INDEX,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
615 mask = XLFD_NULL_MASK;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
616 else if (i == 0)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
617 from = to = XLFD_FOUNDRY_INDEX, mask = XLFD_FOUNDRY_MASK;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
618 else if (i + 1 == n)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
619 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
620 Lisp_Object name = SYMBOL_NAME (val);
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
621
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
622 if (SDATA (name)[SBYTES (name) - 1] == '*')
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
623 from = XLFD_REGISTRY_INDEX, to = XLFD_ENCODING_INDEX,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
624 mask = XLFD_REGENC_MASK;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
625 else
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
626 from = to = XLFD_ENCODING_INDEX,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
627 mask = XLFD_ENCODING_MASK;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
628 }
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
629 else if (range_from <= XLFD_WEIGHT_INDEX
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
630 && range_to >= XLFD_WEIGHT_INDEX
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
631 && !NILP (prop_name_to_numeric (FONT_WEIGHT_INDEX, val)))
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
632 from = to = XLFD_WEIGHT_INDEX, mask = XLFD_WEIGHT_MASK;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
633 else if (range_from <= XLFD_SLANT_INDEX
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
634 && range_to >= XLFD_SLANT_INDEX
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
635 && !NILP (prop_name_to_numeric (FONT_SLANT_INDEX, val)))
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
636 from = to = XLFD_SLANT_INDEX, mask = XLFD_SLANT_MASK;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
637 else if (range_from <= XLFD_SWIDTH_INDEX
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
638 && range_to >= XLFD_SWIDTH_INDEX
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
639 && !NILP (prop_name_to_numeric (FONT_WIDTH_INDEX, val)))
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
640 from = to = XLFD_SWIDTH_INDEX, mask = XLFD_SWIDTH_MASK;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
641 else
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
642 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
643 if (EQ (val, Qc) || EQ (val, Qm) || EQ (val, Qp) || EQ (val, Qd))
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
644 from = to = XLFD_SPACING_INDEX, mask = XLFD_SPACING_MASK;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
645 else
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
646 from = XLFD_FOUNDRY_INDEX, to = XLFD_ENCODING_INDEX,
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
647 mask = XLFD_SYMBOL_MASK;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
648 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
649
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
650 /* Merge position-based and value-based restrictions. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
651 mask &= range_mask;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
652 while (from < range_from)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
653 mask &= ~(1 << from++);
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
654 while (from < 14 && ! (mask & (1 << from)))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
655 from++;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
656 while (to > range_to)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
657 mask &= ~(1 << to--);
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
658 while (to >= 0 && ! (mask & (1 << to)))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
659 to--;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
660 if (from > to)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
661 return -1;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
662 range[i].from = from;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
663 range[i].to = to;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
664 range[i].mask = mask;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
665
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
666 if (from > range_from || to < range_to)
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
667 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
668 /* The range is narrowed by value-based restrictions.
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
669 Reflect it to the other fields. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
670
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
671 /* Following fields should be after FROM. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
672 range_from = from;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
673 /* Preceding fields should be before TO. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
674 for (j = i - 1, from--, to--; j >= 0; j--, from--, to--)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
675 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
676 /* Check FROM for non-wildcard field. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
677 if (! NILP (tmp[j]) && range[j].from < from)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
678 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
679 while (range[j].from < from)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
680 range[j].mask &= ~(1 << range[j].from++);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
681 while (from < 14 && ! (range[j].mask & (1 << from)))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
682 from++;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
683 range[j].from = from;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
684 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
685 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
686 from = range[j].from;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
687 if (range[j].to > to)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
688 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
689 while (range[j].to > to)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
690 range[j].mask &= ~(1 << range[j].to--);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
691 while (to >= 0 && ! (range[j].mask & (1 << to)))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
692 to--;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
693 range[j].to = to;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
694 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
695 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
696 to = range[j].to;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
697 if (from > to)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
698 return -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
699 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
700 }
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
701 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
702 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
703
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
704 /* Decide all fileds from restrictions in RANGE. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
705 for (i = j = 0; i < n ; i++)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
706 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
707 if (j < range[i].from)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
708 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
709 if (i == 0 || ! NILP (tmp[i - 1]))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
710 /* None of TMP[X] corresponds to Jth field. */
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
711 return -1;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
712 for (; j < range[i].from; j++)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
713 field[j] = Qnil;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
714 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
715 field[j++] = tmp[i];
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
716 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
717 if (! NILP (tmp[n - 1]) && j < XLFD_REGISTRY_INDEX)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
718 return -1;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
719 for (; j < XLFD_LAST_INDEX; j++)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
720 field[j] = Qnil;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
721 if (INTEGERP (field[XLFD_ENCODING_INDEX]))
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
722 field[XLFD_ENCODING_INDEX]
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
723 = Fintern (Fnumber_to_string (field[XLFD_ENCODING_INDEX]), Qnil);
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
724 return 0;
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
725 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
726
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
727 /* Parse NAME (null terminated) as XLFD and store information in FONT
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
728 (font-spec or font-entity). Size property of FONT is set as
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
729 follows:
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
730 specified XLFD fields FONT property
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
731 --------------------- -------------
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
732 PIXEL_SIZE PIXEL_SIZE (Lisp integer)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
733 POINT_SIZE and RESY calculated pixel size (Lisp integer)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
734 POINT_SIZE POINT_SIZE/10 (Lisp float)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
735
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
736 If NAME is successfully parsed, return 0. Otherwise return -1.
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
737
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
738 FONT is usually a font-spec, but when this function is called from
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
739 X font backend driver, it is a font-entity. In that case, NAME is
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
740 a fully specified XLFD, and we set FONT_EXTRA_INDEX of FONT to a
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
741 symbol RESX-RESY-SPACING-AVGWIDTH.
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
742 */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
743
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
744 int
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
745 font_parse_xlfd (name, font)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
746 char *name;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
747 Lisp_Object font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
748 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
749 int len = strlen (name);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
750 int i, j;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
751 Lisp_Object dpi, spacing;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
752 int avgwidth;
90695
a1cd7344d6a2 (font_parse_xlfd): Fix the array size of `f'.
Kenichi Handa <handa@m17n.org>
parents: 90677
diff changeset
753 char *f[XLFD_LAST_INDEX + 1];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
754 Lisp_Object val;
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
755 char *p;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
756
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
757 if (len > 255)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
758 /* Maximum XLFD name length is 255. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
759 return -1;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
760 /* Accept "*-.." as a fully specified XLFD. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
761 if (name[0] == '*' && name[1] == '-')
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
762 i = 1, f[XLFD_FOUNDRY_INDEX] = name;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
763 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
764 i = 0;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
765 for (p = name + i; *p; p++)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
766 if (*p == '-' && i < XLFD_LAST_INDEX)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
767 f[i++] = p + 1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
768 f[i] = p;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
769
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
770 dpi = spacing = Qnil;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
771 avgwidth = -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
772
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
773 if (i == XLFD_LAST_INDEX)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
774 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
775 int pixel_size;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
776
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
777 /* Fully specified XLFD. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
778 for (i = 0, j = FONT_FOUNDRY_INDEX; i < XLFD_WEIGHT_INDEX; i++, j++)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
779 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
780 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
781 if (! NILP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
782 ASET (font, j, val);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
783 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
784 for (j = FONT_WEIGHT_INDEX; i < XLFD_ADSTYLE_INDEX; i++, j++)
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
785 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
786 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
787 if (! NILP (val))
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
788 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
789 Lisp_Object numeric = prop_name_to_numeric (j, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
790
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
791 if (INTEGERP (numeric))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
792 val = numeric;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
793 ASET (font, j, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
794 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
795 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
796 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
797 if (! NILP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
798 ASET (font, FONT_ADSTYLE_INDEX, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
799 i = XLFD_REGISTRY_INDEX;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
800 val = intern_font_field (f[i], f[i + 2] - f[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
801 if (! NILP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
802 ASET (font, FONT_REGISTRY_INDEX, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
803
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
804 p = f[XLFD_PIXEL_INDEX];
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
805 if (*p == '[' && (pixel_size = parse_matrix (p)) >= 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
806 ASET (font, FONT_SIZE_INDEX, make_number (pixel_size));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
807 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
808 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
809 i = XLFD_PIXEL_INDEX;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
810 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
811 if (! NILP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
812 ASET (font, FONT_SIZE_INDEX, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
813 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
814 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
815 double point_size = -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
816
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
817 xassert (FONT_SPEC_P (font));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
818 p = f[XLFD_POINT_INDEX];
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
819 if (*p == '[')
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
820 point_size = parse_matrix (p);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
821 else if (isdigit (*p))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
822 point_size = atoi (p), point_size /= 10;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
823 if (point_size >= 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
824 ASET (font, FONT_SIZE_INDEX, make_float (point_size));
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
825 else
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
826 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
827 i = XLFD_PIXEL_INDEX;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
828 val = intern_font_field (f[i], f[i + 1] - 1 - f[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
829 if (! NILP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
830 ASET (font, FONT_SIZE_INDEX, val);
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
831 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
832 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
833 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
834
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
835 /* Parse RESX, RESY, SPACING, and AVGWIDTH. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
836 if (FONT_ENTITY_P (font))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
837 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
838 i = XLFD_RESX_INDEX;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
839 ASET (font, FONT_EXTRA_INDEX,
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
840 intern_font_field (f[i], f[XLFD_REGISTRY_INDEX] - 1 - f[i]));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
841 return 0;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
842 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
843
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
844 /* Here we just setup DPI, SPACING, and AVGWIDTH. They are set
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
845 in FONT_EXTRA_INDEX later. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
846 i = XLFD_RESX_INDEX;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
847 dpi = intern_font_field (f[i], f[i + 1] - 1 - f[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
848 i = XLFD_SPACING_INDEX;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
849 spacing = intern_font_field (f[i], f[i + 1] - 1 - f[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
850 p = f[XLFD_AVGWIDTH_INDEX];
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
851 if (*p == '~')
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
852 p++;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
853 if (isdigit (*p))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
854 avgwidth = atoi (p);
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
855 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
856 else
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
857 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
858 int wild_card_found = 0;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
859 Lisp_Object prop[XLFD_LAST_INDEX];
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
860
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
861 for (j = 0; j < i; j++)
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
862 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
863 if (*f[j] == '*')
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
864 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
865 if (f[j][1] && f[j][1] != '-')
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
866 return -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
867 prop[j] = Qnil;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
868 wild_card_found = 1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
869 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
870 else if (isdigit (*f[j]))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
871 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
872 for (p = f[j] + 1; isdigit (*p); p++);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
873 if (*p && *p != '-')
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
874 prop[j] = intern_downcase (f[j], p - f[j]);
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
875 else
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
876 prop[j] = make_number (atoi (f[j]));
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
877 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
878 else if (j + 1 < i)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
879 prop[j] = intern_font_field (f[j], f[j + 1] - 1 - f[j]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
880 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
881 prop[j] = intern_font_field (f[j], f[i] - f[j]);
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
882 }
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
883 if (! wild_card_found)
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
884 return -1;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
885 if (font_expand_wildcards (prop, i) < 0)
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
886 return -1;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
887
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
888 for (i = 0, j = FONT_FOUNDRY_INDEX; i < XLFD_WEIGHT_INDEX; i++, j++)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
889 if (! NILP (prop[i]))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
890 ASET (font, j, prop[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
891 for (j = FONT_WEIGHT_INDEX; i < XLFD_ADSTYLE_INDEX; i++, j++)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
892 if (! NILP (prop[i]))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
893 ASET (font, j, prop[i]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
894 if (! NILP (prop[XLFD_ADSTYLE_INDEX]))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
895 ASET (font, FONT_ADSTYLE_INDEX, prop[XLFD_ADSTYLE_INDEX]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
896 val = prop[XLFD_REGISTRY_INDEX];
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
897 if (NILP (val))
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
898 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
899 val = prop[XLFD_ENCODING_INDEX];
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
900 if (! NILP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
901 val = Fintern (concat2 (build_string ("*-"), SYMBOL_NAME (val)),
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
902 Qnil);
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
903 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
904 else if (NILP (prop[XLFD_ENCODING_INDEX]))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
905 val = Fintern (concat2 (SYMBOL_NAME (val), build_string ("-*")),
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
906 Qnil);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
907 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
908 val = Fintern (concat3 (SYMBOL_NAME (val), build_string ("-"),
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
909 SYMBOL_NAME (prop[XLFD_ENCODING_INDEX])),
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
910 Qnil);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
911 if (! NILP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
912 ASET (font, FONT_REGISTRY_INDEX, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
913
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
914 if (INTEGERP (prop[XLFD_PIXEL_INDEX]))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
915 ASET (font, FONT_SIZE_INDEX, prop[XLFD_PIXEL_INDEX]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
916 else if (INTEGERP (prop[XLFD_POINT_INDEX]))
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
917 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
918 double point_size = XINT (prop[XLFD_POINT_INDEX]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
919
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
920 ASET (font, FONT_SIZE_INDEX, make_float (point_size / 10));
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
921 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
922
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
923 dpi = prop[XLFD_RESX_INDEX];
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
924 spacing = prop[XLFD_SPACING_INDEX];
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
925 if (INTEGERP (prop[XLFD_AVGWIDTH_INDEX]))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
926 avgwidth = XINT (prop[XLFD_AVGWIDTH_INDEX]);
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
927 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
928
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
929 if (! NILP (dpi))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
930 font_put_extra (font, QCdpi, dpi);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
931 if (! NILP (spacing))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
932 font_put_extra (font, QCspacing, spacing);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
933 if (avgwidth >= 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
934 font_put_extra (font, QCscalable, avgwidth == 0 ? Qt : Qnil);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
935
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
936 return 0;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
937 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
938
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
939 /* Store XLFD name of FONT (font-spec or font-entity) in NAME (NBYTES
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
940 length), and return the name length. If FONT_SIZE_INDEX of FONT is
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
941 0, use PIXEL_SIZE instead. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
942
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
943 int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
944 font_unparse_xlfd (font, pixel_size, name, nbytes)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
945 Lisp_Object font;
90439
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
946 int pixel_size;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
947 char *name;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
948 int nbytes;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
949 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
950 char *f[XLFD_REGISTRY_INDEX + 1];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
951 Lisp_Object val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
952 int i, j, len = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
953
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
954 xassert (FONTP (font));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
955
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
956 for (i = FONT_FOUNDRY_INDEX, j = XLFD_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
957 i++, j++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
958 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
959 if (i == FONT_ADSTYLE_INDEX)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
960 j = XLFD_ADSTYLE_INDEX;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
961 else if (i == FONT_REGISTRY_INDEX)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
962 j = XLFD_REGISTRY_INDEX;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
963 val = AREF (font, i);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
964 if (NILP (val))
90439
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
965 {
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
966 if (j == XLFD_REGISTRY_INDEX)
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
967 f[j] = "*-*", len += 4;
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
968 else
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
969 f[j] = "*", len += 2;
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
970 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
971 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
972 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
973 if (SYMBOLP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
974 val = SYMBOL_NAME (val);
90439
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
975 if (j == XLFD_REGISTRY_INDEX
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
976 && ! strchr ((char *) SDATA (val), '-'))
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
977 {
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
978 /* Change "jisx0208*" and "jisx0208" to "jisx0208*-*". */
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
979 if (SDATA (val)[SBYTES (val) - 1] == '*')
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
980 {
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
981 f[j] = alloca (SBYTES (val) + 3);
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
982 sprintf (f[j], "%s-*", SDATA (val));
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
983 len += SBYTES (val) + 3;
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
984 }
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
985 else
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
986 {
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
987 f[j] = alloca (SBYTES (val) + 4);
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
988 sprintf (f[j], "%s*-*", SDATA (val));
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
989 len += SBYTES (val) + 4;
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
990 }
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
991 }
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
992 else
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
993 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
994 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
995 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
996
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
997 for (i = FONT_WEIGHT_INDEX, j = XLFD_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
998 i++, j++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
999 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1000 val = AREF (font, i);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1001 if (NILP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1002 f[j] = "*", len += 2;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1003 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1004 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1005 if (INTEGERP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1006 val = prop_numeric_to_name (i, XINT (val));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1007 if (SYMBOLP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1008 val = SYMBOL_NAME (val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1009 xassert (STRINGP (val));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1010 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1011 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1012 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1013
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1014 val = AREF (font, FONT_SIZE_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1015 xassert (NUMBERP (val) || NILP (val));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1016 if (INTEGERP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1017 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1018 f[XLFD_PIXEL_INDEX] = alloca (22);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1019 i = XINT (val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1020 if (i > 0)
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1021 len += sprintf (f[XLFD_PIXEL_INDEX], "%d-*", i) + 1;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1022 else /* i == 0 */
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1023 len += sprintf (f[XLFD_PIXEL_INDEX], "%d-*", pixel_size) + 1;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1024 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1025 else if (FLOATP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1026 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1027 f[XLFD_PIXEL_INDEX] = alloca (12);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1028 i = XFLOAT_DATA (val) * 10;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1029 len += sprintf (f[XLFD_PIXEL_INDEX], "*-%d", i) + 1;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1030 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1031 else
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1032 f[XLFD_PIXEL_INDEX] = "*-*", len += 4;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1033
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1034 val = AREF (font, FONT_EXTRA_INDEX);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1035
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1036 if (FONT_ENTITY_P (font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1037 && EQ (AREF (font, FONT_TYPE_INDEX), Qx))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1038 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1039 /* Setup names for RESX-RESY-SPACING-AVWIDTH. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1040 if (SYMBOLP (val) && ! NILP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1041 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1042 val = SYMBOL_NAME (val);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1043 f[XLFD_RESX_INDEX] = (char *) SDATA (val), len += SBYTES (val) + 1;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1044 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1045 else
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1046 f[XLFD_RESX_INDEX] = "*-*-*-*", len += 6;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1047 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1048 else
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1049 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1050 Lisp_Object dpi = assq_no_quit (QCdpi, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1051 Lisp_Object spacing = assq_no_quit (QCspacing, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1052 Lisp_Object scalable = assq_no_quit (QCscalable, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1053
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1054 if (CONSP (dpi) || CONSP (spacing) || CONSP (scalable))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1055 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1056 char *str = alloca (24);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1057 int this_len;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1058
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1059 if (CONSP (dpi) && INTEGERP (XCDR (dpi)))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1060 this_len = sprintf (str, "%d-%d",
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1061 XINT (XCDR (dpi)), XINT (XCDR (dpi)));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1062 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1063 this_len = sprintf (str, "*-*");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1064 if (CONSP (spacing) && ! NILP (XCDR (spacing)))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1065 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1066 val = XCDR (spacing);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1067 if (INTEGERP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1068 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1069 if (XINT (val) < FONT_SPACING_MONO)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1070 val = Qp;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1071 else if (XINT (val) < FONT_SPACING_CHARCELL)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1072 val = Qm;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1073 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1074 val = Qc;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1075 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1076 xassert (SYMBOLP (val));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1077 this_len += sprintf (str + this_len, "-%c",
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1078 SDATA (SYMBOL_NAME (val))[0]);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1079 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1080 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1081 this_len += sprintf (str + this_len, "-*");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1082 if (CONSP (scalable) && ! NILP (XCDR (spacing)))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1083 this_len += sprintf (str + this_len, "-0");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1084 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1085 this_len += sprintf (str + this_len, "-*");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1086 f[XLFD_RESX_INDEX] = str;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1087 len += this_len;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1088 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1089 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1090 f[XLFD_RESX_INDEX] = "*-*-*-*", len += 8;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1091 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1092
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1093 len++; /* for terminating '\0'. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1094 if (len >= nbytes)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1095 return -1;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1096 return sprintf (name, "-%s-%s-%s-%s-%s-%s-%s-%s-%s",
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1097 f[XLFD_FOUNDRY_INDEX], f[XLFD_FAMILY_INDEX],
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1098 f[XLFD_WEIGHT_INDEX], f[XLFD_SLANT_INDEX],
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1099 f[XLFD_SWIDTH_INDEX],
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1100 f[XLFD_ADSTYLE_INDEX], f[XLFD_PIXEL_INDEX],
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1101 f[XLFD_RESX_INDEX], f[XLFD_REGISTRY_INDEX]);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1102 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1103
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1104 /* Parse NAME (null terminated) as Fonconfig's name format and store
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1105 information in FONT (font-spec or font-entity). If NAME is
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1106 successfully parsed, return 0. Otherwise return -1. */
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1107
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1108 int
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1109 font_parse_fcname (name, font)
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1110 char *name;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1111 Lisp_Object font;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1112 {
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1113 char *p0, *p1;
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1114 int len = strlen (name);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1115 char *copy;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1116
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1117 if (len == 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1118 return -1;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1119 /* It is assured that (name[0] && name[0] != '-'). */
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1120 if (name[0] == ':')
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1121 p0 = name;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1122 else
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1123 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1124 Lisp_Object family;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1125 double point_size;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1126
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1127 for (p0 = name + 1; *p0 && (*p0 != '-' && *p0 != ':'); p0++)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1128 if (*p0 == '\\' && p0[1])
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1129 p0++;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1130 family = intern_font_field (name, p0 - name);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1131 if (*p0 == '-')
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1132 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1133 if (! isdigit (p0[1]))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1134 return -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1135 point_size = strtod (p0 + 1, &p1);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1136 if (*p1 && *p1 != ':')
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1137 return -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1138 ASET (font, FONT_SIZE_INDEX, make_float (point_size));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1139 p0 = p1;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1140 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1141 ASET (font, FONT_FAMILY_INDEX, family);
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1142 }
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1143
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1144 len -= p0 - name;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1145 copy = alloca (len + 1);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1146 if (! copy)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1147 return -1;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1148 name = copy;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1149
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1150 /* Now parse ":KEY=VAL" patterns. Store known keys and values in
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1151 extra, copy unknown ones to COPY. */
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1152 while (*p0)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1153 {
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1154 Lisp_Object key, val;
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1155 int prop;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1156
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1157 for (p1 = p0 + 1; *p1 && *p1 != '=' && *p1 != ':'; p1++);
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1158 if (*p1 != '=')
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1159 {
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1160 /* Must be an enumerated value. */
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1161 val = intern_font_field (p0 + 1, p1 - p0 - 1);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1162 if (memcmp (p0 + 1, "light", 5) == 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1163 || memcmp (p0 + 1, "medium", 6) == 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1164 || memcmp (p0 + 1, "demibold", 8) == 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1165 || memcmp (p0 + 1, "bold", 4) == 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1166 || memcmp (p0 + 1, "black", 5) == 0)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1167 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1168 ASET (font, FONT_WEIGHT_INDEX, val);
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1169 }
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1170 else if (memcmp (p0 + 1, "roman", 5) == 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1171 || memcmp (p0 + 1, "italic", 6) == 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1172 || memcmp (p0 + 1, "oblique", 7) == 0)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1173 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1174 ASET (font, FONT_SLANT_INDEX, val);
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1175 }
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1176 else if (memcmp (p0 + 1, "charcell", 8) == 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1177 || memcmp (p0 + 1, "mono", 4) == 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1178 || memcmp (p0 + 1, "proportional", 12) == 0)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1179 {
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1180 font_put_extra (font, QCspacing,
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1181 (p0[1] == 'c' ? Qc : p0[1] == 'm' ? Qm : Qp));
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1182 }
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1183 else
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1184 {
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1185 /* unknown key */
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1186 bcopy (p0, copy, p1 - p0);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1187 copy += p1 - p0;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1188 }
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1189 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1190 else
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1191 {
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1192 if (memcmp (p0 + 1, "pixelsize=", 10) == 0)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1193 prop = FONT_SIZE_INDEX;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1194 else
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1195 {
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1196 key = intern_font_field (p0, p1 - p0);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1197 prop = get_font_prop_index (key, 0);
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1198 }
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1199 p0 = p1 + 1;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1200 for (p1 = p0; *p1 && *p1 != ':'; p1++);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1201 val = intern_font_field (p0, p1 - p0);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1202 if (! NILP (val))
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1203 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1204 if (prop >= 0 && prop < FONT_EXTRA_INDEX)
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1205 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1206 ASET (font, prop, val);
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1207 }
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1208 else
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1209 font_put_extra (font, key, val);
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1210 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1211 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1212 p0 = p1;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1213 }
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1214
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
1215 return 0;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1216 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1217
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1218 /* Store fontconfig's font name of FONT (font-spec or font-entity) in
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1219 NAME (NBYTES length), and return the name length. If
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1220 FONT_SIZE_INDEX of FONT is 0, use PIXEL_SIZE instead. */
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1221
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1222 int
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1223 font_unparse_fcname (font, pixel_size, name, nbytes)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1224 Lisp_Object font;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1225 int pixel_size;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1226 char *name;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1227 int nbytes;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1228 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1229 Lisp_Object val;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1230 int point_size;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1231 int dpi, spacing, scalable;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1232 int i, len = 1;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1233 char *p;
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1234 Lisp_Object styles[3];
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
1235 char *style_names[3] = { "weight", "slant", "width" };
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1236
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1237 val = AREF (font, FONT_FAMILY_INDEX);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1238 if (SYMBOLP (val) && ! NILP (val))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1239 len += SBYTES (SYMBOL_NAME (val));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1240
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1241 val = AREF (font, FONT_SIZE_INDEX);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1242 if (INTEGERP (val))
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1243 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1244 if (XINT (val) != 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1245 pixel_size = XINT (val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1246 point_size = -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1247 len += 21; /* for ":pixelsize=NUM" */
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1248 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1249 else if (FLOATP (val))
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1250 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1251 pixel_size = -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1252 point_size = (int) XFLOAT_DATA (val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1253 len += 11; /* for "-NUM" */
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1254 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1255
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1256 val = AREF (font, FONT_FOUNDRY_INDEX);
90629
c4849318378c (font_unparse_fcname): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90622
diff changeset
1257 if (SYMBOLP (val) && ! NILP (val))
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1258 /* ":foundry=NAME" */
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1259 len += 9 + SBYTES (SYMBOL_NAME (val));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1260
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1261 for (i = FONT_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; i++)
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1262 {
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1263 val = AREF (font, i);
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1264 if (INTEGERP (val))
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1265 {
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1266 val = prop_numeric_to_name (i, XINT (val));
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1267 len += (strlen (style_names[i - FONT_WEIGHT_INDEX])
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1268 + 2 + SBYTES (SYMBOL_NAME (val))); /* :xxx=NAME */
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1269 }
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1270 styles[i - FONT_WEIGHT_INDEX] = val;
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1271 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1272
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1273 val = AREF (font, FONT_EXTRA_INDEX);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1274 if (FONT_ENTITY_P (font)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1275 && EQ (AREF (font, FONT_TYPE_INDEX), Qx))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1276 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1277 char *p;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1278
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1279 /* VAL is a symbol of name `RESX-RESY-SPACING-AVWIDTH'. */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1280 p = (char *) SDATA (SYMBOL_NAME (val));
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1281 dpi = atoi (p);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1282 for (p++; *p != '-'; p++); /* skip RESX */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1283 for (p++; *p != '-'; p++); /* skip RESY */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1284 spacing = (*p == 'c' ? FONT_SPACING_CHARCELL
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1285 : *p == 'm' ? FONT_SPACING_MONO
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1286 : FONT_SPACING_PROPORTIONAL);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1287 for (p++; *p != '-'; p++); /* skip SPACING */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1288 scalable = (atoi (p) == 0);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1289 /* The longest pattern is ":dpi=NUM:scalable=False:spacing=100" */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1290 len += 42;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1291 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1292 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1293 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1294 Lisp_Object elt;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1295
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1296 dpi = spacing = scalable = -1;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1297 elt = assq_no_quit (QCdpi, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1298 if (CONSP (elt))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1299 dpi = XINT (XCDR (elt)), len += 15; /* for ":dpi=NUM" */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1300 elt = assq_no_quit (QCspacing, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1301 if (CONSP (elt))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1302 spacing = XINT (XCDR (elt)), len += 12; /* for ":spacing=100" */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1303 elt = assq_no_quit (QCscalable, val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1304 if (CONSP (elt))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1305 scalable = ! NILP (XCDR (elt)), len += 15; /* for ":scalable=False" */
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1306 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1307
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1308 if (len > nbytes)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1309 return -1;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1310 p = name;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1311 if (! NILP (AREF (font, FONT_FAMILY_INDEX)))
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1312 p += sprintf(p, "%s",
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1313 SDATA (SYMBOL_NAME (AREF (font, FONT_FAMILY_INDEX))));
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1314 if (point_size > 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1315 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1316 if (p == name)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1317 p += sprintf (p, "%d", point_size);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1318 else
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1319 p += sprintf (p, "-%d", point_size);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1320 }
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1321 else if (pixel_size > 0)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1322 p += sprintf (p, ":pixelsize=%d", pixel_size);
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1323 if (SYMBOLP (AREF (font, FONT_FOUNDRY_INDEX))
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1324 && ! NILP (AREF (font, FONT_FOUNDRY_INDEX)))
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1325 p += sprintf (p, ":foundry=%s",
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1326 SDATA (SYMBOL_NAME (AREF (font, FONT_FOUNDRY_INDEX))));
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1327 for (i = 0; i < 3; i++)
90640
bbc1344cea0e (font_unparse_fcname): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents: 90629
diff changeset
1328 if (SYMBOLP (styles[i]) && ! NILP (styles [i]))
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1329 p += sprintf (p, ":%s=%s", style_names[i],
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
1330 SDATA (SYMBOL_NAME (styles [i])));
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1331 if (dpi >= 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1332 p += sprintf (p, ":dpi=%d", dpi);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1333 if (spacing >= 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1334 p += sprintf (p, ":spacing=%d", spacing);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1335 if (scalable > 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1336 p += sprintf (p, ":scalable=True");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1337 else if (scalable == 0)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1338 p += sprintf (p, ":scalable=False");
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1339 return (p - name);
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1340 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1341
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1342 /* Parse NAME (null terminated) and store information in FONT
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1343 (font-spec or font-entity). If NAME is successfully parsed, return
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1344 0. Otherwise return -1.
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1345
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1346 If NAME is XLFD and FONT is a font-entity, store
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1347 RESX-RESY-SPACING-AVWIDTH information as a symbol in
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1348 FONT_EXTRA_INDEX. */
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1349
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1350 static int
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1351 font_parse_name (name, font)
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1352 char *name;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1353 Lisp_Object font;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1354 {
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1355 if (name[0] == '-' || index (name, '*'))
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1356 return font_parse_xlfd (name, font);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1357 return font_parse_fcname (name, font);
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1358 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
1359
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1360 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1361 font_merge_old_spec (name, family, registry, spec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1362 Lisp_Object name, family, registry, spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1363 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1364 if (STRINGP (name))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1365 {
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
1366 if (font_parse_xlfd ((char *) SDATA (name), spec) < 0)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1367 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1368 Lisp_Object extra = Fcons (Fcons (QCname, name), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1369
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1370 ASET (spec, FONT_EXTRA_INDEX, extra);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1371 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1372 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1373 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1374 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1375 if (! NILP (family))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1376 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1377 int len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1378 char *p0, *p1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1379
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1380 xassert (STRINGP (family));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1381 len = SBYTES (family);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1382 p0 = (char *) SDATA (family);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1383 p1 = index (p0, '-');
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1384 if (p1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1385 {
90530
76d717f9ceda (font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents: 90507
diff changeset
1386 if ((*p0 != '*' || p1 - p0 > 1)
76d717f9ceda (font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents: 90507
diff changeset
1387 && NILP (AREF (spec, FONT_FOUNDRY_INDEX)))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1388 ASET (spec, FONT_FOUNDRY_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1389 intern_downcase (p0, p1 - p0));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1390 if (NILP (AREF (spec, FONT_FAMILY_INDEX)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1391 ASET (spec, FONT_FAMILY_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1392 intern_downcase (p1 + 1, len - (p1 + 1 - p0)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1393 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1394 else if (NILP (AREF (spec, FONT_FAMILY_INDEX)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1395 ASET (spec, FONT_FAMILY_INDEX, intern_downcase (p0, len));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1396 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1397 if (! NILP (registry)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1398 && NILP (AREF (spec, FONT_REGISTRY_INDEX)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1399 ASET (spec, FONT_REGISTRY_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1400 intern_downcase ((char *) SDATA (registry), SBYTES (registry)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1401 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1402 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1403
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1404 static Lisp_Object
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1405 font_lispy_object (font)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1406 struct font *font;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1407 {
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1408 Lisp_Object objlist = AREF (font->entity, FONT_OBJLIST_INDEX);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1409
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1410 for (; ! NILP (objlist); objlist = XCDR (objlist))
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1411 {
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1412 struct Lisp_Save_Value *p = XSAVE_VALUE (XCAR (objlist));
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1413
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1414 if (font == (struct font *) p->pointer)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1415 break;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1416 }
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1417 xassert (! NILP (objlist));
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1418 return XCAR (objlist);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1419 }
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
1420
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1421 #define LGSTRING_HEADER_SIZE 6
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1422 #define LGSTRING_GLYPH_SIZE 8
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1423
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1424 static int
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1425 check_gstring (gstring)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1426 Lisp_Object gstring;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1427 {
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1428 Lisp_Object val;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1429 int i, j;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1430
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1431 CHECK_VECTOR (gstring);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1432 val = AREF (gstring, 0);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1433 CHECK_VECTOR (val);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1434 if (ASIZE (val) < LGSTRING_HEADER_SIZE)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1435 goto err;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1436 CHECK_FONT_OBJECT (LGSTRING_FONT (gstring));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1437 if (! NILP (LGSTRING_LBEARING (gstring)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1438 CHECK_NUMBER (LGSTRING_LBEARING (gstring));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1439 if (! NILP (LGSTRING_RBEARING (gstring)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1440 CHECK_NUMBER (LGSTRING_RBEARING (gstring));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1441 if (! NILP (LGSTRING_WIDTH (gstring)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1442 CHECK_NATNUM (LGSTRING_WIDTH (gstring));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1443 if (! NILP (LGSTRING_ASCENT (gstring)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1444 CHECK_NUMBER (LGSTRING_ASCENT (gstring));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1445 if (! NILP (LGSTRING_DESCENT (gstring)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1446 CHECK_NUMBER (LGSTRING_DESCENT(gstring));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1447
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1448 for (i = 0; i < LGSTRING_LENGTH (gstring); i++)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1449 {
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1450 val = LGSTRING_GLYPH (gstring, i);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1451 CHECK_VECTOR (val);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1452 if (ASIZE (val) < LGSTRING_GLYPH_SIZE)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1453 goto err;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1454 if (NILP (LGLYPH_CHAR (val)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1455 break;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1456 CHECK_NATNUM (LGLYPH_FROM (val));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1457 CHECK_NATNUM (LGLYPH_TO (val));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1458 CHECK_CHARACTER (LGLYPH_CHAR (val));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1459 if (! NILP (LGLYPH_CODE (val)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1460 CHECK_NATNUM (LGLYPH_CODE (val));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1461 if (! NILP (LGLYPH_WIDTH (val)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1462 CHECK_NATNUM (LGLYPH_WIDTH (val));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1463 if (! NILP (LGLYPH_ADJUSTMENT (val)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1464 {
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1465 val = LGLYPH_ADJUSTMENT (val);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1466 CHECK_VECTOR (val);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1467 if (ASIZE (val) < 3)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1468 goto err;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1469 for (j = 0; j < 3; j++)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1470 CHECK_NUMBER (AREF (val, j));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1471 }
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1472 }
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1473 return i;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1474 err:
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1475 error ("Invalid glyph-string format");
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1476 return -1;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1477 }
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
1478
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1479
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1480 /* OTF handler */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1481
90823
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1482 static void
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1483 check_otf_features (otf_features)
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1484 Lisp_Object otf_features;
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1485 {
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1486 Lisp_Object val, elt;
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1487
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1488 CHECK_CONS (otf_features);
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1489 CHECK_SYMBOL (XCAR (otf_features));
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1490 otf_features = XCDR (otf_features);
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1491 CHECK_CONS (otf_features);
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1492 CHECK_SYMBOL (XCAR (otf_features));
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1493 otf_features = XCDR (otf_features);
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1494 for (val = Fcar (otf_features); ! NILP (val); val = Fcdr (val))
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1495 {
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1496 CHECK_SYMBOL (Fcar (val));
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1497 if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4)
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1498 error ("Invalid OTF GSUB feature: %s", SYMBOL_NAME (XCAR (val)));
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1499 }
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1500 otf_features = XCDR (otf_features);
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1501 for (val = Fcar (otf_features); ! NILP (val); val = Fcdr (val))
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1502 {
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1503 CHECK_SYMBOL (Fcar (val));
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1504 if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4)
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1505 error ("Invalid OTF GPOS feature: %s", SYMBOL_NAME (XCAR (val)));
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1506 }
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1507 }
b08ad368c328 (check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents: 90817
diff changeset
1508
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1509 #ifdef HAVE_LIBOTF
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1510 #include <otf.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1511
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1512 Lisp_Object otf_list;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1513
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1514 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1515 otf_tag_symbol (tag)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1516 OTF_Tag tag;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1517 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1518 char name[5];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1519
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1520 OTF_tag_name (tag, name);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1521 return Fintern (make_unibyte_string (name, 4), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1522 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1523
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1524 static OTF *
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1525 otf_open (entity, file)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1526 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1527 char *file;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1528 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1529 Lisp_Object val = Fassoc (entity, otf_list);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1530 OTF *otf;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1531
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1532 if (! NILP (val))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1533 otf = XSAVE_VALUE (XCDR (val))->pointer;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1534 else
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1535 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1536 otf = file ? OTF_open (file) : NULL;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1537 val = make_save_value (otf, 0);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1538 otf_list = Fcons (Fcons (entity, val), otf_list);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1539 }
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1540 return otf;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1541 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1542
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1543
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1544 /* Return a list describing which scripts/languages FONT supports by
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1545 which GSUB/GPOS features of OpenType tables. See the comment of
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1546 (sturct font_driver).otf_capability. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1547
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1548 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1549 font_otf_capability (font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1550 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1551 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1552 OTF *otf;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1553 Lisp_Object capability = Fcons (Qnil, Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1554 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1555
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1556 otf = otf_open (font->entity, font->file_name);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1557 if (! otf)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1558 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1559 for (i = 0; i < 2; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1560 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1561 OTF_GSUB_GPOS *gsub_gpos;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1562 Lisp_Object script_list = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1563 int j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1564
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1565 if (OTF_get_features (otf, i == 0) < 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1566 continue;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1567 gsub_gpos = i == 0 ? otf->gsub : otf->gpos;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1568 for (j = gsub_gpos->ScriptList.ScriptCount - 1; j >= 0; j--)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1569 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1570 OTF_Script *script = gsub_gpos->ScriptList.Script + j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1571 Lisp_Object langsys_list = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1572 Lisp_Object script_tag = otf_tag_symbol (script->ScriptTag);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1573 int k;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1574
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1575 for (k = script->LangSysCount; k >= 0; k--)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1576 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1577 OTF_LangSys *langsys;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1578 Lisp_Object feature_list = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1579 Lisp_Object langsys_tag;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1580 int l;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1581
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1582 if (k == script->LangSysCount)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1583 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1584 langsys = &script->DefaultLangSys;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1585 langsys_tag = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1586 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1587 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1588 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1589 langsys = script->LangSys + k;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1590 langsys_tag
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1591 = otf_tag_symbol (script->LangSysRecord[k].LangSysTag);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1592 }
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1593 for (l = langsys->FeatureCount - 1; l >= 0; l--)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1594 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1595 OTF_Feature *feature
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1596 = gsub_gpos->FeatureList.Feature + langsys->FeatureIndex[l];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1597 Lisp_Object feature_tag
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1598 = otf_tag_symbol (feature->FeatureTag);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1599
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1600 feature_list = Fcons (feature_tag, feature_list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1601 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1602 langsys_list = Fcons (Fcons (langsys_tag, feature_list),
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1603 langsys_list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1604 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1605 script_list = Fcons (Fcons (script_tag, langsys_list),
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1606 script_list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1607 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1608
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1609 if (i == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1610 XSETCAR (capability, script_list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1611 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1612 XSETCDR (capability, script_list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1613 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1614
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1615 return capability;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1616 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1617
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1618 /* Parse OTF features in SPEC and write a proper features spec string
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1619 in FEATURES for the call of OTF_drive_gsub/gpos (of libotf). It is
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1620 assured that the sufficient memory has already allocated for
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1621 FEATURES. */
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1622
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1623 static void
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1624 generate_otf_features (spec, features)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1625 Lisp_Object spec;
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1626 char *features;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1627 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1628 Lisp_Object val;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1629 char *p, *pend;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1630 int asterisk;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1631
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1632 p = features;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1633 *p = '\0';
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1634 for (asterisk = 0; CONSP (spec); spec = XCDR (spec))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1635 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1636 val = XCAR (spec);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1637 CHECK_SYMBOL (val);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1638 if (p > features)
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1639 *p++ = ',';
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1640 if (SREF (SYMBOL_NAME (val), 0) == '*')
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1641 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1642 asterisk = 1;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1643 *p++ = '*';
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1644 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1645 else if (! asterisk)
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1646 {
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1647 val = SYMBOL_NAME (val);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1648 p += sprintf (p, "%s", SDATA (val));
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1649 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1650 else
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1651 {
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1652 val = SYMBOL_NAME (val);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1653 p += sprintf (p, "~%s", SDATA (val));
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1654 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1655 }
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1656 if (CONSP (spec))
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1657 error ("OTF spec too long");
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1658 }
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1659
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1660 #define DEVICE_DELTA(table, size) \
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1661 (((size) >= (table).StartSize && (size) <= (table).EndSize) \
90530
76d717f9ceda (font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents: 90507
diff changeset
1662 ? (table).DeltaValue[(size) - (table).StartSize] \
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1663 : 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1664
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1665 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1666 adjust_anchor (struct font *font, OTF_Anchor *anchor,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1667 unsigned code, int size, int *x, int *y)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1668 {
90883
ce81330d951f (Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents: 90881
diff changeset
1669 if (anchor->AnchorFormat == 2 && font->driver->anchor_point)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1670 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1671 int x0, y0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1672
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1673 if (font->driver->anchor_point (font, code, anchor->f.f1.AnchorPoint,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1674 &x0, &y0) >= 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1675 *x = x0, *y = y0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1676 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1677 else if (anchor->AnchorFormat == 3)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1678 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1679 if (anchor->f.f2.XDeviceTable.offset)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1680 *x += DEVICE_DELTA (anchor->f.f2.XDeviceTable, size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1681 if (anchor->f.f2.YDeviceTable.offset)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1682 *y += DEVICE_DELTA (anchor->f.f2.YDeviceTable, size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1683 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1684 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1685
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1686 Lisp_Object
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1687 font_otf_DeviceTable (device_table)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1688 OTF_DeviceTable *device_table;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1689 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1690 int len = device_table->StartSize - device_table->EndSize + 1;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1691
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1692 return Fcons (make_number (len),
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1693 make_unibyte_string (device_table->DeltaValue, len));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1694 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1695
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1696 Lisp_Object
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1697 font_otf_ValueRecord (value_format, value_record)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1698 int value_format;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1699 OTF_ValueRecord *value_record;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1700 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1701 Lisp_Object val = Fmake_vector (make_number (8), Qnil);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1702
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1703 if (value_format & OTF_XPlacement)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1704 ASET (val, 0, value_record->XPlacement);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1705 if (value_format & OTF_YPlacement)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1706 ASET (val, 1, value_record->YPlacement);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1707 if (value_format & OTF_XAdvance)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1708 ASET (val, 2, value_record->XAdvance);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1709 if (value_format & OTF_YAdvance)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1710 ASET (val, 3, value_record->YAdvance);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1711 if (value_format & OTF_XPlaDevice)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1712 ASET (val, 4, font_otf_DeviceTable (&value_record->XPlaDevice));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1713 if (value_format & OTF_YPlaDevice)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1714 ASET (val, 4, font_otf_DeviceTable (&value_record->YPlaDevice));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1715 if (value_format & OTF_XAdvDevice)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1716 ASET (val, 4, font_otf_DeviceTable (&value_record->XAdvDevice));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1717 if (value_format & OTF_YAdvDevice)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1718 ASET (val, 4, font_otf_DeviceTable (&value_record->YAdvDevice));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1719 return val;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1720 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1721
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1722 Lisp_Object
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1723 font_otf_Anchor (anchor)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1724 OTF_Anchor *anchor;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1725 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1726 Lisp_Object val;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1727
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1728 val = Fmake_vector (make_number (anchor->AnchorFormat + 1), Qnil);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1729 ASET (val, 0, make_number (anchor->XCoordinate));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1730 ASET (val, 1, make_number (anchor->YCoordinate));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1731 if (anchor->AnchorFormat == 2)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1732 ASET (val, 2, make_number (anchor->f.f1.AnchorPoint));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1733 else
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1734 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1735 ASET (val, 3, font_otf_DeviceTable (&anchor->f.f2.XDeviceTable));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1736 ASET (val, 4, font_otf_DeviceTable (&anchor->f.f2.YDeviceTable));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1737 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1738 return val;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1739 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1740
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1741 #define REPLACEMENT_CHARACTER 0xFFFD
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1742
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1743 /* Drive FONT's OpenType FEATURES. See the comment of (sturct
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1744 font_driver).drive_otf. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1745
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1746 int
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1747 font_drive_otf (font, otf_features, gstring_in, from, to, gstring_out, idx,
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1748 alternate_subst)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1749 struct font *font;
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1750 Lisp_Object otf_features;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1751 Lisp_Object gstring_in;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1752 int from, to;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1753 Lisp_Object gstring_out;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1754 int idx, alternate_subst;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1755 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1756 Lisp_Object val;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1757 int len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1758 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1759 OTF *otf;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1760 OTF_GlyphString otf_gstring;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1761 OTF_Glyph *g;
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1762 char *script, *langsys = NULL, *gsub_features = NULL, *gpos_features = NULL;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1763 int need_cmap;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1764
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1765 val = XCAR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1766 script = SDATA (SYMBOL_NAME (val));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1767 otf_features = XCDR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1768 val = XCAR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1769 langsys = NILP (val) ? NULL : SDATA (SYMBOL_NAME (val));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1770 otf_features = XCDR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1771 val = XCAR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1772 if (! NILP (val))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1773 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1774 gsub_features = alloca (XINT (Flength (val)) * 6);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1775 generate_otf_features (val, &script, &langsys, gsub_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1776 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1777 otf_features = XCDR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1778 val = XCAR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1779 if (! NILP (val))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1780 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1781 gpos_features = alloca (XINT (Flength (val)) * 6);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1782 generate_otf_features (val, &script, &langsys, gpos_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1783 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1784
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1785 otf = otf_open (font->entity, font->file_name);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1786 if (! otf)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1787 return 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1788 if (OTF_get_table (otf, "head") < 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1789 return 0;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1790 if (OTF_get_table (otf, "cmap") < 0)
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1791 return 0;
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1792 if ((! gsub_features || OTF_check_table (otf, "GSUB") < 0)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1793 && (! gpos_features || OTF_check_table (otf, "GPOS") < 0))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1794 return 0;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1795
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1796 len = to - from;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1797 otf_gstring.size = otf_gstring.used = len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1798 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1799 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1800 for (i = 0, need_cmap = 0; i < len; i++)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1801 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1802 Lisp_Object g = LGSTRING_GLYPH (gstring_in, from + i);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1803
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1804 otf_gstring.glyphs[i].c = XINT (LGLYPH_CHAR (g));
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1805 if (otf_gstring.glyphs[i].c == REPLACEMENT_CHARACTER)
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1806 otf_gstring.glyphs[i].c = 0;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1807 if (NILP (LGLYPH_CODE (g)))
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1808 {
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1809 otf_gstring.glyphs[i].glyph_id = 0;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1810 need_cmap = 1;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1811 }
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1812 else
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1813 otf_gstring.glyphs[i].glyph_id = XINT (LGLYPH_CODE (g));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1814 }
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1815 if (need_cmap)
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1816 OTF_drive_cmap (otf, &otf_gstring);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1817 OTF_drive_gdef (otf, &otf_gstring);
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1818
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1819 if (gsub_features)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1820 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1821 if ((alternate_subst
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1822 ? OTF_drive_gsub_alternate (otf, &otf_gstring, script, langsys,
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1823 gsub_features)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1824 : OTF_drive_gsub (otf, &otf_gstring, script, langsys,
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1825 gsub_features)) < 0)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1826 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1827 free (otf_gstring.glyphs);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1828 return 0;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1829 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1830 if (ASIZE (gstring_out) < idx + otf_gstring.used)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1831 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1832 free (otf_gstring.glyphs);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1833 return -1;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1834 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1835 for (i = 0, g = otf_gstring.glyphs; i < otf_gstring.used;)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1836 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1837 int i0 = g->f.index.from, i1 = g->f.index.to;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1838 Lisp_Object glyph = LGSTRING_GLYPH (gstring_in, from + i0);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1839 Lisp_Object min_idx = AREF (glyph, 0);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1840 Lisp_Object max_idx = AREF (glyph, 1);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1841
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1842 if (i0 < i1)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1843 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1844 int min_idx_i = XINT (min_idx), max_idx_i = XINT (max_idx);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1845
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1846 for (i0++; i0 <= i1; i0++)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1847 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1848 glyph = LGSTRING_GLYPH (gstring_in, from + i0);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1849 if (min_idx_i > XINT (AREF (glyph, 0)))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1850 min_idx_i = XINT (AREF (glyph, 0));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1851 if (max_idx_i < XINT (AREF (glyph, 1)))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1852 max_idx_i = XINT (AREF (glyph, 1));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1853 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1854 min_idx = make_number (min_idx_i);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1855 max_idx = make_number (max_idx_i);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1856 i0 = g->f.index.from;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1857 }
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1858 for (; i < otf_gstring.used && g->f.index.from == i0; i++, g++)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1859 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1860 glyph = LGSTRING_GLYPH (gstring_out, idx + i);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1861 ASET (glyph, 0, min_idx);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1862 ASET (glyph, 1, max_idx);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1863 if (g->c > 0)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1864 LGLYPH_SET_CHAR (glyph, make_number (g->c));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1865 else
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1866 LGLYPH_SET_CHAR (glyph, make_number (REPLACEMENT_CHARACTER));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1867 LGLYPH_SET_CODE (glyph, make_number (g->glyph_id));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1868 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1869 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1870 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1871
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1872 if (gpos_features)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1873 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1874 Lisp_Object glyph;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1875 int u = otf->head->unitsPerEm;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1876 int size = font->pixel_size;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1877 Lisp_Object base = Qnil, mark = Qnil;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1878
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1879 if (OTF_drive_gpos (otf, &otf_gstring, script, langsys,
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1880 gpos_features) < 0)
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1881 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1882 free (otf_gstring.glyphs);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1883 return 0;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1884 }
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1885 for (i = 0, g = otf_gstring.glyphs; i < otf_gstring.used; i++, g++)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1886 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1887 Lisp_Object prev;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1888 int xoff = 0, yoff = 0, width_adjust = 0;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1889
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1890 if (! g->glyph_id)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1891 continue;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1892
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1893 switch (g->positioning_type)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1894 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1895 case 0:
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1896 break;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1897 case 1: case 2:
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1898 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1899 int format = g->f.f1.format;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1900
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1901 if (format & OTF_XPlacement)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1902 xoff = g->f.f1.value->XPlacement * size / u;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1903 if (format & OTF_XPlaDevice)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1904 xoff += DEVICE_DELTA (g->f.f1.value->XPlaDevice, size);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1905 if (format & OTF_YPlacement)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1906 yoff = - (g->f.f1.value->YPlacement * size / u);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1907 if (format & OTF_YPlaDevice)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1908 yoff -= DEVICE_DELTA (g->f.f1.value->YPlaDevice, size);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1909 if (format & OTF_XAdvance)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1910 width_adjust += g->f.f1.value->XAdvance * size / u;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1911 if (format & OTF_XAdvDevice)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1912 width_adjust += DEVICE_DELTA (g->f.f1.value->XAdvDevice, size);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1913 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1914 break;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1915 case 3:
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1916 /* Not yet supported. */
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1917 break;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1918 case 4: case 5:
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1919 if (NILP (base))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1920 break;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1921 prev = base;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1922 goto label_adjust_anchor;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1923 default: /* i.e. case 6 */
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1924 if (NILP (mark))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1925 break;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1926 prev = mark;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1927
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1928 label_adjust_anchor:
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1929 {
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1930 int base_x, base_y, mark_x, mark_y, width;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1931 unsigned code;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1932
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1933 base_x = g->f.f4.base_anchor->XCoordinate * size / u;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1934 base_y = g->f.f4.base_anchor->YCoordinate * size / u;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1935 mark_x = g->f.f4.mark_anchor->XCoordinate * size / u;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1936 mark_y = g->f.f4.mark_anchor->YCoordinate * size / u;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1937
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1938 code = XINT (LGLYPH_CODE (prev));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1939 if (g->f.f4.base_anchor->AnchorFormat != 1)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1940 adjust_anchor (font, g->f.f4.base_anchor,
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1941 code, size, &base_x, &base_y);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1942 if (g->f.f4.mark_anchor->AnchorFormat != 1)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1943 adjust_anchor (font, g->f.f4.mark_anchor,
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1944 code, size, &mark_x, &mark_y);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1945
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1946 if (NILP (LGLYPH_WIDTH (prev)))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1947 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1948 width = font->driver->text_extents (font, &code, 1, NULL);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1949 LGLYPH_SET_WIDTH (prev, make_number (width));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1950 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1951 else
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1952 width = XINT (LGLYPH_WIDTH (prev));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1953 xoff = XINT (LGLYPH_XOFF (prev)) + (base_x - width) - mark_x;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1954 yoff = XINT (LGLYPH_YOFF (prev)) + mark_y - base_y;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1955 }
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1956 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1957 if (xoff || yoff || width_adjust)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1958 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1959 Lisp_Object adjustment = Fmake_vector (make_number (3), Qnil);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1960
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1961 ASET (adjustment, 0, make_number (xoff));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1962 ASET (adjustment, 1, make_number (yoff));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1963 ASET (adjustment, 2, make_number (width_adjust));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1964 LGLYPH_SET_ADJUSTMENT (glyph, adjustment);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1965 }
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1966 if (g->GlyphClass == OTF_GlyphClass0)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1967 base = mark = glyph;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1968 else if (g->GlyphClass == OTF_GlyphClassMark)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1969 mark = glyph;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1970 else
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
1971 base = glyph;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1972 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1973 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1974
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1975 free (otf_gstring.glyphs);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1976 return i;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1977 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1978
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1979 #endif /* HAVE_LIBOTF */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1980
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1981
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1982 /* G-string (glyph string) handler */
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1983
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1984 /* G-string is a vector of the form [HEADER GLYPH ...].
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
1985 See the docstring of `font-make-gstring' for more detail. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1986
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1987 struct font *
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1988 font_prepare_composition (cmp)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1989 struct composition *cmp;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1990 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1991 Lisp_Object gstring
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1992 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1993 cmp->hash_index * 2);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1994 struct font *font = XSAVE_VALUE (LGSTRING_FONT (gstring))->pointer;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1995 int len = LGSTRING_LENGTH (gstring);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1996 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1997
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1998 cmp->font = font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1999 cmp->lbearing = cmp->rbearing = cmp->pixel_width = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2000 cmp->ascent = font->ascent;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2001 cmp->descent = font->descent;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2002
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2003 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2004 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2005 Lisp_Object g = LGSTRING_GLYPH (gstring, i);
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2006 unsigned code;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2007 struct font_metrics metrics;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2008
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2009 if (NILP (LGLYPH_FROM (g)))
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2010 break;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2011 code = XINT (LGLYPH_CODE (g));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2012 font->driver->text_extents (font, &code, 1, &metrics);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2013 LGLYPH_SET_WIDTH (g, make_number (metrics.width));
90530
76d717f9ceda (font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents: 90507
diff changeset
2014 metrics.lbearing += LGLYPH_XOFF (g);
76d717f9ceda (font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents: 90507
diff changeset
2015 metrics.rbearing += LGLYPH_XOFF (g);
76d717f9ceda (font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents: 90507
diff changeset
2016 metrics.ascent += LGLYPH_YOFF (g);
76d717f9ceda (font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents: 90507
diff changeset
2017 metrics.descent += LGLYPH_YOFF (g);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2018
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2019 if (cmp->lbearing > cmp->pixel_width + metrics.lbearing)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2020 cmp->lbearing = cmp->pixel_width + metrics.lbearing;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2021 if (cmp->rbearing < cmp->pixel_width + metrics.rbearing)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2022 cmp->rbearing = cmp->pixel_width + metrics.rbearing;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2023 if (cmp->ascent < metrics.ascent)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2024 cmp->ascent = metrics.ascent;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2025 if (cmp->descent < metrics.descent)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2026 cmp->descent = metrics.descent;
90530
76d717f9ceda (font_merge_old_spec): Treat '*' in foundry as a wild
Kenichi Handa <handa@m17n.org>
parents: 90507
diff changeset
2027 cmp->pixel_width += metrics.width + LGLYPH_WADJUST (g);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2028 }
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
2029 cmp->glyph_len = i;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2030 LGSTRING_SET_LBEARING (gstring, make_number (cmp->lbearing));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2031 LGSTRING_SET_RBEARING (gstring, make_number (cmp->rbearing));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2032 LGSTRING_SET_WIDTH (gstring, make_number (cmp->pixel_width));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2033 LGSTRING_SET_ASCENT (gstring, make_number (cmp->ascent));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2034 LGSTRING_SET_DESCENT (gstring, make_number (cmp->descent));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2035
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2036 return font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2037 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2038
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2039 int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2040 font_gstring_produce (old, from, to, new, idx, code, n)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2041 Lisp_Object old;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2042 int from, to;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2043 Lisp_Object new;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2044 int idx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2045 unsigned *code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2046 int n;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2047 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2048 Lisp_Object min_idx, max_idx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2049 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2050
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2051 if (idx + n > ASIZE (new))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2052 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2053 if (from == to)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2054 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2055 if (from == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2056 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2057 min_idx = make_number (0);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2058 max_idx = make_number (1);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2059 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2060 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2061 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2062 min_idx = AREF (AREF (old, from - 1), 0);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2063 max_idx = AREF (AREF (old, from - 1), 1);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2064 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2065 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2066 else if (from + 1 == to)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2067 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2068 min_idx = AREF (AREF (old, from), 0);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2069 max_idx = AREF (AREF (old, from), 1);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2070 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2071 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2072 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2073 int min_idx_i = XINT (AREF (AREF (old, from), 0));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2074 int max_idx_i = XINT (AREF (AREF (old, from), 1));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2075
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2076 for (i = from + 1; i < to; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2077 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2078 if (min_idx_i > XINT (AREF (AREF (old, i), 0)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2079 min_idx_i = XINT (AREF (AREF (old, i), 0));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2080 if (max_idx_i < XINT (AREF (AREF (old, i), 1)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2081 max_idx_i = XINT (AREF (AREF (old, i), 1));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2082 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2083 min_idx = make_number (min_idx_i);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2084 max_idx = make_number (max_idx_i);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2085 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2086
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2087 for (i = 0; i < n; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2088 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2089 ASET (AREF (new, idx + i), 0, min_idx);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2090 ASET (AREF (new, idx + i), 1, max_idx);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2091 ASET (AREF (new, idx + i), 2, make_number (code[i]));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2092 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2093
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2094 return 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2095 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2096
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2097 /* Font sorting */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2098
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2099 static unsigned font_score P_ ((Lisp_Object, Lisp_Object *));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2100 static int font_compare P_ ((const void *, const void *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2101 static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2102 Lisp_Object, Lisp_Object));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2103
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2104 /* We sort fonts by scoring each of them against a specified
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2105 font-spec. The score value is 32 bit (`unsigned'), and the smaller
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2106 the value is, the closer the font is to the font-spec.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2107
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2108 Each 1-bit in the highest 4 bits of the score is used for atomic
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2109 properties FOUNDRY, FAMILY, ADSTYLE, and REGISTRY.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2110
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2111 Each 7-bit in the lowest 28 bits are used for numeric properties
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2112 WEIGHT, SLANT, WIDTH, and SIZE. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2113
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2114 /* How many bits to shift to store the difference value of each font
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2115 property in a score. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2116 static int sort_shift_bits[FONT_SIZE_INDEX + 1];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2117
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2118 /* Score font-entity ENTITY against properties of font-spec SPEC_PROP.
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2119 The return value indicates how different ENTITY is compared with
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2120 SPEC_PROP. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2121
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2122 static unsigned
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2123 font_score (entity, spec_prop)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2124 Lisp_Object entity, *spec_prop;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2125 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2126 unsigned score = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2127 int i;
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2128 /* Score four atomic fields. Maximum difference is 1. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2129 for (i = FONT_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; i++)
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2130 if (! NILP (spec_prop[i])
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2131 && ! EQ (spec_prop[i], AREF (entity, i)))
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2132 score |= 1 << sort_shift_bits[i];
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2133
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2134 /* Score four numeric fields. Maximum difference is 127. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2135 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2136 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2137 Lisp_Object entity_val = AREF (entity, i);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2138
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2139 if (! NILP (spec_prop[i]) && ! EQ (spec_prop[i], entity_val))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2140 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2141 if (! INTEGERP (entity_val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2142 score |= 127 << sort_shift_bits[i];
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2143 else
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2144 {
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2145 int diff = XINT (entity_val) - XINT (spec_prop[i]);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2146
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2147 if (diff < 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2148 diff = - diff;
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2149 if (i == FONT_SIZE_INDEX)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2150 {
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2151 if (XINT (entity_val) > 0
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2152 && diff > FONT_PIXEL_SIZE_QUANTUM)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2153 score |= min (diff, 127) << sort_shift_bits[i];
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2154 }
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2155 else
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2156 score |= min (diff, 127) << sort_shift_bits[i];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2157 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2158 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2159 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2160
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2161 return score;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2162 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2163
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2164
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2165 /* The comparison function for qsort. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2166
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2167 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2168 font_compare (d1, d2)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2169 const void *d1, *d2;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2170 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2171 return (*(unsigned *) d1 < *(unsigned *) d2
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2172 ? -1 : *(unsigned *) d1 > *(unsigned *) d2);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2173 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2174
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2175
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2176 /* The structure for elements being sorted by qsort. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2177 struct font_sort_data
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2178 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2179 unsigned score;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2180 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2181 };
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2182
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2183
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2184 /* Sort font-entities in vector VEC by closeness to font-spec PREFER.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2185 If PREFER specifies a point-size, calculate the corresponding
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2186 pixel-size from QCdpi property of PREFER or from the Y-resolution
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2187 of FRAME before sorting. If SPEC is not nil, it is a font-spec to
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2188 get the font-entities in VEC. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2189
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2190 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2191 font_sort_entites (vec, prefer, frame, spec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2192 Lisp_Object vec, prefer, frame, spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2193 {
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2194 Lisp_Object prefer_prop[FONT_SPEC_MAX];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2195 int len, i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2196 struct font_sort_data *data;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2197 USE_SAFE_ALLOCA;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2198
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2199 len = ASIZE (vec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2200 if (len <= 1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2201 return vec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2202
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2203 for (i = FONT_FOUNDRY_INDEX; i <= FONT_SIZE_INDEX; i++)
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2204 prefer_prop[i] = AREF (prefer, i);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2205
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2206 if (! NILP (spec))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2207 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2208 /* As it is assured that all fonts in VEC match with SPEC, we
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2209 should ignore properties specified in SPEC. So, set the
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2210 corresponding properties in PREFER_PROP to nil. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2211 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++)
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2212 if (! NILP (AREF (spec, i)))
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2213 prefer_prop[i++] = Qnil;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2214 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2215
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2216 if (FLOATP (prefer_prop[FONT_SIZE_INDEX]))
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2217 prefer_prop[FONT_SIZE_INDEX]
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2218 = make_number (font_pixel_size (XFRAME (frame), prefer));
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2219
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2220 /* Scoring and sorting. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2221 SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2222 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2223 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2224 data[i].entity = AREF (vec, i);
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2225 data[i].score = font_score (data[i].entity, prefer_prop);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2226 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2227 qsort (data, len, sizeof *data, font_compare);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2228 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2229 ASET (vec, i, data[i].entity);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2230 SAFE_FREE ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2231
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2232 return vec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2233 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2234
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2235
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2236 /* API of Font Service Layer. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2237
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2238 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2239 font_update_sort_order (order)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2240 int *order;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2241 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2242 int i, shift_bits = 21;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2243
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2244 for (i = 0; i < 4; i++, shift_bits -= 7)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2245 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2246 int xlfd_idx = order[i];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2247
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2248 if (xlfd_idx == XLFD_WEIGHT_INDEX)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2249 sort_shift_bits[FONT_WEIGHT_INDEX] = shift_bits;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2250 else if (xlfd_idx == XLFD_SLANT_INDEX)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2251 sort_shift_bits[FONT_SLANT_INDEX] = shift_bits;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2252 else if (xlfd_idx == XLFD_SWIDTH_INDEX)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2253 sort_shift_bits[FONT_WIDTH_INDEX] = shift_bits;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2254 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2255 sort_shift_bits[FONT_SIZE_INDEX] = shift_bits;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2256 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2257 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2258
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2259 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2260 font_symbolic_weight (font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2261 Lisp_Object font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2262 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2263 Lisp_Object weight = AREF (font, FONT_WEIGHT_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2264
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2265 if (INTEGERP (weight))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2266 weight = prop_numeric_to_name (FONT_WEIGHT_INDEX, XINT (weight));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2267 return weight;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2268 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2269
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2270 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2271 font_symbolic_slant (font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2272 Lisp_Object font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2273 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2274 Lisp_Object slant = AREF (font, FONT_SLANT_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2275
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2276 if (INTEGERP (slant))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2277 slant = prop_numeric_to_name (FONT_SLANT_INDEX, XINT (slant));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2278 return slant;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2279 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2280
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2281 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2282 font_symbolic_width (font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2283 Lisp_Object font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2284 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2285 Lisp_Object width = AREF (font, FONT_WIDTH_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2286
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2287 if (INTEGERP (width))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2288 width = prop_numeric_to_name (FONT_WIDTH_INDEX, XINT (width));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2289 return width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2290 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2291
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2292 int
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2293 font_match_p (spec, entity)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2294 Lisp_Object spec, entity;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2295 {
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2296 int i;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2297
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2298 for (i = FONT_FOUNDRY_INDEX; i < FONT_SIZE_INDEX; i++)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2299 if (! NILP (AREF (spec, i))
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2300 && ! EQ (AREF (spec, i), AREF (entity, i)))
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2301 return 0;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2302 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX))
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2303 && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2304 && (XINT (AREF (spec, FONT_SIZE_INDEX))
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2305 != XINT (AREF (entity, FONT_SIZE_INDEX))))
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2306 return 0;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2307 return 1;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2308 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2309
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2310 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2311 font_find_object (font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2312 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2313 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2314 Lisp_Object tail, elt;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2315
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2316 for (tail = AREF (font->entity, FONT_OBJLIST_INDEX); CONSP (tail);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2317 tail = XCDR (tail))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2318 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2319 elt = XCAR (tail);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2320 if (font == XSAVE_VALUE (elt)->pointer
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2321 && XSAVE_VALUE (elt)->integer > 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2322 return elt;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2323 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2324 abort ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2325 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2326 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2327
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2328 static Lisp_Object scratch_font_spec, scratch_font_prefer;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2329
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2330 /* Return a vector of font-entities matching with SPEC on frame F. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2331
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2332 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2333 font_list_entities (frame, spec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2334 Lisp_Object frame, spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2335 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2336 FRAME_PTR f = XFRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2337 struct font_driver_list *driver_list = f->font_driver_list;
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2338 Lisp_Object ftype, family, size, alternate_familes;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2339 Lisp_Object *vec = alloca (sizeof (Lisp_Object) * num_font_drivers);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2340 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2341
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2342 if (! vec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2343 return null_vector;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2344
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2345 family = AREF (spec, FONT_FAMILY_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2346 if (NILP (family))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2347 alternate_familes = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2348 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2349 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2350 if (NILP (font_family_alist)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2351 && !NILP (Vface_alternative_font_family_alist))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2352 build_font_family_alist ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2353 alternate_familes = assq_no_quit (family, font_family_alist);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2354 if (! NILP (alternate_familes))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2355 alternate_familes = XCDR (alternate_familes);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2356 }
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2357 size = AREF (spec, FONT_SIZE_INDEX);
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2358 if (FLOATP (size))
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2359 ASET (spec, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec)));
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2360
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2361 xassert (ASIZE (spec) == FONT_SPEC_MAX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2362 ftype = AREF (spec, FONT_TYPE_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2363
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2364 for (i = 0; driver_list; driver_list = driver_list->next)
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2365 if (driver_list->on
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2366 && (NILP (ftype) || EQ (driver_list->driver->type, ftype)))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2367 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2368 Lisp_Object cache = driver_list->driver->get_cache (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2369 Lisp_Object tail = alternate_familes;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2370 Lisp_Object val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2371
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2372 xassert (CONSP (cache));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2373 ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2374 ASET (spec, FONT_FAMILY_INDEX, family);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2375
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2376 while (1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2377 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2378 val = assoc_no_quit (spec, XCDR (cache));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2379 if (CONSP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2380 val = XCDR (val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2381 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2382 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2383 val = driver_list->driver->list (frame, spec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2384 if (VECTORP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2385 XSETCDR (cache, Fcons (Fcons (Fcopy_sequence (spec), val),
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2386 XCDR (cache)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2387 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2388 if (VECTORP (val) && ASIZE (val) > 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2389 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2390 vec[i++] = val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2391 break;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2392 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2393 if (NILP (tail))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2394 break;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2395 ASET (spec, FONT_FAMILY_INDEX, XCAR (tail));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2396 tail = XCDR (tail);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2397 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2398 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2399 ASET (spec, FONT_TYPE_INDEX, ftype);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2400 ASET (spec, FONT_FAMILY_INDEX, family);
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2401 ASET (spec, FONT_SIZE_INDEX, size);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2402 return (i > 0 ? Fvconcat (i, vec) : null_vector);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2403 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2404
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2405 static Lisp_Object
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2406 font_matching_entity (frame, spec)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2407 Lisp_Object frame, spec;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2408 {
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2409 FRAME_PTR f = XFRAME (frame);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2410 struct font_driver_list *driver_list = f->font_driver_list;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2411 Lisp_Object ftype, size, entity;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2412
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2413 ftype = AREF (spec, FONT_TYPE_INDEX);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2414 size = AREF (spec, FONT_SIZE_INDEX);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2415 if (FLOATP (size))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2416 ASET (spec, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec)));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2417 entity = Qnil;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2418 for (; driver_list; driver_list = driver_list->next)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2419 if (driver_list->on
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2420 && (NILP (ftype) || EQ (driver_list->driver->type, ftype)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2421 {
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2422 Lisp_Object cache = driver_list->driver->get_cache (frame);
90590
bad57814fca3 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 90563
diff changeset
2423 Lisp_Object key;
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2424
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2425 xassert (CONSP (cache));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2426 ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2427 key = Fcons (spec, Qnil);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2428 entity = assoc_no_quit (key, XCDR (cache));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2429 if (CONSP (entity))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2430 entity = XCDR (entity);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2431 else
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2432 {
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2433 entity = driver_list->driver->match (frame, spec);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2434 if (! NILP (entity))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2435 {
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2436 XSETCAR (key, Fcopy_sequence (spec));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2437 XSETCDR (cache, Fcons (Fcons (key, entity), XCDR (cache)));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2438 }
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2439 }
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2440 if (! NILP (entity))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2441 break;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2442 }
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2443 ASET (spec, FONT_TYPE_INDEX, ftype);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2444 ASET (spec, FONT_SIZE_INDEX, size);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2445 return entity;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2446 }
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2447
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2448 static int num_fonts;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2449
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2450 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2451 font_open_entity (f, entity, pixel_size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2452 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2453 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2454 int pixel_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2455 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2456 struct font_driver_list *driver_list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2457 Lisp_Object objlist, size, val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2458 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2459
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2460 size = AREF (entity, FONT_SIZE_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2461 xassert (NATNUMP (size));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2462 if (XINT (size) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2463 pixel_size = XINT (size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2464
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2465 for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2466 objlist = XCDR (objlist))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2467 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2468 font = XSAVE_VALUE (XCAR (objlist))->pointer;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2469 if (font->pixel_size == pixel_size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2470 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2471 XSAVE_VALUE (XCAR (objlist))->integer++;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2472 return XCAR (objlist);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2473 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2474 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2475
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2476 xassert (FONT_ENTITY_P (entity));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2477 val = AREF (entity, FONT_TYPE_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2478 for (driver_list = f->font_driver_list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2479 driver_list && ! EQ (driver_list->driver->type, val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2480 driver_list = driver_list->next);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2481 if (! driver_list)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2482 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2483
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2484 font = driver_list->driver->open (f, entity, pixel_size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2485 if (! font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2486 return Qnil;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
2487 font->scalable = XINT (size) == 0;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
2488
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2489 val = make_save_value (font, 1);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2490 ASET (entity, FONT_OBJLIST_INDEX,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2491 Fcons (val, AREF (entity, FONT_OBJLIST_INDEX)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2492 num_fonts++;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2493 return val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2494 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2495
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2496 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2497 font_close_object (f, font_object)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2498 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2499 Lisp_Object font_object;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2500 {
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2501 struct font *font = XSAVE_VALUE (font_object)->pointer;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2502 Lisp_Object objlist;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2503 Lisp_Object tail, prev = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2504
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2505 XSAVE_VALUE (font_object)->integer--;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2506 xassert (XSAVE_VALUE (font_object)->integer >= 0);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2507 if (XSAVE_VALUE (font_object)->integer > 0)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2508 return;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2509
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2510 objlist = AREF (font->entity, FONT_OBJLIST_INDEX);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2511 for (prev = Qnil, tail = objlist; CONSP (tail);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2512 prev = tail, tail = XCDR (tail))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2513 if (EQ (font_object, XCAR (tail)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2514 {
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2515 if (font->driver->close)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2516 font->driver->close (f, font);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2517 XSAVE_VALUE (font_object)->pointer = NULL;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2518 if (NILP (prev))
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2519 ASET (font->entity, FONT_OBJLIST_INDEX, XCDR (objlist));
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2520 else
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2521 XSETCDR (prev, XCDR (objlist));
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2522 return;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2523 }
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2524 abort ();
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2525 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2526
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2527 int
90490
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2528 font_has_char (f, font, c)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2529 FRAME_PTR f;
90490
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2530 Lisp_Object font;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2531 int c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2532 {
90490
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2533 struct font *fontp;
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2534
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2535 if (FONT_ENTITY_P (font))
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2536 {
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2537 Lisp_Object type = AREF (font, FONT_TYPE_INDEX);
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2538 struct font_driver_list *driver_list;
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2539
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2540 for (driver_list = f->font_driver_list;
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2541 driver_list && ! EQ (driver_list->driver->type, type);
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2542 driver_list = driver_list->next);
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2543 if (! driver_list)
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2544 return 0;
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2545 if (! driver_list->driver->has_char)
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2546 return -1;
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2547 return driver_list->driver->has_char (font, c);
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2548 }
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2549
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2550 xassert (FONT_OBJECT_P (font));
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2551 fontp = XSAVE_VALUE (font)->pointer;
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2552
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2553 if (fontp->driver->has_char)
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2554 {
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2555 int result = fontp->driver->has_char (fontp->entity, c);
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2556
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2557 if (result >= 0)
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2558 return result;
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2559 }
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2560 return (fontp->driver->encode_char (fontp, c) != FONT_INVALID_CODE);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2561 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2562
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2563 unsigned
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2564 font_encode_char (font_object, c)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2565 Lisp_Object font_object;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2566 int c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2567 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2568 struct font *font = XSAVE_VALUE (font_object)->pointer;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2569
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2570 return font->driver->encode_char (font, c);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2571 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2572
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2573 Lisp_Object
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2574 font_get_name (font_object)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2575 Lisp_Object font_object;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2576 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2577 struct font *font = XSAVE_VALUE (font_object)->pointer;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2578 char *name = (font->font.full_name ? font->font.full_name
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2579 : font->font.name ? font->font.name
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2580 : NULL);
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2581
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2582 return (name ? make_unibyte_string (name, strlen (name)) : null_string);
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2583 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2584
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2585 Lisp_Object
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2586 font_get_spec (font_object)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2587 Lisp_Object font_object;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2588 {
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2589 struct font *font = XSAVE_VALUE (font_object)->pointer;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2590 Lisp_Object spec = Ffont_spec (0, NULL);
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2591 int i;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2592
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2593 for (i = 0; i < FONT_SIZE_INDEX; i++)
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2594 ASET (spec, i, AREF (font->entity, i));
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2595 ASET (spec, FONT_SIZE_INDEX, make_number (font->pixel_size));
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2596 return spec;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2597 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2598
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2599 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2600 font_get_frame (font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2601 Lisp_Object font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2602 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2603 if (FONT_OBJECT_P (font))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2604 font = ((struct font *) XSAVE_VALUE (font)->pointer)->entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2605 xassert (FONT_ENTITY_P (font));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2606 return AREF (font, FONT_FRAME_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2607 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2608
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2609 /* Find a font entity best matching with LFACE. If SPEC is non-nil,
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2610 the font must exactly match with it. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2611
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2612 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2613 font_find_for_lface (f, lface, spec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2614 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2615 Lisp_Object *lface;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2616 Lisp_Object spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2617 {
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2618 Lisp_Object frame, entities;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2619 int i;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2620
90507
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2621 XSETFRAME (frame, f);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2622
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2623 if (NILP (spec))
90490
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2624 {
90507
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2625 for (i = 0; i < FONT_SPEC_MAX; i++)
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2626 ASET (scratch_font_spec, i, Qnil);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2627 ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso8859_1);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2628
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2629 if (! NILP (lface[LFACE_FAMILY_INDEX]))
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2630 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil,
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2631 scratch_font_spec);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2632 entities = font_list_entities (frame, scratch_font_spec);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2633 while (ASIZE (entities) == 0)
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2634 {
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2635 /* Try without FOUNDRY or FAMILY. */
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2636 if (! NILP (AREF (scratch_font_spec, FONT_FOUNDRY_INDEX)))
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2637 {
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2638 ASET (scratch_font_spec, FONT_FOUNDRY_INDEX, Qnil);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2639 entities = font_list_entities (frame, scratch_font_spec);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2640 }
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2641 else if (! NILP (AREF (scratch_font_spec, FONT_FAMILY_INDEX)))
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2642 {
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2643 ASET (scratch_font_spec, FONT_FAMILY_INDEX, Qnil);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2644 entities = font_list_entities (frame, scratch_font_spec);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2645 }
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2646 else
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2647 break;
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2648 }
90490
8ef2cbaf626a (font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents: 90483
diff changeset
2649 }
90507
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2650 else
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2651 {
90507
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2652 for (i = 0; i < FONT_SPEC_MAX; i++)
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2653 ASET (scratch_font_spec, i, AREF (spec, i));
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2654 if (NILP (AREF (spec, FONT_REGISTRY_INDEX)))
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2655 ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso8859_1);
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2656 entities = font_list_entities (frame, scratch_font_spec);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2657 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2658
90507
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2659 if (ASIZE (entities) == 0)
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2660 return Qnil;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2661 if (ASIZE (entities) > 1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2662 {
90507
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2663 /* Sort fonts by properties specified in LFACE. */
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2664 Lisp_Object prefer = scratch_font_prefer;
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2665 double pt;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2666
90507
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2667 if (! NILP (lface[LFACE_FAMILY_INDEX]))
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
2668 font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, prefer);
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2669 ASET (prefer, FONT_WEIGHT_INDEX,
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2670 font_prop_validate_style (FONT_WEIGHT_INDEX, QCweight,
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2671 lface[LFACE_WEIGHT_INDEX]));
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2672 ASET (prefer, FONT_SLANT_INDEX,
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2673 font_prop_validate_style (FONT_SLANT_INDEX, QCslant,
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2674 lface[LFACE_SLANT_INDEX]));
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2675 ASET (prefer, FONT_WIDTH_INDEX,
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2676 font_prop_validate_style (FONT_WIDTH_INDEX, QCwidth,
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2677 lface[LFACE_SWIDTH_INDEX]));
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2678 pt = XINT (lface[LFACE_HEIGHT_INDEX]);
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2679 ASET (prefer, FONT_SIZE_INDEX, make_float (pt / 10));
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2680
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2681 font_sort_entites (entities, prefer, frame, spec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2682 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2683
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2684 return AREF (entities, 0);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2685 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2686
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2687 Lisp_Object
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2688 font_open_for_lface (f, entity, lface, spec)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2689 FRAME_PTR f;
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2690 Lisp_Object entity;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2691 Lisp_Object *lface;
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2692 Lisp_Object spec;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2693 {
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2694 int size;
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2695
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2696 if (FONT_SPEC_P (spec) && INTEGERP (AREF (spec, FONT_SIZE_INDEX)))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2697 size = XINT (AREF (spec, FONT_SIZE_INDEX));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2698 else
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2699 {
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2700 double pt = XINT (lface[LFACE_HEIGHT_INDEX]);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2701
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2702 pt /= 10;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2703 size = POINT_TO_PIXEL (pt, f->resy);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2704 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2705 return font_open_entity (f, entity, size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2706 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2707
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2708 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2709 font_load_for_face (f, face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2710 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2711 struct face *face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2712 {
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2713 Lisp_Object font_object = face->lface[LFACE_FONT_INDEX];
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2714
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2715 if (NILP (font_object))
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2716 {
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2717 Lisp_Object entity = font_find_for_lface (f, face->lface, Qnil);
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2718
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2719 if (! NILP (entity))
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
2720 font_object = font_open_for_lface (f, entity, face->lface, Qnil);
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2721 }
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2722
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2723 if (! NILP (font_object))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2724 {
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2725 struct font *font = XSAVE_VALUE (font_object)->pointer;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2726
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2727 face->font = font->font.font;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2728 face->font_info = (struct font_info *) font;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2729 face->font_info_id = 0;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2730 face->font_name = font->font.full_name;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2731 }
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2732 else
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2733 {
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2734 face->font = NULL;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2735 face->font_info = NULL;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2736 face->font_info_id = -1;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2737 face->font_name = NULL;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2738 add_to_log ("Unable to load font for a face%s", null_string, Qnil);
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2739 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2740 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2741
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2742 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2743 font_prepare_for_face (f, face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2744 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2745 struct face *face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2746 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2747 struct font *font = (struct font *) face->font_info;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2748
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2749 if (font->driver->prepare_face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2750 font->driver->prepare_face (f, face);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2751 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2752
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2753 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2754 font_done_for_face (f, face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2755 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2756 struct face *face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2757 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2758 struct font *font = (struct font *) face->font_info;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2759
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2760 if (font->driver->done_face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2761 font->driver->done_face (f, face);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2762 face->extra = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2763 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2764
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2765 Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2766 font_open_by_name (f, name)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2767 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2768 char *name;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2769 {
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2770 Lisp_Object args[2];
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2771 Lisp_Object spec, prefer, size, entity, entity_list;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2772 Lisp_Object frame;
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2773 int i;
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2774 int pixel_size;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2775
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2776 XSETFRAME (frame, f);
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2777
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2778 args[0] = QCname;
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2779 args[1] = make_unibyte_string (name, strlen (name));
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2780 spec = Ffont_spec (2, args);
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2781 prefer = scratch_font_prefer;
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2782 for (i = FONT_WEIGHT_INDEX; i < FONT_SIZE_INDEX; i++)
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2783 if (NILP (AREF (spec, i)))
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2784 ASET (prefer, i, make_number (100));
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2785 size = AREF (spec, FONT_SIZE_INDEX);
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2786 if (NILP (size))
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2787 pixel_size = 0;
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2788 else if (INTEGERP (size))
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2789 pixel_size = XINT (size);
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2790 else /* FLOATP (size) */
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2791 {
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2792 double pt = XFLOAT_DATA (size);
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2793
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2794 pixel_size = POINT_TO_PIXEL (pt, f->resy);
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2795 size = make_number (pixel_size);
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2796 ASET (spec, FONT_SIZE_INDEX, size);
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2797 }
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2798 if (pixel_size == 0)
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2799 {
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2800 pixel_size = POINT_TO_PIXEL (12.0, f->resy);
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2801 size = make_number (pixel_size);
90468
5424215feef6 (XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents: 90451
diff changeset
2802 }
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2803 ASET (prefer, FONT_SIZE_INDEX, size);
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2804 if (NILP (AREF (spec, FONT_REGISTRY_INDEX)))
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
2805 ASET (spec, FONT_REGISTRY_INDEX, Qiso8859_1);
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2806
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2807 entity_list = Flist_fonts (spec, frame, make_number (1), prefer);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2808 if (NILP (entity_list))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2809 entity = font_matching_entity (frame, spec);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2810 else
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2811 entity = XCAR (entity_list);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2812 return (NILP (entity)
90476
017a6aec5d77 (font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents: 90468
diff changeset
2813 ? Qnil
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2814 : font_open_entity (f, entity, pixel_size));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2815 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2816
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2817
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2818 /* Register font-driver DRIVER. This function is used in two ways.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2819
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2820 The first is with frame F non-NULL. In this case, make DRIVER
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2821 available (but not yet activated) on F. All frame creaters
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2822 (e.g. Fx_create_frame) must call this function at least once with
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2823 an available font-driver.
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2824
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2825 The second is with frame F NULL. In this case, DRIVER is globally
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2826 registered in the variable `font_driver_list'. All font-driver
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2827 implementations must call this function in its syms_of_XXXX
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2828 (e.g. syms_of_xfont). */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2829
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2830 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2831 register_font_driver (driver, f)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2832 struct font_driver *driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2833 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2834 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2835 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2836 struct font_driver_list *prev, *list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2837
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2838 if (f && ! driver->draw)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2839 error ("Unsable font driver for a frame: %s",
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2840 SDATA (SYMBOL_NAME (driver->type)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2841
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2842 for (prev = NULL, list = root; list; prev = list, list = list->next)
90695
a1cd7344d6a2 (font_parse_xlfd): Fix the array size of `f'.
Kenichi Handa <handa@m17n.org>
parents: 90677
diff changeset
2843 if (EQ (list->driver->type, driver->type))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2844 error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2845
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2846 list = malloc (sizeof (struct font_driver_list));
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2847 list->on = 0;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2848 list->driver = driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2849 list->next = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2850 if (prev)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2851 prev->next = list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2852 else if (f)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2853 f->font_driver_list = list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2854 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2855 font_driver_list = list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2856 num_font_drivers++;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2857 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2858
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2859 /* Free font-driver list on frame F. It doesn't free font-drivers
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2860 themselves. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2861
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2862 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2863 free_font_driver_list (f)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2864 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2865 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2866 while (f->font_driver_list)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2867 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2868 struct font_driver_list *next = f->font_driver_list->next;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2869
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2870 free (f->font_driver_list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2871 f->font_driver_list = next;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2872 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2873 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2874
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2875 /* Make the frame F use font backends listed in NEW_BACKENDS (list of
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2876 symbols). If NEW_BACKENDS is nil, make F use all available font
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2877 drivers. If no backend is available, dont't alter
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2878 f->font_driver_list.
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2879
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2880 A caller must free all realized faces and clear all font caches if
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2881 any in advance. The return value is a list of font backends
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2882 actually made used for on F. */
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2883
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2884 Lisp_Object
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2885 font_update_drivers (f, new_drivers)
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2886 FRAME_PTR f;
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2887 Lisp_Object new_drivers;
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2888 {
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2889 Lisp_Object active_drivers = Qnil;
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2890 struct font_driver_list *list;
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2891
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2892 /* At first check which font backends are available. */
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2893 for (list = f->font_driver_list; list; list = list->next)
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2894 if (NILP (new_drivers)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2895 || ! NILP (Fmemq (list->driver->type, new_drivers)))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2896 {
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2897 list->on = 2;
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2898 active_drivers = nconc2 (active_drivers,
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2899 Fcons (list->driver->type, Qnil));
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2900 }
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2901 /* If at least one backend is available, update all list->on. */
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2902 if (! NILP (active_drivers))
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2903 for (list = f->font_driver_list; list; list = list->next)
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2904 list->on = (list->on == 2);
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2905
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2906 return active_drivers;
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2907 }
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2908
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
2909
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2910 Lisp_Object
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2911 font_at (c, pos, face, w, object)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2912 int c;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2913 EMACS_INT pos;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2914 struct face *face;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2915 struct window *w;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2916 Lisp_Object object;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2917 {
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2918 FRAME_PTR f;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2919 int face_id;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2920 int dummy;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2921
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2922 f = XFRAME (w->frame);
90811
c1ed0fd37416 (font_at): If the window W is not on a window system,
Kenichi Handa <handa@m17n.org>
parents: 90695
diff changeset
2923 if (! FRAME_WINDOW_P (f))
c1ed0fd37416 (font_at): If the window W is not on a window system,
Kenichi Handa <handa@m17n.org>
parents: 90695
diff changeset
2924 return Qnil;
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2925 if (! face)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2926 {
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2927 if (STRINGP (object))
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2928 face_id = face_at_string_position (w, object, pos, 0, -1, -1, &dummy,
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2929 DEFAULT_FACE_ID, 0);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2930 else
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2931 face_id = face_at_buffer_position (w, pos, -1, -1, &dummy,
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2932 pos + 100, 0);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2933 face = FACE_FROM_ID (f, face_id);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2934 }
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2935 face_id = FACE_FOR_CHAR (f, face, c, pos, object);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2936 face = FACE_FROM_ID (f, face_id);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2937 if (! face->font_info)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2938 return Qnil;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2939 return font_lispy_object ((struct font *) face->font_info);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2940 }
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2941
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2942
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2943 /* Lisp API */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2944
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2945 DEFUN ("fontp", Ffontp, Sfontp, 1, 1, 0,
90993
a9e96c4a1a90 (Ffontp): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 90903
diff changeset
2946 doc: /* Return t if OBJECT is a font-spec or font-entity. */)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2947 (object)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2948 Lisp_Object object;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2949 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2950 return (FONTP (object) ? Qt : Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2951 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2952
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2953 DEFUN ("font-spec", Ffont_spec, Sfont_spec, 0, MANY, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2954 doc: /* Return a newly created font-spec with specified arguments as properties.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2955 usage: (font-spec &rest properties) */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2956 (nargs, args)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2957 int nargs;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2958 Lisp_Object *args;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2959 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2960 Lisp_Object spec = Fmake_vector (make_number (FONT_SPEC_MAX), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2961 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2962
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2963 for (i = 0; i < nargs; i += 2)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2964 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2965 enum font_property_index prop;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2966 Lisp_Object key = args[i], val = args[i + 1];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2967
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2968 prop = get_font_prop_index (key, 0);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2969 if (prop < FONT_EXTRA_INDEX)
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2970 ASET (spec, prop, val);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2971 else
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
2972 {
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
2973 if (EQ (key, QCname))
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2974 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2975 CHECK_STRING (val);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2976 font_parse_name ((char *) SDATA (val), spec);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2977 }
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2978 font_put_extra (spec, key, val);
90451
6ffc9b378367 (enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents: 90448
diff changeset
2979 }
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2980 }
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
2981 CHECK_VALIDATE_FONT_SPEC (spec);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2982 return spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2983 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2984
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2985
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2986 DEFUN ("font-get", Ffont_get, Sfont_get, 2, 2, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2987 doc: /* Return the value of FONT's PROP property.
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2988 FONT is a font-spec, a font-entity, or a font-object. */)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2989 (font, prop)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2990 Lisp_Object font, prop;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2991 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2992 enum font_property_index idx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2993
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
2994 if (FONT_OBJECT_P (font))
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
2995 {
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
2996 struct font *fontp = XSAVE_VALUE (font)->pointer;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
2997
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
2998 if (EQ (prop, QCotf))
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
2999 {
90881
7bf78e56f04f (Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents: 90823
diff changeset
3000 if (fontp->driver->otf_capability)
7bf78e56f04f (Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents: 90823
diff changeset
3001 return fontp->driver->otf_capability (fontp);
7bf78e56f04f (Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents: 90823
diff changeset
3002 else
7bf78e56f04f (Ffont_get): Use font driver to determine otf capability.
Jason Rumney <jasonr@gnu.org>
parents: 90823
diff changeset
3003 return Qnil;
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
3004 }
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3005 font = fontp->entity;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3006 }
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3007 else
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3008 CHECK_FONT (font);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3009 idx = get_font_prop_index (prop, 0);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3010 if (idx < FONT_EXTRA_INDEX)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3011 return AREF (font, idx);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3012 if (FONT_ENTITY_P (font))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3013 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3014 return Fcdr (Fassoc (AREF (font, FONT_EXTRA_INDEX), prop));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3015 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3016
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3017
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3018 DEFUN ("font-put", Ffont_put, Sfont_put, 3, 3, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3019 doc: /* Set one property of FONT-SPEC: give property PROP value VALUE. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3020 (font_spec, prop, val)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3021 Lisp_Object font_spec, prop, val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3022 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3023 enum font_property_index idx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3024 Lisp_Object extra, slot;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3025
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3026 CHECK_FONT_SPEC (font_spec);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3027 idx = get_font_prop_index (prop, 0);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3028 if (idx < FONT_EXTRA_INDEX)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3029 return ASET (font_spec, idx, val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3030 extra = AREF (font_spec, FONT_EXTRA_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3031 slot = Fassoc (extra, prop);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3032 if (NILP (slot))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3033 extra = Fcons (Fcons (prop, val), extra);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3034 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3035 Fsetcdr (slot, val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3036 return val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3037 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3038
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3039 DEFUN ("list-fonts", Flist_fonts, Slist_fonts, 1, 4, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3040 doc: /* List available fonts matching FONT-SPEC on the current frame.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3041 Optional 2nd argument FRAME specifies the target frame.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3042 Optional 3rd argument NUM, if non-nil, limits the number of returned fonts.
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3043 Optional 4th argument PREFER, if non-nil, is a font-spec
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3044 to which closeness fonts are sorted. */)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3045 (font_spec, frame, num, prefer)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3046 Lisp_Object font_spec, frame, num, prefer;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3047 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3048 Lisp_Object vec, list, tail;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3049 int n = 0, i, len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3050
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3051 if (NILP (frame))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3052 frame = selected_frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3053 CHECK_LIVE_FRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3054 CHECK_VALIDATE_FONT_SPEC (font_spec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3055 if (! NILP (num))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3056 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3057 CHECK_NUMBER (num);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3058 n = XINT (num);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3059 if (n <= 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3060 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3061 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3062 if (! NILP (prefer))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3063 CHECK_FONT (prefer);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3064
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3065 vec = font_list_entities (frame, font_spec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3066 len = ASIZE (vec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3067 if (len == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3068 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3069 if (len == 1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3070 return Fcons (AREF (vec, 0), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3071
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3072 if (! NILP (prefer))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3073 vec = font_sort_entites (vec, prefer, frame, font_spec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3074
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3075 list = tail = Fcons (AREF (vec, 0), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3076 if (n == 0 || n > len)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3077 n = len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3078 for (i = 1; i < n; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3079 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3080 Lisp_Object val = Fcons (AREF (vec, i), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3081
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3082 XSETCDR (tail, val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3083 tail = val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3084 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3085 return list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3086 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3087
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3088 DEFUN ("list-families", Flist_families, Slist_families, 0, 1, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3089 doc: /* List available font families on the current frame.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3090 Optional 2nd argument FRAME specifies the target frame. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3091 (frame)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3092 Lisp_Object frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3093 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3094 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3095 struct font_driver_list *driver_list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3096 Lisp_Object list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3097
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3098 if (NILP (frame))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3099 frame = selected_frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3100 CHECK_LIVE_FRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3101 f = XFRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3102 list = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3103 for (driver_list = f->font_driver_list; driver_list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3104 driver_list = driver_list->next)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3105 if (driver_list->driver->list_family)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3106 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3107 Lisp_Object val = driver_list->driver->list_family (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3108
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3109 if (NILP (list))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3110 list = val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3111 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3112 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3113 Lisp_Object tail = list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3114
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3115 for (; CONSP (val); val = XCDR (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3116 if (NILP (Fmemq (XCAR (val), tail)))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3117 list = Fcons (XCAR (val), list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3118 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3119 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3120 return list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3121 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3122
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3123 DEFUN ("find-font", Ffind_font, Sfind_font, 1, 2, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3124 doc: /* Return a font-entity matching with FONT-SPEC on the current frame.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3125 Optional 2nd argument FRAME, if non-nil, specifies the target frame. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3126 (font_spec, frame)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3127 Lisp_Object font_spec, frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3128 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3129 Lisp_Object val = Flist_fonts (font_spec, frame, make_number (1), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3130
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3131 if (CONSP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3132 val = XCAR (val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3133 return val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3134 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3135
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3136 DEFUN ("font-xlfd-name", Ffont_xlfd_name, Sfont_xlfd_name, 1, 1, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3137 doc: /* Return XLFD name of FONT.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3138 FONT is a font-spec, font-entity, or font-object.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3139 If the name is too long for XLFD (maximum 255 chars), return nil. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3140 (font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3141 Lisp_Object font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3142 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3143 char name[256];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3144 int pixel_size = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3145
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3146 if (FONT_SPEC_P (font))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3147 CHECK_VALIDATE_FONT_SPEC (font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3148 else if (FONT_ENTITY_P (font))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3149 CHECK_FONT (font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3150 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3151 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3152 struct font *fontp;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3153
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3154 CHECK_FONT_GET_OBJECT (font, fontp);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3155 font = fontp->entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3156 pixel_size = fontp->pixel_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3157 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3158
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3159 if (font_unparse_xlfd (font, pixel_size, name, 256) < 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3160 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3161 return build_string (name);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3162 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3163
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3164 DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3165 doc: /* Clear font cache. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3166 ()
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3167 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3168 Lisp_Object list, frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3169
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3170 FOR_EACH_FRAME (list, frame)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3171 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3172 FRAME_PTR f = XFRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3173 struct font_driver_list *driver_list = f->font_driver_list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3174
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3175 for (; driver_list; driver_list = driver_list->next)
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3176 if (driver_list->on)
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3177 {
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3178 Lisp_Object cache = driver_list->driver->get_cache (frame);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3179 Lisp_Object tail, elt;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3180
90549
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3181 for (tail = XCDR (cache); CONSP (tail); tail = XCDR (tail))
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3182 {
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3183 elt = XCAR (tail);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3184 if (CONSP (elt) && FONT_SPEC_P (XCAR (elt)))
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3185 {
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3186 Lisp_Object vec = XCDR (elt);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3187 int i;
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3188
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3189 for (i = 0; i < ASIZE (vec); i++)
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3190 {
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3191 Lisp_Object entity = AREF (vec, i);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3192
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3193 if (EQ (driver_list->driver->type,
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3194 AREF (entity, FONT_TYPE_INDEX)))
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3195 {
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3196 Lisp_Object objlist
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3197 = AREF (entity, FONT_OBJLIST_INDEX);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3198
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3199 for (; CONSP (objlist); objlist = XCDR (objlist))
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3200 {
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3201 Lisp_Object val = XCAR (objlist);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3202 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3203 struct font *font = p->pointer;
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3204
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3205 xassert (font && (driver_list->driver
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3206 == font->driver));
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3207 driver_list->driver->close (f, font);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3208 p->pointer = NULL;
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3209 p->integer = 0;
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3210 }
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3211 if (driver_list->driver->free_entity)
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3212 driver_list->driver->free_entity (entity);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3213 }
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3214 }
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3215 }
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3216 }
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3217 XSETCDR (cache, Qnil);
5dab62a4573c (font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents: 90541
diff changeset
3218 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3219 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3220
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3221 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3222 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3223
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3224 DEFUN ("internal-set-font-style-table", Finternal_set_font_style_table,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3225 Sinternal_set_font_style_table, 2, 2, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3226 doc: /* Set font style table for PROP to TABLE.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3227 PROP must be `:weight', `:slant', or `:width'.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3228 TABLE must be an alist of symbols vs the corresponding numeric values
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3229 sorted by numeric values. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3230 (prop, table)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3231 Lisp_Object prop, table;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3232 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3233 int table_index;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3234 int numeric;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3235 Lisp_Object tail, val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3236
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3237 CHECK_SYMBOL (prop);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3238 table_index = (EQ (prop, QCweight) ? 0
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3239 : EQ (prop, QCslant) ? 1
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3240 : EQ (prop, QCwidth) ? 2
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3241 : 3);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3242 if (table_index >= ASIZE (font_style_table))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3243 error ("Invalid font style property: %s", SDATA (SYMBOL_NAME (prop)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3244 table = Fcopy_sequence (table);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3245 numeric = -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3246 for (tail = table; ! NILP (tail); tail = Fcdr (tail))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3247 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3248 prop = Fcar (Fcar (tail));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3249 val = Fcdr (Fcar (tail));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3250 CHECK_SYMBOL (prop);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3251 CHECK_NATNUM (val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3252 if (numeric > XINT (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3253 error ("Numeric values not sorted for %s", SDATA (SYMBOL_NAME (prop)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3254 numeric = XINT (val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3255 XSETCAR (tail, Fcons (prop, val));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3256 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3257 ASET (font_style_table, table_index, table);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3258 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3259 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3260
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3261 DEFUN ("font-make-gstring", Ffont_make_gstring, Sfont_make_gstring, 2, 2, 0,
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3262 doc: /* Return a newly created g-string for FONT-OBJECT with NUM glyphs.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3263 FONT-OBJECT may be nil if it is not yet known.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3264
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3265 G-string is sequence of glyphs of a specific font,
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3266 and is a vector of this form:
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3267 [ HEADER GLYPH ... ]
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3268 HEADER is a vector of this form:
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3269 [FONT-OBJECT LBEARING RBEARING WIDTH ASCENT DESCENT]
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3270 where
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3271 FONT-OBJECT is a font-object for all glyphs in the g-string,
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3272 LBEARING thry DESCENT is the metrics (in pixels) of the whole G-string.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3273 GLYPH is a vector of this form:
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3274 [ FROM-IDX TO-IDX C CODE WIDTH [ [X-OFF Y-OFF WADJUST] | nil] ]
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3275 where
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3276 FROM-IDX and TO-IDX are used internally and should not be touched.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3277 C is the character of the glyph.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3278 CODE is the glyph-code of C in FONT-OBJECT.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3279 X-OFF and Y-OFF are offests to the base position for the glyph.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3280 WIDTH is the normal width of the glyph.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3281 WADJUST is the adjustment to the normal width of the glyph. */)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3282 (font_object, num)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3283 Lisp_Object font_object, num;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3284 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3285 Lisp_Object gstring, g;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3286 int len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3287 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3288
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3289 if (! NILP (font_object))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3290 CHECK_FONT_OBJECT (font_object);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3291 CHECK_NATNUM (num);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3292
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3293 len = XINT (num) + 1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3294 gstring = Fmake_vector (make_number (len), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3295 g = Fmake_vector (make_number (6), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3296 ASET (g, 0, font_object);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3297 ASET (gstring, 0, g);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3298 for (i = 1; i < len; i++)
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3299 ASET (gstring, i, Fmake_vector (make_number (8), Qnil));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3300 return gstring;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3301 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3302
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3303 DEFUN ("font-fill-gstring", Ffont_fill_gstring, Sfont_fill_gstring, 4, 5, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3304 doc: /* Fillin glyph-string GSTRING by characters for FONT-OBJECT.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3305 START and END specifies the region to extract characters.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3306 If optional 3rd argument OBJECT is non-nil, it is a buffer or a string from
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3307 where to extract characters.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3308 FONT-OBJECT may be nil if GSTRING already already contains one. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3309 (gstring, font_object, start, end, object)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3310 Lisp_Object gstring, font_object, start, end, object;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3311 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3312 int len, i, c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3313 unsigned code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3314 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3315
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3316 CHECK_VECTOR (gstring);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3317 if (NILP (font_object))
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3318 font_object = LGSTRING_FONT (gstring);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3319 CHECK_FONT_GET_OBJECT (font_object, font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3320
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3321 if (STRINGP (object))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3322 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3323 const unsigned char *p;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3324
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3325 CHECK_NATNUM (start);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3326 CHECK_NATNUM (end);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3327 if (XINT (start) > XINT (end)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3328 || XINT (end) > ASIZE (object)
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3329 || XINT (end) - XINT (start) > LGSTRING_LENGTH (gstring))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3330 args_out_of_range (start, end);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3331
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3332 len = XINT (end) - XINT (start);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3333 p = SDATA (object) + string_char_to_byte (object, XINT (start));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3334 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3335 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3336 Lisp_Object g = LGSTRING_GLYPH (gstring, i);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3337
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3338 c = STRING_CHAR_ADVANCE (p);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3339 code = font->driver->encode_char (font, c);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3340 if (code > MOST_POSITIVE_FIXNUM)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3341 error ("Glyph code 0x%X is too large", code);
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3342 LGLYPH_SET_FROM (g, make_number (i));
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3343 LGLYPH_SET_TO (g, make_number (i + 1));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3344 LGLYPH_SET_CHAR (g, make_number (c));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3345 LGLYPH_SET_CODE (g, make_number (code));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3346 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3347 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3348 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3349 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3350 int pos, pos_byte;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3351
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3352 if (! NILP (object))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3353 Fset_buffer (object);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3354 validate_region (&start, &end);
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3355 if (XINT (end) - XINT (start) > LGSTRING_LENGTH (gstring))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3356 args_out_of_range (start, end);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3357 len = XINT (end) - XINT (start);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3358 pos = XINT (start);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3359 pos_byte = CHAR_TO_BYTE (pos);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3360 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3361 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3362 Lisp_Object g = LGSTRING_GLYPH (gstring, i);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3363
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3364 FETCH_CHAR_ADVANCE (c, pos, pos_byte);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3365 code = font->driver->encode_char (font, c);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3366 if (code > MOST_POSITIVE_FIXNUM)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3367 error ("Glyph code 0x%X is too large", code);
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3368 LGLYPH_SET_FROM (g, make_number (i));
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3369 LGLYPH_SET_TO (g, make_number (i + 1));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3370 LGLYPH_SET_CHAR (g, make_number (c));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3371 LGLYPH_SET_CODE (g, make_number (code));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3372 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3373 }
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3374 for (i = LGSTRING_LENGTH (gstring) - 1; i >= len; i--)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3375 {
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3376 Lisp_Object g = LGSTRING_GLYPH (gstring, i);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3377
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3378 LGLYPH_SET_FROM (g, Qnil);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3379 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3380 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3381 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3382
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3383 DEFUN ("font-drive-otf", Ffont_drive_otf, Sfont_drive_otf, 6, 6, 0,
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3384 doc: /* Apply OpenType features on glyph-string GSTRING-IN.
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3385 OTF-SPEC specifies which featuress to apply in this format:
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3386 (SCRIPT LANGSYS GSUB GPOS)
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3387 where
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3388 SCRIPT is a symbol specifying a script tag of OpenType,
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3389 LANGSYS is a symbol specifying a langsys tag of OpenType,
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3390 GSUB and GPOS, if non-nil, are lists of symbols specifying feature tags.
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3391
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3392 If LANGYS is nil, the default langsys is selected.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3393
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3394 The features are applied in the order appeared in the list. The
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3395 symbol `*' means to apply all available features not appeared in this
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3396 list, and the remaining features are ignored. For instance, (vatu
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3397 pstf * haln) is to apply vatu and pstf in this order, then to apply
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3398 all available features other than vatu, pstf, and haln.
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3399
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3400 The features are applied to the glyphs in the range FROM and TO of
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3401 the glyph-string GSTRING-IN.
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3402
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3403 If some of a feature is actually applicable, the resulting glyphs are
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3404 produced in the glyph-string GSTRING-OUT from the index INDEX. In
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3405 this case, the value is the number of produced glyphs.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3406
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3407 If no feature is applicable, no glyph is produced in GSTRING-OUT, and
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3408 the value is 0.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3409
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3410 If GSTRING-OUT is too short to hold produced glyphs, no glyphs is
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3411 produced in GSTRING-OUT, and the value is nil.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3412
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3413 See the documentation of `font-make-gstring' for the format of
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3414 glyph-string. */)
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3415 (otf_features, gstring_in, from, to, gstring_out, index)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3416 Lisp_Object otf_features, gstring_in, from, to, gstring_out, index;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3417 {
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3418 Lisp_Object font_object = LGSTRING_FONT (gstring_in);
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3419 Lisp_Object val;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3420 struct font *font;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3421 int len, num;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3422
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3423 check_otf_features (otf_features);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3424 CHECK_FONT_GET_OBJECT (font_object, font);
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3425 if (! font->driver->otf_drive)
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3426 error ("Font backend %s can't drive OpenType GSUB table",
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3427 SDATA (SYMBOL_NAME (font->driver->type)));
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3428 CHECK_CONS (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3429 CHECK_SYMBOL (XCAR (otf_features));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3430 val = XCDR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3431 CHECK_SYMBOL (XCAR (val));
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3432 val = XCDR (otf_features);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3433 if (! NILP (val))
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3434 CHECK_CONS (val);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3435 len = check_gstring (gstring_in);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3436 CHECK_VECTOR (gstring_out);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3437 CHECK_NATNUM (from);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3438 CHECK_NATNUM (to);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3439 CHECK_NATNUM (index);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3440
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3441 if (XINT (from) >= XINT (to) || XINT (to) > len)
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3442 args_out_of_range_3 (from, to, make_number (len));
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3443 if (XINT (index) >= ASIZE (gstring_out))
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3444 args_out_of_range (index, make_number (ASIZE (gstring_out)));
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3445 num = font->driver->otf_drive (font, otf_features,
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3446 gstring_in, XINT (from), XINT (to),
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3447 gstring_out, XINT (index), 0);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3448 if (num < 0)
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3449 return Qnil;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3450 return make_number (num);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3451 }
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3452
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3453 DEFUN ("font-otf-alternates", Ffont_otf_alternates, Sfont_otf_alternates,
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3454 3, 3, 0,
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3455 doc: /* Return a list of alternate glyphs of CHARACTER in FONT-OBJECT.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3456 FEATURE-SPEC specifies which features of the font FONT-OBJECT to apply
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3457 in this format:
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3458 (SCRIPT LANGSYS FEATURE ...)
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3459 See the documentation of `font-otf-gsub' for more detail.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3460
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3461 The value is a list of cons cells of the format (GLYPH-ID . CHARACTER),
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3462 where GLYPH-ID is a glyph index of the font, and CHARACTER is a
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3463 character code corresponding to the glyph or nil if there's no
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3464 corresponding character. */)
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3465 (font_object, character, otf_features)
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3466 Lisp_Object font_object, character, otf_features;
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3467 {
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3468 struct font *font;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3469 Lisp_Object gstring_in, gstring_out, g;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3470 Lisp_Object alternates;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3471 int i, num;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3472
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3473 CHECK_FONT_GET_OBJECT (font_object, font);
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3474 if (! font->driver->otf_drive)
90563
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
3475 error ("Font backend %s can't drive OpenType GSUB table",
7c29515f7c2a (font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents: 90556
diff changeset
3476 SDATA (SYMBOL_NAME (font->driver->type)));
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3477 CHECK_CHARACTER (character);
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3478 CHECK_CONS (otf_features);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3479
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3480 gstring_in = Ffont_make_gstring (font_object, make_number (1));
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3481 g = LGSTRING_GLYPH (gstring_in, 0);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3482 LGLYPH_SET_CHAR (g, character);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3483 gstring_out = Ffont_make_gstring (font_object, make_number (10));
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3484 while ((num = font->driver->otf_drive (font, otf_features, gstring_in, 0, 1,
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3485 gstring_out, 0, 1)) < 0)
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3486 gstring_out = Ffont_make_gstring (font_object,
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3487 make_number (ASIZE (gstring_out) * 2));
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3488 alternates = Qnil;
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3489 for (i = 0; i < num; i++)
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3490 {
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3491 Lisp_Object g = LGSTRING_GLYPH (gstring_out, i);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3492 int c = XINT (LGLYPH_CHAR (g));
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3493 unsigned code = XUINT (LGLYPH_CODE (g));
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3494
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3495 alternates = Fcons (Fcons (make_number (code),
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3496 c > 0 ? make_number (c) : Qnil),
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3497 alternates);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3498 }
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3499 return Fnreverse (alternates);
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3500 }
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3501
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3502
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3503 #ifdef FONT_DEBUG
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3504
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3505 DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3506 doc: /* Open FONT-ENTITY. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3507 (font_entity, size, frame)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3508 Lisp_Object font_entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3509 Lisp_Object size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3510 Lisp_Object frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3511 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3512 int isize;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3513
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3514 CHECK_FONT_ENTITY (font_entity);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3515 if (NILP (size))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3516 size = AREF (font_entity, FONT_SIZE_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3517 CHECK_NUMBER (size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3518 if (NILP (frame))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3519 frame = selected_frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3520 CHECK_LIVE_FRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3521
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3522 isize = XINT (size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3523 if (isize < 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3524 isize = POINT_TO_PIXEL (- isize, XFRAME (frame)->resy);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3525
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3526 return font_open_entity (XFRAME (frame), font_entity, isize);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3527 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3528
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3529 DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3530 doc: /* Close FONT-OBJECT. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3531 (font_object, frame)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3532 Lisp_Object font_object, frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3533 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3534 CHECK_FONT_OBJECT (font_object);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3535 if (NILP (frame))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3536 frame = selected_frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3537 CHECK_LIVE_FRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3538 font_close_object (XFRAME (frame), font_object);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3539 return Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3540 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3541
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3542 DEFUN ("query-font", Fquery_font, Squery_font, 1, 1, 0,
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3543 doc: /* Return information about FONT-OBJECT.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3544 The value is a vector:
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3545 [ NAME FILENAME PIXEL-SIZE SIZE ASCENT DESCENT SPACE-WIDTH AVERAGE-WIDTH
90677
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3546 CAPABILITY ]
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3547
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3548 NAME is a string of the font name (or nil if the font backend doesn't
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3549 provide a name).
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3550
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3551 FILENAME is a string of the font file (or nil if the font backend
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3552 doesn't provide a file name).
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3553
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3554 PIXEL-SIZE is a pixel size by which the font is opened.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3555
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3556 SIZE is a maximum advance width of the font in pixel.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3557
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3558 ASCENT, DESCENT, SPACE-WIDTH, AVERAGE-WIDTH are metrics of the font in
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3559 pixel.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3560
90677
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3561 CAPABILITY is a list whose first element is a symbol representing the
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3562 font format \(x, opentype, truetype, type1, pcf, or bdf) and the
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3563 remaining elements describes a detail of the font capability.
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3564
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3565 If the font is OpenType font, the form of the list is
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3566 \(opentype GSUB GPOS)
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3567 where GSUB shows which "GSUB" features the font supports, and GPOS
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3568 shows which "GPOS" features the font supports. Both GSUB and GPOS are
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3569 lists of the format:
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3570 \((SCRIPT (LANGSYS FEATURE ...) ...) ...)
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3571
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3572 If the font is not OpenType font, currently the length of the form is
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3573 one.
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3574
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3575 SCRIPT is a symbol representing OpenType script tag.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3576
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3577 LANGSYS is a symbol representing OpenType langsys tag, or nil
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3578 representing the default langsys.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3579
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3580 FEATURE is a symbol representing OpenType feature tag.
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3581
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3582 If the font is not OpenType font, OTF-CAPABILITY is nil. */)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3583 (font_object)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3584 Lisp_Object font_object;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3585 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3586 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3587 Lisp_Object val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3588
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3589 CHECK_FONT_GET_OBJECT (font_object, font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3590
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3591 val = Fmake_vector (make_number (9), Qnil);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3592 if (font->font.full_name)
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3593 ASET (val, 0, make_unibyte_string (font->font.full_name,
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3594 strlen (font->font.full_name)));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3595 if (font->file_name)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3596 ASET (val, 1, make_unibyte_string (font->file_name,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3597 strlen (font->file_name)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3598 ASET (val, 2, make_number (font->pixel_size));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3599 ASET (val, 3, make_number (font->font.size));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3600 ASET (val, 4, make_number (font->ascent));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3601 ASET (val, 5, make_number (font->descent));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3602 ASET (val, 6, make_number (font->font.space_width));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3603 ASET (val, 7, make_number (font->font.average_width));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3604 if (font->driver->otf_capability)
90677
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3605 ASET (val, 8, Fcons (Qopentype, font->driver->otf_capability (font)));
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3606 else
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3607 ASET (val, 8, Fcons (font->format, Qnil));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3608 return val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3609 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3610
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3611 DEFUN ("get-font-glyphs", Fget_font_glyphs, Sget_font_glyphs, 2, 2, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3612 doc: /* Return a vector of glyphs of FONT-OBJECT for drawing STRING.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3613 Each element is a vector [GLYPH-CODE LBEARING RBEARING WIDTH ASCENT DESCENT]. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3614 (font_object, string)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3615 Lisp_Object font_object, string;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3616 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3617 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3618 int i, len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3619 Lisp_Object vec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3620
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3621 CHECK_FONT_GET_OBJECT (font_object, font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3622 CHECK_STRING (string);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3623 len = SCHARS (string);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3624 vec = Fmake_vector (make_number (len), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3625 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3626 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3627 Lisp_Object ch = Faref (string, make_number (i));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3628 Lisp_Object val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3629 int c = XINT (ch);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3630 unsigned code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3631 struct font_metrics metrics;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3632
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3633 code = font->driver->encode_char (font, c);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3634 if (code == FONT_INVALID_CODE)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3635 continue;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3636 val = Fmake_vector (make_number (6), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3637 if (code <= MOST_POSITIVE_FIXNUM)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3638 ASET (val, 0, make_number (code));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3639 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3640 ASET (val, 0, Fcons (make_number (code >> 16),
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3641 make_number (code & 0xFFFF)));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3642 font->driver->text_extents (font, &code, 1, &metrics);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3643 ASET (val, 1, make_number (metrics.lbearing));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3644 ASET (val, 2, make_number (metrics.rbearing));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3645 ASET (val, 3, make_number (metrics.width));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3646 ASET (val, 4, make_number (metrics.ascent));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3647 ASET (val, 5, make_number (metrics.descent));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3648 ASET (vec, i, val);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3649 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3650 return vec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3651 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3652
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3653 DEFUN ("font-match-p", Ffont_match_p, Sfont_match_p, 2, 2, 0,
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3654 doc: /* Return t iff font-spec SPEC matches with FONT.
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3655 FONT is a font-spec, font-entity, or font-object. */)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3656 (spec, font)
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3657 Lisp_Object spec, font;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3658 {
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3659 CHECK_FONT_SPEC (spec);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3660 if (FONT_OBJECT_P (font))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3661 font = ((struct font *) XSAVE_VALUE (font)->pointer)->entity;
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3662 else if (! FONT_ENTITY_P (font))
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3663 CHECK_FONT_SPEC (font);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3664
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3665 return (font_match_p (spec, font) ? Qt : Qnil);
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3666 }
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3667
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3668 DEFUN ("font-at", Ffont_at, Sfont_at, 1, 2, 0,
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3669 doc: /* Return a font-object for displaying a character at POSISTION.
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3670 Optional second arg WINDOW, if non-nil, is a window displaying
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3671 the current buffer. It defaults to the currently selected window. */)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3672 (position, window)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3673 Lisp_Object position, window;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3674 {
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3675 struct window *w;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3676 EMACS_INT pos, pos_byte;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3677 int c;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3678
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3679 CHECK_NUMBER_COERCE_MARKER (position);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3680 pos = XINT (position);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3681 if (pos < BEGV || pos >= ZV)
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3682 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3683 pos_byte = CHAR_TO_BYTE (pos);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3684 c = FETCH_CHAR (pos_byte);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3685 if (NILP (window))
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3686 window = selected_window;
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3687 CHECK_LIVE_WINDOW (window);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3688 w = XWINDOW (selected_window);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3689
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3690 return font_at (c, pos, NULL, w, Qnil);
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3691 }
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3692
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3693 #if 0
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3694 DEFUN ("draw-string", Fdraw_string, Sdraw_string, 2, 2, 0,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3695 doc: /* Draw STRING by FONT-OBJECT on the top left corner of the current frame.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3696 The value is a number of glyphs drawn.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3697 Type C-l to recover what previously shown. */)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3698 (font_object, string)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3699 Lisp_Object font_object, string;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3700 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3701 Lisp_Object frame = selected_frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3702 FRAME_PTR f = XFRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3703 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3704 struct face *face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3705 int i, len, width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3706 unsigned *code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3707
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3708 CHECK_FONT_GET_OBJECT (font_object, font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3709 CHECK_STRING (string);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3710 len = SCHARS (string);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3711 code = alloca (sizeof (unsigned) * len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3712 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3713 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3714 Lisp_Object ch = Faref (string, make_number (i));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3715 Lisp_Object val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3716 int c = XINT (ch);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3717
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3718 code[i] = font->driver->encode_char (font, c);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3719 if (code[i] == FONT_INVALID_CODE)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3720 break;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3721 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3722 face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3723 face->fontp = font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3724 if (font->driver->prepare_face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3725 font->driver->prepare_face (f, face);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3726 width = font->driver->text_extents (font, code, i, NULL);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3727 len = font->driver->draw_text (f, face, 0, font->ascent, code, i, width);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3728 if (font->driver->done_face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3729 font->driver->done_face (f, face);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3730 face->fontp = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3731 return make_number (len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3732 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3733 #endif
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3734
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3735 #endif /* FONT_DEBUG */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3736
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3737
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3738 extern void syms_of_ftfont P_ (());
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3739 extern void syms_of_xfont P_ (());
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3740 extern void syms_of_xftfont P_ (());
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3741 extern void syms_of_ftxfont P_ (());
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3742 extern void syms_of_bdffont P_ (());
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3743 extern void syms_of_w32font P_ (());
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3744 extern void syms_of_atmfont P_ (());
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3745
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3746 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3747 syms_of_font ()
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3748 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3749 sort_shift_bits[FONT_SLANT_INDEX] = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3750 sort_shift_bits[FONT_WEIGHT_INDEX] = 7;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3751 sort_shift_bits[FONT_SIZE_INDEX] = 14;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3752 sort_shift_bits[FONT_WIDTH_INDEX] = 21;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3753 sort_shift_bits[FONT_ADSTYLE_INDEX] = 28;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3754 sort_shift_bits[FONT_FOUNDRY_INDEX] = 29;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3755 sort_shift_bits[FONT_FAMILY_INDEX] = 30;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3756 sort_shift_bits[FONT_REGISTRY_INDEX] = 31;
90507
4a6034a7c870 (font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents: 90503
diff changeset
3757 /* Note that sort_shift_bits[FONT_TYPE_INDEX] is never used. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3758
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3759 staticpro (&font_style_table);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3760 font_style_table = Fmake_vector (make_number (3), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3761
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3762 staticpro (&font_family_alist);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3763 font_family_alist = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3764
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3765 DEFSYM (Qfontp, "fontp");
90677
424dec0c7b5d (Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90640
diff changeset
3766 DEFSYM (Qopentype, "opentype");
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3767
90439
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
3768 DEFSYM (Qiso8859_1, "iso8859-1");
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
3769 DEFSYM (Qiso10646_1, "iso10646-1");
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
3770 DEFSYM (Qunicode_bmp, "unicode-bmp");
90622
bb9362e3a03b (Qunicode_sip): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90590
diff changeset
3771 DEFSYM (Qunicode_sip, "unicode-sip");
90439
fb253905e9c3 * font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
3772
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3773 DEFSYM (QCotf, ":otf");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3774 DEFSYM (QClanguage, ":language");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3775 DEFSYM (QCscript, ":script");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3776
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3777 DEFSYM (QCfoundry, ":foundry");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3778 DEFSYM (QCadstyle, ":adstyle");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3779 DEFSYM (QCregistry, ":registry");
90481
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
3780 DEFSYM (QCspacing, ":spacing");
93690200f520 (POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents: 90476
diff changeset
3781 DEFSYM (QCdpi, ":dpi");
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3782 DEFSYM (QCscalable, ":scalable");
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3783 DEFSYM (QCextra, ":extra");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3784
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3785 DEFSYM (Qc, "c");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3786 DEFSYM (Qm, "m");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3787 DEFSYM (Qp, "p");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3788 DEFSYM (Qd, "d");
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3789
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3790 staticpro (&null_string);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3791 null_string = build_string ("");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3792 staticpro (&null_vector);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3793 null_vector = Fmake_vector (make_number (0), Qnil);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3794
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3795 staticpro (&scratch_font_spec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3796 scratch_font_spec = Ffont_spec (0, NULL);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3797 staticpro (&scratch_font_prefer);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3798 scratch_font_prefer = Ffont_spec (0, NULL);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3799
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3800 #ifdef HAVE_LIBOTF
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3801 staticpro (&otf_list);
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3802 otf_list = Qnil;
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3803 #endif
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3804
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3805 defsubr (&Sfontp);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3806 defsubr (&Sfont_spec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3807 defsubr (&Sfont_get);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3808 defsubr (&Sfont_put);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3809 defsubr (&Slist_fonts);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3810 defsubr (&Slist_families);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3811 defsubr (&Sfind_font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3812 defsubr (&Sfont_xlfd_name);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3813 defsubr (&Sclear_font_cache);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3814 defsubr (&Sinternal_set_font_style_table);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3815 defsubr (&Sfont_make_gstring);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3816 defsubr (&Sfont_fill_gstring);
90817
d2c230a67741 (struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 90811
diff changeset
3817 defsubr (&Sfont_drive_otf);
90556
e56a86aa94cc (font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents: 90549
diff changeset
3818 defsubr (&Sfont_otf_alternates);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3819
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3820 #ifdef FONT_DEBUG
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3821 defsubr (&Sopen_font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3822 defsubr (&Sclose_font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3823 defsubr (&Squery_font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3824 defsubr (&Sget_font_glyphs);
90503
8e3ffc0a529f (QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents: 90490
diff changeset
3825 defsubr (&Sfont_match_p);
90541
b7130e76c2f9 Include window.h.
Kenichi Handa <handa@m17n.org>
parents: 90530
diff changeset
3826 defsubr (&Sfont_at);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3827 #if 0
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3828 defsubr (&Sdraw_string);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3829 #endif
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3830 #endif /* FONT_DEBUG */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3831
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3832 #ifdef HAVE_FREETYPE
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3833 syms_of_ftfont ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3834 #ifdef HAVE_X_WINDOWS
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3835 syms_of_xfont ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3836 syms_of_ftxfont ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3837 #ifdef HAVE_XFT
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3838 syms_of_xftfont ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3839 #endif /* HAVE_XFT */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3840 #endif /* HAVE_X_WINDOWS */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3841 #else /* not HAVE_FREETYPE */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3842 #ifdef HAVE_X_WINDOWS
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3843 syms_of_xfont ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3844 #endif /* HAVE_X_WINDOWS */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3845 #endif /* not HAVE_FREETYPE */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3846 #ifdef HAVE_BDFFONT
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3847 syms_of_bdffont ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3848 #endif /* HAVE_BDFFONT */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3849 #ifdef WINDOWSNT
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3850 syms_of_w32font ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3851 #endif /* WINDOWSNT */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3852 #ifdef MAC_OS
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3853 syms_of_atmfont ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3854 #endif /* MAC_OS */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3855 }
90427
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
3856
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
3857 /* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
3858 (do not change this comment) */