Mercurial > emacs
annotate src/font.c @ 95963:a20bb74ebe03
* net/tramp.el (tramp-handle-start-file-process): Clear
modification time of the connection buffer.
(tramp-sh-file-name-handler): Reset `tramp-locked' in case of
error.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Sun, 15 Jun 2008 13:36:30 +0000 |
parents | fbdde312e09d |
children | e427600f176b |
rev | line source |
---|---|
90400 | 1 /* font.c -- "Font" primitives. |
91553 | 2 Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. |
3 Copyright (C) 2006, 2007, 2008 | |
90400 | 4 National Institute of Advanced Industrial Science and Technology (AIST) |
5 Registration Number H13PRO009 | |
6 | |
7 This file is part of GNU Emacs. | |
8 | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94926
diff
changeset
|
9 GNU Emacs is free software: you can redistribute it and/or modify |
90400 | 10 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94926
diff
changeset
|
11 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94926
diff
changeset
|
12 (at your option) any later version. |
90400 | 13 |
14 GNU Emacs is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94926
diff
changeset
|
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
90400 | 21 |
22 #include <config.h> | |
23 #include <stdio.h> | |
24 #include <stdlib.h> | |
25 #include <ctype.h> | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
26 #ifdef HAVE_M17N_FLT |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
27 #include <m17n-flt.h> |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
28 #endif |
90400 | 29 |
30 #include "lisp.h" | |
31 #include "buffer.h" | |
32 #include "frame.h" | |
90541 | 33 #include "window.h" |
90400 | 34 #include "dispextern.h" |
35 #include "charset.h" | |
36 #include "character.h" | |
37 #include "composite.h" | |
38 #include "fontset.h" | |
39 #include "font.h" | |
40 | |
91909 | 41 #ifdef HAVE_X_WINDOWS |
42 #include "xterm.h" | |
43 #endif /* HAVE_X_WINDOWS */ | |
44 | |
45 #ifdef HAVE_NTGUI | |
46 #include "w32term.h" | |
47 #endif /* HAVE_NTGUI */ | |
48 | |
49 #ifdef MAC_OS | |
50 #include "macterm.h" | |
51 #endif /* MAC_OS */ | |
52 | |
94926 | 53 Lisp_Object Qfont_spec, Qfont_entity, Qfont_object; |
90400 | 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 |
94926 | 57 /* Important character set strings. */ |
95699 | 58 Lisp_Object Qascii_0, 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 | 60 /* Special vector of zero length. This is repeatedly used by (struct |
61 font_driver *)->list when a specified font is not found. */ | |
94926 | 62 static Lisp_Object null_vector; |
63 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
64 static Lisp_Object Vfont_weight_table, Vfont_slant_table, Vfont_width_table; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
65 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
66 /* Vector of Vfont_weight_table, Vfont_slant_table, and Vfont_width_table. */ |
90400 | 67 static Lisp_Object font_style_table; |
68 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
69 /* Structure used for tables mapping weight, slant, and width numeric |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
70 values and their names. */ |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
71 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
72 struct table_entry |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
73 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
74 int numeric; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
75 /* The first one is a valid name as a face attribute. |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
76 The second one (if any) is a typical name in XLFD field. */ |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
77 char *names[5]; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
78 Lisp_Object *symbols; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
79 }; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
80 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
81 /* Table of weight numeric values and their names. This table must be |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
82 sorted by numeric values in ascending order. */ |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
83 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
84 static struct table_entry weight_table[] = |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
85 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
86 { 0, { "thin" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
87 { 20, { "ultra-light", "ultralight" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
88 { 40, { "extra-light", "extralight" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
89 { 50, { "light" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
90 { 75, { "semi-light", "semilight", "demilight", "book" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
91 { 100, { "normal", "medium", "regular" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
92 { 180, { "semi-bold", "semibold", "demibold", "demi" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
93 { 200, { "bold" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
94 { 205, { "extra-bold", "extrabold" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
95 { 210, { "ultra-bold", "ultrabold", "black" }} |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
96 }; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
97 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
98 /* Table of slant numeric values and their names. This table must be |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
99 sorted by numeric values in ascending order. */ |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
100 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
101 static struct table_entry slant_table[] = |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
102 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
103 { 0, { "reverse-oblique", "ro" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
104 { 10, { "reverse-italic", "ri" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
105 { 100, { "normal", "r" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
106 { 200, { "italic" ,"i", "ot" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
107 { 210, { "oblique", "o" }} |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
108 }; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
109 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
110 /* Table of width numeric values and their names. This table must be |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
111 sorted by numeric values in ascending order. */ |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
112 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
113 static struct table_entry width_table[] = |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
114 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
115 { 50, { "ultra-condensed", "ultracondensed" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
116 { 63, { "extra-condensed", "extracondensed" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
117 { 75, { "condensed", "compressed", "narrow" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
118 { 87, { "semi-condensed", "semicondensed", "demicondensed" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
119 { 100, { "normal", "medium", "regular" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
120 { 113, { "semi-expanded", "semiexpanded", "demiexpanded" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
121 { 125, { "expanded" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
122 { 150, { "extra-expanded", "extraexpanded" }}, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
123 { 200, { "ultra-expanded", "ultraexpanded", "wide" }} |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
124 }; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
125 |
94926 | 126 extern Lisp_Object Qnormal; |
90400 | 127 |
128 /* Symbols representing keys of normal font properties. */ | |
129 extern Lisp_Object QCtype, QCfamily, QCweight, QCslant, QCwidth, QCsize, QCname; | |
94926 | 130 Lisp_Object QCfoundry, QCadstyle, QCregistry; |
90400 | 131 /* Symbols representing keys of font extra info. */ |
94926 | 132 Lisp_Object QCspacing, QCdpi, QCscalable, QCotf, QClang, QCscript, QCavgwidth; |
133 Lisp_Object QCantialias, QCfont_entity, QCfc_unknown_spec; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
134 /* Symbols representing values of font spacing property. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
135 Lisp_Object Qc, Qm, Qp, Qd; |
90400 | 136 |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
137 Lisp_Object Vfont_encoding_alist; |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
138 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
139 /* Alist of font registry symbol and the corresponding charsets |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
140 information. The information is retrieved from |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
141 Vfont_encoding_alist on demand. |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
142 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
143 Eash element has the form: |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
144 (REGISTRY . (ENCODING-CHARSET-ID . REPERTORY-CHARSET-ID)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
145 or |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
146 (REGISTRY . nil) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
147 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
148 In the former form, ENCODING-CHARSET-ID is an ID of a charset that |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
149 encodes a character code to a glyph code of a font, and |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
150 REPERTORY-CHARSET-ID is an ID of a charset that tells if a |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
151 character is supported by a font. |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
152 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
153 The latter form means that the information for REGISTRY couldn't be |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
154 retrieved. */ |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
155 static Lisp_Object font_charset_alist; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
156 |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
157 /* List of all font drivers. Each font-backend (XXXfont.c) calls |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
158 register_font_driver in syms_of_XXXfont to register its font-driver |
90400 | 159 here. */ |
160 static struct font_driver_list *font_driver_list; | |
161 | |
94926 | 162 |
163 | |
164 /* Creaters of font-related Lisp object. */ | |
165 | |
166 Lisp_Object | |
167 font_make_spec () | |
168 { | |
169 Lisp_Object font_spec; | |
170 struct font_spec *spec | |
171 = ((struct font_spec *) | |
172 allocate_pseudovector (VECSIZE (struct font_spec), | |
173 FONT_SPEC_MAX, PVEC_FONT)); | |
174 XSETFONT (font_spec, spec); | |
175 return font_spec; | |
176 } | |
177 | |
178 Lisp_Object | |
179 font_make_entity () | |
180 { | |
181 Lisp_Object font_entity; | |
182 struct font_entity *entity | |
183 = ((struct font_entity *) | |
184 allocate_pseudovector (VECSIZE (struct font_entity), | |
185 FONT_ENTITY_MAX, PVEC_FONT)); | |
186 XSETFONT (font_entity, entity); | |
187 return font_entity; | |
188 } | |
189 | |
190 Lisp_Object | |
191 font_make_object (size) | |
192 int size; | |
193 { | |
194 Lisp_Object font_object; | |
195 struct font *font | |
196 = (struct font *) allocate_pseudovector (size, FONT_OBJECT_MAX, PVEC_FONT); | |
197 XSETFONT (font_object, font); | |
198 | |
199 return font_object; | |
200 } | |
201 | |
202 | |
203 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
204 static int font_pixel_size P_ ((FRAME_PTR f, Lisp_Object)); |
94926 | 205 static Lisp_Object font_open_entity P_ ((FRAME_PTR, Lisp_Object, int)); |
206 static Lisp_Object font_matching_entity P_ ((FRAME_PTR, Lisp_Object *, | |
90400 | 207 Lisp_Object)); |
208 | |
209 /* Number of registered font drivers. */ | |
210 static int num_font_drivers; | |
211 | |
94926 | 212 |
213 /* Return a Lispy value of a font property value at STR and LEN bytes. | |
214 If STR is "*", it returns nil. | |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
215 If FORCE_SYMBOL is zero and all characters in STR are digits, it |
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
216 returns an integer. Otherwise, it returns a symbol interned from |
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
217 STR. */ |
94926 | 218 |
219 Lisp_Object | |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
220 font_intern_prop (str, len, force_symbol) |
94926 | 221 char *str; |
222 int len; | |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
223 int force_symbol; |
94926 | 224 { |
225 int i; | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
226 Lisp_Object tem; |
94926 | 227 Lisp_Object obarray; |
228 | |
229 if (len == 1 && *str == '*') | |
230 return Qnil; | |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
231 if (!force_symbol && len >=1 && isdigit (*str)) |
94926 | 232 { |
233 for (i = 1; i < len; i++) | |
234 if (! isdigit (str[i])) | |
235 break; | |
236 if (i == len) | |
237 return make_number (atoi (str)); | |
238 } | |
239 | |
240 /* The following code is copied from the function intern (in lread.c). */ | |
241 obarray = Vobarray; | |
242 if (!VECTORP (obarray) || XVECTOR (obarray)->size == 0) | |
243 obarray = check_obarray (obarray); | |
244 tem = oblookup (obarray, str, len, len); | |
245 if (SYMBOLP (tem)) | |
246 return tem; | |
247 return Fintern (make_unibyte_string (str, len), obarray); | |
248 } | |
249 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
250 /* 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
|
251 |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
252 static int |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
253 font_pixel_size (f, spec) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
254 FRAME_PTR f; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
255 Lisp_Object spec; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
256 { |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
257 #ifdef HAVE_WINDOW_SYSTEM |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
258 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
|
259 double point_size; |
94926 | 260 int dpi, pixel_size; |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
261 Lisp_Object val; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
262 |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
263 if (INTEGERP (size)) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
264 return XINT (size); |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
265 if (NILP (size)) |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
266 return 0; |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
267 font_assert (FLOATP (size)); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
268 point_size = XFLOAT_DATA (size); |
94926 | 269 val = AREF (spec, FONT_DPI_INDEX); |
270 if (INTEGERP (val)) | |
95483
d3cbd7d56845
(font_pixel_size): Don't take cdr of an integer.
Chong Yidong <cyd@stupidchicken.com>
parents:
95475
diff
changeset
|
271 dpi = XINT (val); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
272 else |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
273 dpi = f->resy; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
274 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
|
275 return pixel_size; |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
276 #else |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
277 return 1; |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
278 #endif |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
279 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
280 |
94926 | 281 |
282 /* Return a value of PROP's VAL (symbol or integer) to be stored in a | |
283 font vector. If VAL is not valid (i.e. not registered in | |
284 font_style_table), return -1 if NOERROR is zero, and return a | |
285 proper index if NOERROR is nonzero. In that case, register VAL in | |
286 font_style_table if VAL is a symbol, and return a closest index if | |
287 VAL is an integer. */ | |
288 | |
289 int | |
290 font_style_to_value (prop, val, noerror) | |
90400 | 291 enum font_property_index prop; |
94926 | 292 Lisp_Object val; |
293 int noerror; | |
90400 | 294 { |
94926 | 295 Lisp_Object table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); |
296 int len = ASIZE (table); | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
297 int i, j; |
94926 | 298 |
299 if (SYMBOLP (val)) | |
90400 | 300 { |
95403
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
301 unsigned char *s; |
94926 | 302 Lisp_Object args[2], elt; |
303 | |
304 /* At first try exact match. */ | |
305 for (i = 0; i < len; i++) | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
306 for (j = 1; j < ASIZE (AREF (table, i)); j++) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
307 if (EQ (val, AREF (AREF (table, i), j))) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
308 return ((XINT (AREF (AREF (table, i), 0)) << 8) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
309 | (i << 4) | (j - 1)); |
94926 | 310 /* Try also with case-folding match. */ |
95403
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
311 s = SDATA (SYMBOL_NAME (val)); |
94926 | 312 for (i = 0; i < len; i++) |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
313 for (j = 1; j < ASIZE (AREF (table, i)); j++) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
314 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
315 elt = AREF (AREF (table, i), j); |
95403
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
316 if (xstrcasecmp (s, SDATA (SYMBOL_NAME (elt))) == 0) |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
317 return ((XINT (AREF (AREF (table, i), 0)) << 8) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
318 | (i << 4) | (j - 1)); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
319 } |
94926 | 320 if (! noerror) |
321 return -1; | |
322 if (len == 255) | |
323 abort (); | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
324 elt = Fmake_vector (make_number (2), make_number (255)); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
325 ASET (elt, 1, val); |
94926 | 326 args[0] = table; |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
327 args[1] = Fmake_vector (make_number (1), elt); |
94926 | 328 ASET (font_style_table, prop - FONT_WEIGHT_INDEX, Fvconcat (2, args)); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
329 return (255 << 8) | (i << 4); |
90400 | 330 } |
94926 | 331 else |
332 { | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
333 int i, last_n; |
94926 | 334 int numeric = XINT (val); |
335 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
336 for (i = 0, last_n = -1; i < len; i++) |
94926 | 337 { |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
338 int n = XINT (AREF (AREF (table, i), 0)); |
94926 | 339 |
340 if (numeric == n) | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
341 return (n << 8) | (i << 4); |
94926 | 342 if (numeric < n) |
343 { | |
344 if (! noerror) | |
345 return -1; | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
346 return ((i == 0 || n - numeric < numeric - last_n) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
347 ? (n << 8) | (i << 4): (last_n << 8 | ((i - 1) << 4))); |
94926 | 348 } |
349 last_n = n; | |
350 } | |
351 if (! noerror) | |
352 return -1; | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
353 return ((last_n << 8) | ((i - 1) << 4)); |
94926 | 354 } |
90400 | 355 } |
356 | |
357 Lisp_Object | |
95894
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
358 font_style_symbolic_from_value (prop, val, for_face) |
94926 | 359 enum font_property_index prop; |
95894
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
360 Lisp_Object val; |
94926 | 361 int for_face; |
90400 | 362 { |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
363 Lisp_Object table, elt; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
364 int i; |
94926 | 365 |
366 if (NILP (val)) | |
367 return Qnil; | |
368 table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX); | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
369 i = XINT (val) & 0xFF; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
370 font_assert (((i >> 4) & 0xF) < ASIZE (table)); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
371 elt = AREF (table, ((i >> 4) & 0xF)); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
372 font_assert ((i & 0xF) + 1 < ASIZE (elt)); |
95894
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
373 return (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1)); |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
374 } |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
375 |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
376 Lisp_Object |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
377 font_style_symbolic (font, prop, for_face) |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
378 Lisp_Object font; |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
379 enum font_property_index prop; |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
380 int for_face; |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
381 { |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
382 Lisp_Object val = AREF (font, prop); |
76261fd18708
* w32fns.c (Fw32_select_font): Removed old font API function.
Jason Rumney <jasonr@gnu.org>
parents:
95890
diff
changeset
|
383 return font_style_symbolic_from_value (prop, val, for_face); |
90400 | 384 } |
385 | |
386 extern Lisp_Object Vface_alternative_font_family_alist; | |
387 | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
388 extern Lisp_Object find_font_encoding P_ ((Lisp_Object)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
389 |
94926 | 390 |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
391 /* Return ENCODING or a cons of ENCODING and REPERTORY of the font |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
392 FONTNAME. ENCODING is a charset symbol that specifies the encoding |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
393 of the font. REPERTORY is a charset symbol or nil. */ |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
394 |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
395 Lisp_Object |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
396 find_font_encoding (fontname) |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
397 Lisp_Object fontname; |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
398 { |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
399 Lisp_Object tail, elt; |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
400 |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
401 for (tail = Vfont_encoding_alist; CONSP (tail); tail = XCDR (tail)) |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
402 { |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
403 elt = XCAR (tail); |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
404 if (CONSP (elt) |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
405 && STRINGP (XCAR (elt)) |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
406 && fast_string_match_ignore_case (XCAR (elt), fontname) >= 0 |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
407 && (SYMBOLP (XCDR (elt)) |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
408 ? CHARSETP (XCDR (elt)) |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
409 : CONSP (XCDR (elt)) && CHARSETP (XCAR (XCDR (elt))))) |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
410 return (XCDR (elt)); |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
411 } |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
412 /* We don't know the encoding of this font. Let's assume `ascii'. */ |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
413 return Qascii; |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
414 } |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
415 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
416 /* Return encoding charset and repertory charset for REGISTRY in |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
417 ENCODING and REPERTORY correspondingly. If correct information for |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
418 REGISTRY is available, return 0. Otherwise return -1. */ |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
419 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
420 int |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
421 font_registry_charsets (registry, encoding, repertory) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
422 Lisp_Object registry; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
423 struct charset **encoding, **repertory; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
424 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
425 Lisp_Object val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
426 int encoding_id, repertory_id; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
427 |
94926 | 428 val = Fassoc_string (registry, font_charset_alist, Qt); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
429 if (! NILP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
430 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
431 val = XCDR (val); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
432 if (NILP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
433 return -1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
434 encoding_id = XINT (XCAR (val)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
435 repertory_id = XINT (XCDR (val)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
436 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
437 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
438 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
439 val = find_font_encoding (SYMBOL_NAME (registry)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
440 if (SYMBOLP (val) && CHARSETP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
441 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
442 encoding_id = repertory_id = XINT (CHARSET_SYMBOL_ID (val)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
443 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
444 else if (CONSP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
445 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
446 if (! CHARSETP (XCAR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
447 goto invalid_entry; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
448 encoding_id = XINT (CHARSET_SYMBOL_ID (XCAR (val))); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
449 if (NILP (XCDR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
450 repertory_id = -1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
451 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
452 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
453 if (! CHARSETP (XCDR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
454 goto invalid_entry; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
455 repertory_id = XINT (CHARSET_SYMBOL_ID (XCDR (val))); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
456 } |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
457 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
458 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
459 goto invalid_entry; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
460 val = Fcons (make_number (encoding_id), make_number (repertory_id)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
461 font_charset_alist |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
462 = nconc2 (font_charset_alist, Fcons (Fcons (registry, val), Qnil)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
463 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
464 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
465 if (encoding) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
466 *encoding = CHARSET_FROM_ID (encoding_id); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
467 if (repertory) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
468 *repertory = repertory_id >= 0 ? CHARSET_FROM_ID (repertory_id) : NULL; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
469 return 0; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
470 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
471 invalid_entry: |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
472 font_charset_alist |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
473 = nconc2 (font_charset_alist, Fcons (Fcons (registry, Qnil), Qnil)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
474 return -1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
475 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
476 |
90400 | 477 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
478 /* Font property value validaters. See the comment of |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
479 font_property_table for the meaning of the arguments. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
480 |
94926 | 481 static Lisp_Object font_prop_validate P_ ((int, Lisp_Object, Lisp_Object)); |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
482 static Lisp_Object font_prop_validate_symbol P_ ((Lisp_Object, Lisp_Object)); |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
483 static Lisp_Object font_prop_validate_style P_ ((Lisp_Object, Lisp_Object)); |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
484 static Lisp_Object font_prop_validate_non_neg P_ ((Lisp_Object, Lisp_Object)); |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
485 static Lisp_Object font_prop_validate_spacing P_ ((Lisp_Object, Lisp_Object)); |
94926 | 486 static int get_font_prop_index P_ ((Lisp_Object)); |
90400 | 487 |
488 static Lisp_Object | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
489 font_prop_validate_symbol (prop, val) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
490 Lisp_Object prop, val; |
90400 | 491 { |
492 if (STRINGP (val)) | |
94926 | 493 val = Fintern (val, Qnil); |
494 if (! SYMBOLP (val)) | |
495 val = Qerror; | |
496 else if (EQ (prop, QCregistry)) | |
497 val = Fintern (Fdowncase (SYMBOL_NAME (val)), Qnil); | |
498 return val; | |
499 } | |
500 | |
501 | |
502 static Lisp_Object | |
503 font_prop_validate_style (style, val) | |
504 Lisp_Object style, val; | |
505 { | |
506 enum font_property_index prop = (EQ (style, QCweight) ? FONT_WEIGHT_INDEX | |
507 : EQ (style, QCslant) ? FONT_SLANT_INDEX | |
508 : FONT_WIDTH_INDEX); | |
509 int n; | |
510 if (INTEGERP (val)) | |
511 { | |
512 n = XINT (val); | |
95194
6be267398fe5
(font_prop_validate_style): Adjusted for the format
Kenichi Handa <handa@m17n.org>
parents:
95177
diff
changeset
|
513 if (((n >> 4) & 0xF) |
94926 | 514 >= ASIZE (AREF (font_style_table, prop - FONT_WEIGHT_INDEX))) |
515 val = Qerror; | |
516 else | |
517 { | |
95194
6be267398fe5
(font_prop_validate_style): Adjusted for the format
Kenichi Handa <handa@m17n.org>
parents:
95177
diff
changeset
|
518 Lisp_Object elt = AREF (AREF (font_style_table, prop - FONT_WEIGHT_INDEX), (n >> 4) & 0xF); |
6be267398fe5
(font_prop_validate_style): Adjusted for the format
Kenichi Handa <handa@m17n.org>
parents:
95177
diff
changeset
|
519 |
6be267398fe5
(font_prop_validate_style): Adjusted for the format
Kenichi Handa <handa@m17n.org>
parents:
95177
diff
changeset
|
520 if ((n & 0xF) + 1 >= ASIZE (elt)) |
6be267398fe5
(font_prop_validate_style): Adjusted for the format
Kenichi Handa <handa@m17n.org>
parents:
95177
diff
changeset
|
521 val = Qerror; |
6be267398fe5
(font_prop_validate_style): Adjusted for the format
Kenichi Handa <handa@m17n.org>
parents:
95177
diff
changeset
|
522 else if (XINT (AREF (elt, 0)) != (n >> 8)) |
94926 | 523 val = Qerror; |
524 } | |
525 } | |
90400 | 526 else if (SYMBOLP (val)) |
527 { | |
94926 | 528 int n = font_style_to_value (prop, val, 0); |
529 | |
530 val = n >= 0 ? make_number (n) : Qerror; | |
90400 | 531 } |
532 else | |
533 val = Qerror; | |
534 return val; | |
535 } | |
536 | |
537 static Lisp_Object | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
538 font_prop_validate_non_neg (prop, val) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
539 Lisp_Object prop, val; |
90400 | 540 { |
541 return (NATNUMP (val) || (FLOATP (val) && XFLOAT_DATA (val) >= 0) | |
542 ? val : Qerror); | |
543 } | |
544 | |
545 static Lisp_Object | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
546 font_prop_validate_spacing (prop, val) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
547 Lisp_Object prop, val; |
90400 | 548 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
549 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
|
550 return val; |
95504
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
551 if (SYMBOLP (val) && SBYTES (SYMBOL_NAME (val)) == 1) |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
552 { |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
553 char spacing = SDATA (SYMBOL_NAME (val))[0]; |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
554 |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
555 if (spacing == 'c' || spacing == 'C') |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
556 return make_number (FONT_SPACING_CHARCELL); |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
557 if (spacing == 'm' || spacing == 'M') |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
558 return make_number (FONT_SPACING_MONO); |
95523
3c4256715c94
(font_prop_validate_spacing): Fix last change.
Andreas Schwab <schwab@suse.de>
parents:
95516
diff
changeset
|
559 if (spacing == 'p' || spacing == 'P') |
95504
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
560 return make_number (FONT_SPACING_PROPORTIONAL); |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
561 if (spacing == 'd' || spacing == 'D') |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
562 return make_number (FONT_SPACING_DUAL); |
00bdff60fc10
(font_prop_validate_spacing): Handle uppercase symbols.
Kenichi Handa <handa@m17n.org>
parents:
95483
diff
changeset
|
563 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
564 return Qerror; |
90400 | 565 } |
566 | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
567 static Lisp_Object |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
568 font_prop_validate_otf (prop, val) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
569 Lisp_Object prop, val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
570 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
571 Lisp_Object tail, tmp; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
572 int i; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
573 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
574 /* VAL = (SCRIPT [ LANGSYS [ GSUB-FEATURES [ GPOS-FEATURES ]]]) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
575 GSUB-FEATURES = (FEATURE ... [ nil FEATURE ... ]) | nil |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
576 GPOS-FEATURES = (FEATURE ... [ nil FEATURE ... ]) | nil */ |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
577 if (! CONSP (val)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
578 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
579 if (! SYMBOLP (XCAR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
580 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
581 tail = XCDR (val); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
582 if (NILP (tail)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
583 return val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
584 if (! CONSP (tail) || ! SYMBOLP (XCAR (val))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
585 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
586 for (i = 0; i < 2; i++) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
587 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
588 tail = XCDR (tail); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
589 if (NILP (tail)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
590 return val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
591 if (! CONSP (tail)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
592 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
593 for (tmp = XCAR (tail); CONSP (tmp); tmp = XCDR (tmp)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
594 if (! SYMBOLP (XCAR (tmp))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
595 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
596 if (! NILP (tmp)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
597 return Qerror; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
598 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
599 return val; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
600 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
601 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
602 /* 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
|
603 values. */ |
90400 | 604 struct |
605 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
606 /* Pointer to the key symbol. */ |
90400 | 607 Lisp_Object *key; |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
608 /* Function to validate PROP's value VAL, or NULL if any value is |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
609 ok. The value is VAL or its regularized value if VAL is valid, |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
610 and Qerror if not. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
611 Lisp_Object (*validater) P_ ((Lisp_Object prop, Lisp_Object val)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
612 } font_property_table[] = |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
613 { { &QCtype, font_prop_validate_symbol }, |
90400 | 614 { &QCfoundry, font_prop_validate_symbol }, |
615 { &QCfamily, font_prop_validate_symbol }, | |
616 { &QCadstyle, font_prop_validate_symbol }, | |
617 { &QCregistry, font_prop_validate_symbol }, | |
618 { &QCweight, font_prop_validate_style }, | |
619 { &QCslant, font_prop_validate_style }, | |
620 { &QCwidth, font_prop_validate_style }, | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
621 { &QCsize, font_prop_validate_non_neg }, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
622 { &QCdpi, font_prop_validate_non_neg }, |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
623 { &QCspacing, font_prop_validate_spacing }, |
94926 | 624 { &QCavgwidth, font_prop_validate_non_neg }, |
625 /* The order of the above entries must match with enum | |
626 font_property_index. */ | |
627 { &QClang, font_prop_validate_symbol }, | |
628 { &QCscript, font_prop_validate_symbol }, | |
629 { &QCotf, font_prop_validate_otf } | |
90400 | 630 }; |
631 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
632 /* Size (number of elements) of the above table. */ |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
633 #define FONT_PROPERTY_TABLE_SIZE \ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
634 ((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
|
635 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
636 /* Return an index number of font property KEY or -1 if KEY is not an |
94926 | 637 already known property. */ |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
638 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
639 static int |
94926 | 640 get_font_prop_index (key) |
90400 | 641 Lisp_Object key; |
642 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
643 int i; |
94926 | 644 |
645 for (i = 0; i < FONT_PROPERTY_TABLE_SIZE; i++) | |
646 if (EQ (key, *font_property_table[i].key)) | |
647 return i; | |
648 return -1; | |
649 } | |
650 | |
651 /* Validate the font property. The property key is specified by the | |
652 symbol PROP, or the index IDX (if PROP is nil). If VAL is invalid, | |
653 signal an error. The value is VAL or the regularized one. */ | |
654 | |
655 static Lisp_Object | |
656 font_prop_validate (idx, prop, val) | |
657 int idx; | |
658 Lisp_Object prop, val; | |
659 { | |
660 Lisp_Object validated; | |
661 | |
94964
5ffc88767cc1
(font_prop_validate): Make nil a valid value.
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
662 if (NILP (val)) |
5ffc88767cc1
(font_prop_validate): Make nil a valid value.
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
663 return val; |
94926 | 664 if (NILP (prop)) |
665 prop = *font_property_table[idx].key; | |
666 else | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
667 { |
94926 | 668 idx = get_font_prop_index (prop); |
669 if (idx < 0) | |
670 return val; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
671 } |
94926 | 672 validated = (font_property_table[idx].validater) (prop, val); |
673 if (EQ (validated, Qerror)) | |
674 signal_error ("invalid font property", Fcons (prop, val)); | |
675 return validated; | |
90400 | 676 } |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
677 |
94926 | 678 |
679 /* Store VAL as a value of extra font property PROP in FONT while | |
680 keeping the sorting order. Don't check the validity of VAL. */ | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
681 |
90888
5f03b3602143
(font_put_extra): Expose externally.
Jason Rumney <jasonr@gnu.org>
parents:
90883
diff
changeset
|
682 Lisp_Object |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
683 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
|
684 Lisp_Object font, prop, val; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
685 { |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
686 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
|
687 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
|
688 |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
689 if (NILP (slot)) |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
690 { |
94926 | 691 Lisp_Object prev = Qnil; |
692 | |
693 while (CONSP (extra) | |
694 && NILP (Fstring_lessp (prop, XCAR (XCAR (extra))))) | |
695 prev = extra, extra = XCDR (extra); | |
696 if (NILP (prev)) | |
697 ASET (font, FONT_EXTRA_INDEX, Fcons (Fcons (prop, val), extra)); | |
698 else | |
699 XSETCDR (prev, Fcons (Fcons (prop, val), extra)); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
700 return val; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
701 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
702 XSETCDR (slot, val); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
703 return val; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
704 } |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
705 |
90400 | 706 |
707 /* Font name parser and unparser */ | |
708 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
709 static int parse_matrix P_ ((char *)); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
710 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
|
711 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
|
712 |
90400 | 713 /* An enumerator for each field of an XLFD font name. */ |
714 enum xlfd_field_index | |
715 { | |
716 XLFD_FOUNDRY_INDEX, | |
717 XLFD_FAMILY_INDEX, | |
718 XLFD_WEIGHT_INDEX, | |
719 XLFD_SLANT_INDEX, | |
720 XLFD_SWIDTH_INDEX, | |
721 XLFD_ADSTYLE_INDEX, | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
722 XLFD_PIXEL_INDEX, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
723 XLFD_POINT_INDEX, |
90400 | 724 XLFD_RESX_INDEX, |
725 XLFD_RESY_INDEX, | |
726 XLFD_SPACING_INDEX, | |
727 XLFD_AVGWIDTH_INDEX, | |
728 XLFD_REGISTRY_INDEX, | |
729 XLFD_ENCODING_INDEX, | |
730 XLFD_LAST_INDEX | |
731 }; | |
732 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
733 /* 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
|
734 enum xlfd_field_mask |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
735 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
736 XLFD_FOUNDRY_MASK = 0x0001, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
737 XLFD_FAMILY_MASK = 0x0002, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
738 XLFD_WEIGHT_MASK = 0x0004, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
739 XLFD_SLANT_MASK = 0x0008, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
740 XLFD_SWIDTH_MASK = 0x0010, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
741 XLFD_ADSTYLE_MASK = 0x0020, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
742 XLFD_PIXEL_MASK = 0x0040, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
743 XLFD_POINT_MASK = 0x0080, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
744 XLFD_RESX_MASK = 0x0100, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
745 XLFD_RESY_MASK = 0x0200, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
746 XLFD_SPACING_MASK = 0x0400, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
747 XLFD_AVGWIDTH_MASK = 0x0800, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
748 XLFD_REGISTRY_MASK = 0x1000, |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
749 XLFD_ENCODING_MASK = 0x2000 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
750 }; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
751 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
752 |
90400 | 753 /* Parse P pointing the pixel/point size field of the form |
754 `[A B C D]' which specifies a transformation matrix: | |
755 | |
756 A B 0 | |
757 C D 0 | |
758 0 0 1 | |
759 | |
760 by which all glyphs of the font are transformed. The spec says | |
761 that scalar value N for the pixel/point size is equivalent to: | |
762 A = N * resx/resy, B = C = 0, D = N. | |
763 | |
764 Return the scalar value N if the form is valid. Otherwise return | |
765 -1. */ | |
766 | |
767 static int | |
768 parse_matrix (p) | |
769 char *p; | |
770 { | |
771 double matrix[4]; | |
772 char *end; | |
773 int i; | |
774 | |
775 for (i = 0, p++; i < 4 && *p && *p != ']'; i++) | |
776 { | |
777 if (*p == '~') | |
778 matrix[i] = - strtod (p + 1, &end); | |
779 else | |
780 matrix[i] = strtod (p, &end); | |
781 p = end; | |
782 } | |
783 return (i == 4 ? (int) matrix[3] : -1); | |
784 } | |
785 | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
786 /* 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
|
787 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
|
788 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
|
789 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
790 static int |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
791 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
|
792 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
|
793 int n; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
794 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
795 /* Copy of FIELD. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
796 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
|
797 /* 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
|
798 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
|
799 struct { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
800 /* Minimum possible field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
801 int from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
802 /* Maxinum possible field. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
803 int to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
804 /* 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
|
805 int mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
806 } range[XLFD_LAST_INDEX]; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
807 int i, j; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
808 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
|
809 unsigned range_mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
810 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
811 #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
|
812 | 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
|
813 #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
|
814 #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
|
815 | XLFD_AVGWIDTH_MASK) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
816 #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
|
817 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
818 /* 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
|
819 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
|
820 following loop. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
821 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
|
822 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
|
823 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
824 /* 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
|
825 position-based retriction for FIELD[I]. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
826 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
|
827 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
|
828 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
829 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
|
830 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
831 tmp[i] = val; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
832 if (NILP (val)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
833 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
834 /* Wildcard. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
835 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
|
836 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
|
837 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
|
838 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
839 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
840 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
841 /* 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
|
842 retriction for FIELD[I]. */ |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
843 int from, to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
844 unsigned mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
845 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
846 if (INTEGERP (val)) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
847 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
848 int numeric = XINT (val); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
849 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
850 if (i + 1 == n) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
851 from = to = XLFD_ENCODING_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
852 mask = XLFD_ENCODING_MASK; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
853 else if (numeric == 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
854 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
|
855 mask = XLFD_PIXEL_MASK | XLFD_LARGENUM_MASK; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
856 else if (numeric <= 48) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
857 from = to = XLFD_PIXEL_INDEX, |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
858 mask = XLFD_PIXEL_MASK; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
859 else |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
860 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
|
861 mask = XLFD_LARGENUM_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
862 } |
94926 | 863 else if (SBYTES (SYMBOL_NAME (val)) == 0) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
864 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
|
865 mask = XLFD_NULL_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
866 else if (i == 0) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
867 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
|
868 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
|
869 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
870 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
|
871 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
872 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
|
873 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
|
874 mask = XLFD_REGENC_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
875 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
876 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
|
877 mask = XLFD_ENCODING_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
878 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
879 else if (range_from <= XLFD_WEIGHT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
880 && range_to >= XLFD_WEIGHT_INDEX |
94926 | 881 && FONT_WEIGHT_NAME_NUMERIC (val) >= 0) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
882 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
|
883 else if (range_from <= XLFD_SLANT_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
884 && range_to >= XLFD_SLANT_INDEX |
94926 | 885 && FONT_SLANT_NAME_NUMERIC (val) >= 0) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
886 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
|
887 else if (range_from <= XLFD_SWIDTH_INDEX |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
888 && range_to >= XLFD_SWIDTH_INDEX |
94926 | 889 && FONT_WIDTH_NAME_NUMERIC (val) >= 0) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
890 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
|
891 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
892 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
893 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
|
894 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
|
895 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
896 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
|
897 mask = XLFD_SYMBOL_MASK; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
898 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
899 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
900 /* 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
|
901 mask &= range_mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
902 while (from < range_from) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
903 mask &= ~(1 << from++); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
904 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
|
905 from++; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
906 while (to > range_to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
907 mask &= ~(1 << to--); |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
908 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
|
909 to--; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
910 if (from > to) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
911 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
912 range[i].from = from; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
913 range[i].to = to; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
914 range[i].mask = mask; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
915 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
916 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
|
917 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
918 /* 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
|
919 Reflect it to the other fields. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
920 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
921 /* Following fields should be after FROM. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
922 range_from = from; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
923 /* Preceding fields should be before TO. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
924 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
|
925 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
926 /* Check FROM for non-wildcard field. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
927 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
|
928 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
929 while (range[j].from < from) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
930 range[j].mask &= ~(1 << range[j].from++); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
931 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
|
932 from++; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
933 range[j].from = from; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
934 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
935 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
936 from = range[j].from; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
937 if (range[j].to > to) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
938 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
939 while (range[j].to > to) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
940 range[j].mask &= ~(1 << range[j].to--); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
941 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
|
942 to--; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
943 range[j].to = to; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
944 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
945 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
946 to = range[j].to; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
947 if (from > to) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
948 return -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
949 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
950 } |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
951 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
952 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
953 |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
954 /* 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
|
955 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
|
956 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
957 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
|
958 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
959 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
|
960 /* 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
|
961 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
962 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
|
963 field[j] = Qnil; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
964 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
965 field[j++] = tmp[i]; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
966 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
967 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
|
968 return -1; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
969 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
|
970 field[j] = Qnil; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
971 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
|
972 field[XLFD_ENCODING_INDEX] |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
973 = 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
|
974 return 0; |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
975 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
976 |
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
977 |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
978 #ifdef ENABLE_CHECKING |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
979 /* Match a 14-field XLFD pattern against a full XLFD font name. */ |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
980 static int |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
981 font_match_xlfd (char *pattern, char *name) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
982 { |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
983 while (*pattern && *name) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
984 { |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
985 if (*pattern == *name) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
986 pattern++; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
987 else if (*pattern == '*') |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
988 if (*name == pattern[1]) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
989 pattern += 2; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
990 else |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
991 ; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
992 else |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
993 return 0; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
994 name++; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
995 } |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
996 return 1; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
997 } |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
998 |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
999 /* Make sure the font object matches the XLFD font name. */ |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1000 static int |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1001 font_check_xlfd_parse (Lisp_Object font, char *name) |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1002 { |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1003 char name_check[256]; |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1004 font_unparse_xlfd (font, 0, name_check, 255); |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1005 return font_match_xlfd (name_check, name); |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1006 } |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1007 |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1008 #endif |
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
1009 |
94926 | 1010 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1011 /* 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
|
1012 (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
|
1013 follows: |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1014 specified XLFD fields FONT property |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1015 --------------------- ------------- |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1016 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
|
1017 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
|
1018 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
|
1019 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1020 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
|
1021 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1022 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
|
1023 X font backend driver, it is a font-entity. In that case, NAME is |
94926 | 1024 a fully specified XLFD. */ |
90400 | 1025 |
1026 int | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1027 font_parse_xlfd (name, font) |
90400 | 1028 char *name; |
1029 Lisp_Object font; | |
1030 { | |
1031 int len = strlen (name); | |
94926 | 1032 int i, j, n; |
90695
a1cd7344d6a2
(font_parse_xlfd): Fix the array size of `f'.
Kenichi Handa <handa@m17n.org>
parents:
90677
diff
changeset
|
1033 char *f[XLFD_LAST_INDEX + 1]; |
90400 | 1034 Lisp_Object val; |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1035 char *p; |
90400 | 1036 |
1037 if (len > 255) | |
1038 /* Maximum XLFD name length is 255. */ | |
1039 return -1; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1040 /* Accept "*-.." as a fully specified XLFD. */ |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1041 if (name[0] == '*' && name[1] == '-') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1042 i = 1, f[XLFD_FOUNDRY_INDEX] = name; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1043 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1044 i = 0; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1045 for (p = name + i; *p; p++) |
94926 | 1046 if (*p == '-') |
1047 { | |
1048 f[i++] = p + 1; | |
1049 if (i == XLFD_LAST_INDEX) | |
1050 break; | |
1051 } | |
1052 f[i] = name + len; | |
1053 | |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1054 #define INTERN_FIELD(N) font_intern_prop (f[N], f[(N) + 1] - 1 - f[N], 0) |
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1055 #define INTERN_FIELD_SYM(N) font_intern_prop (f[N], f[(N) + 1] - 1 - f[N], 1) |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1056 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1057 if (i == XLFD_LAST_INDEX) |
90400 | 1058 { |
94926 | 1059 /* Fully specified XLFD. */ |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1060 int pixel_size; |
94926 | 1061 |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1062 ASET (font, FONT_FOUNDRY_INDEX, INTERN_FIELD_SYM (XLFD_FOUNDRY_INDEX)); |
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1063 ASET (font, FONT_FAMILY_INDEX, INTERN_FIELD_SYM (XLFD_FAMILY_INDEX)); |
94926 | 1064 for (i = XLFD_WEIGHT_INDEX, j = FONT_WEIGHT_INDEX; |
1065 i <= XLFD_SWIDTH_INDEX; i++, j++) | |
90400 | 1066 { |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1067 val = INTERN_FIELD_SYM (i); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1068 if (! NILP (val)) |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1069 { |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1070 if ((n = font_style_to_value (j, INTERN_FIELD_SYM (i), 0)) < 0) |
94926 | 1071 return -1; |
1072 ASET (font, j, make_number (n)); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1073 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1074 } |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1075 ASET (font, FONT_ADSTYLE_INDEX, INTERN_FIELD_SYM (XLFD_ADSTYLE_INDEX)); |
94926 | 1076 if (strcmp (f[XLFD_REGISTRY_INDEX], "*-*") == 0) |
1077 ASET (font, FONT_REGISTRY_INDEX, Qnil); | |
1078 else | |
1079 ASET (font, FONT_REGISTRY_INDEX, | |
1080 font_intern_prop (f[XLFD_REGISTRY_INDEX], | |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1081 f[XLFD_LAST_INDEX] - f[XLFD_REGISTRY_INDEX], |
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1082 1)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1083 p = f[XLFD_PIXEL_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1084 if (*p == '[' && (pixel_size = parse_matrix (p)) >= 0) |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
1085 ASET (font, FONT_SIZE_INDEX, make_number (pixel_size)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1086 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1087 { |
94926 | 1088 val = INTERN_FIELD (XLFD_PIXEL_INDEX); |
1089 if (INTEGERP (val)) | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1090 ASET (font, FONT_SIZE_INDEX, val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1091 else |
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 double point_size = -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1094 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
1095 font_assert (FONT_SPEC_P (font)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1096 p = f[XLFD_POINT_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1097 if (*p == '[') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1098 point_size = parse_matrix (p); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1099 else if (isdigit (*p)) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1100 point_size = atoi (p), point_size /= 10; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1101 if (point_size >= 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1102 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
|
1103 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1104 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1105 |
94926 | 1106 ASET (font, FONT_DPI_INDEX, INTERN_FIELD (XLFD_RESY_INDEX)); |
1107 val = INTERN_FIELD (XLFD_SPACING_INDEX); | |
1108 if (! NILP (val)) | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1109 { |
94926 | 1110 val = font_prop_validate_spacing (QCspacing, val); |
1111 if (! INTEGERP (val)) | |
1112 return -1; | |
1113 ASET (font, FONT_SPACING_INDEX, val); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1114 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1115 p = f[XLFD_AVGWIDTH_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1116 if (*p == '~') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1117 p++; |
94926 | 1118 ASET (font, FONT_AVGWIDTH_INDEX, |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1119 font_intern_prop (p, f[XLFD_REGISTRY_INDEX] - 1 - p, 1)); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1120 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1121 else |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1122 { |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1123 int wild_card_found = 0; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1124 Lisp_Object prop[XLFD_LAST_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1125 |
94926 | 1126 if (FONT_ENTITY_P (font)) |
1127 return -1; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1128 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
|
1129 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1130 if (*f[j] == '*') |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1131 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1132 if (f[j][1] && f[j][1] != '-') |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1133 return -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1134 prop[j] = Qnil; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1135 wild_card_found = 1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1136 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1137 else if (j + 1 < i) |
94926 | 1138 prop[j] = INTERN_FIELD (j); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1139 else |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1140 prop[j] = font_intern_prop (f[j], f[i] - f[j], 0); |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1141 } |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1142 if (! wild_card_found) |
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
1143 return -1; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1144 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
|
1145 return -1; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1146 |
94926 | 1147 ASET (font, FONT_FOUNDRY_INDEX, prop[XLFD_FOUNDRY_INDEX]); |
1148 ASET (font, FONT_FAMILY_INDEX, prop[XLFD_FAMILY_INDEX]); | |
1149 for (i = XLFD_WEIGHT_INDEX, j = FONT_WEIGHT_INDEX; | |
1150 i <= XLFD_SWIDTH_INDEX; i++, j++) | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1151 if (! NILP (prop[i])) |
94926 | 1152 { |
1153 if ((n = font_style_to_value (j, prop[i], 1)) < 0) | |
1154 return -1; | |
1155 ASET (font, j, make_number (n)); | |
1156 } | |
1157 ASET (font, FONT_ADSTYLE_INDEX, prop[XLFD_ADSTYLE_INDEX]); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1158 val = prop[XLFD_REGISTRY_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1159 if (NILP (val)) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1160 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1161 val = prop[XLFD_ENCODING_INDEX]; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1162 if (! NILP (val)) |
94926 | 1163 val = concat2 (build_string ("*-"), SYMBOL_NAME (val)); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1164 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1165 else if (NILP (prop[XLFD_ENCODING_INDEX])) |
94926 | 1166 val = concat2 (SYMBOL_NAME (val), build_string ("-*")); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1167 else |
94926 | 1168 val = concat3 (SYMBOL_NAME (val), build_string ("-"), |
1169 SYMBOL_NAME (prop[XLFD_ENCODING_INDEX])); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1170 if (! NILP (val)) |
94926 | 1171 ASET (font, FONT_REGISTRY_INDEX, Fintern (val, Qnil)); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1172 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1173 if (INTEGERP (prop[XLFD_PIXEL_INDEX])) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1174 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
|
1175 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
|
1176 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1177 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
|
1178 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1179 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
|
1180 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1181 |
94926 | 1182 if (INTEGERP (prop[XLFD_RESX_INDEX])) |
1183 ASET (font, FONT_DPI_INDEX, prop[XLFD_RESY_INDEX]); | |
1184 if (! NILP (prop[XLFD_SPACING_INDEX])) | |
1185 { | |
1186 val = font_prop_validate_spacing (QCspacing, | |
1187 prop[XLFD_SPACING_INDEX]); | |
1188 if (! INTEGERP (val)) | |
1189 return -1; | |
1190 ASET (font, FONT_SPACING_INDEX, val); | |
1191 } | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1192 if (INTEGERP (prop[XLFD_AVGWIDTH_INDEX])) |
94926 | 1193 ASET (font, FONT_AVGWIDTH_INDEX, 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
|
1194 } |
90400 | 1195 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1196 return 0; |
90400 | 1197 } |
1198 | |
1199 /* Store XLFD name of FONT (font-spec or font-entity) in NAME (NBYTES | |
1200 length), and return the name length. If FONT_SIZE_INDEX of FONT is | |
1201 0, use PIXEL_SIZE instead. */ | |
1202 | |
1203 int | |
1204 font_unparse_xlfd (font, pixel_size, name, nbytes) | |
1205 Lisp_Object font; | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1206 int pixel_size; |
90400 | 1207 char *name; |
1208 int nbytes; | |
1209 { | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1210 char *f[XLFD_REGISTRY_INDEX + 1]; |
90400 | 1211 Lisp_Object val; |
1212 int i, j, len = 0; | |
1213 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
1214 font_assert (FONTP (font)); |
90400 | 1215 |
1216 for (i = FONT_FOUNDRY_INDEX, j = XLFD_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; | |
1217 i++, j++) | |
1218 { | |
1219 if (i == FONT_ADSTYLE_INDEX) | |
1220 j = XLFD_ADSTYLE_INDEX; | |
1221 else if (i == FONT_REGISTRY_INDEX) | |
1222 j = XLFD_REGISTRY_INDEX; | |
1223 val = AREF (font, i); | |
1224 if (NILP (val)) | |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1225 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1226 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
|
1227 f[j] = "*-*", len += 4; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1228 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1229 f[j] = "*", len += 2; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1230 } |
90400 | 1231 else |
1232 { | |
1233 if (SYMBOLP (val)) | |
1234 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
|
1235 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
|
1236 && ! strchr ((char *) SDATA (val), '-')) |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1237 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1238 /* 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
|
1239 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
|
1240 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1241 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
|
1242 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
|
1243 len += SBYTES (val) + 3; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1244 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1245 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1246 { |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1247 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
|
1248 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
|
1249 len += SBYTES (val) + 4; |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1250 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1251 } |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1252 else |
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1253 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; |
90400 | 1254 } |
1255 } | |
1256 | |
1257 for (i = FONT_WEIGHT_INDEX, j = XLFD_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; | |
1258 i++, j++) | |
1259 { | |
94926 | 1260 val = font_style_symbolic (font, i, 0); |
90400 | 1261 if (NILP (val)) |
1262 f[j] = "*", len += 2; | |
1263 else | |
1264 { | |
94926 | 1265 val = SYMBOL_NAME (val); |
90400 | 1266 f[j] = (char *) SDATA (val), len += SBYTES (val) + 1; |
1267 } | |
1268 } | |
1269 | |
1270 val = AREF (font, FONT_SIZE_INDEX); | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
1271 font_assert (NUMBERP (val) || NILP (val)); |
90400 | 1272 if (INTEGERP (val)) |
1273 { | |
94926 | 1274 i = XINT (val); |
91943
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1275 if (i <= 0) |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1276 i = pixel_size; |
90400 | 1277 if (i > 0) |
91943
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1278 { |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1279 f[XLFD_PIXEL_INDEX] = alloca (22); |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1280 len += sprintf (f[XLFD_PIXEL_INDEX], "%d-*", i) + 1; |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1281 } |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1282 else |
c5e5ad126614
(font_unparse_xlfd): Don't ignore integer pixel size specs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91909
diff
changeset
|
1283 f[XLFD_PIXEL_INDEX] = "*-*", len += 4; |
90400 | 1284 } |
1285 else if (FLOATP (val)) | |
1286 { | |
94926 | 1287 i = XFLOAT_DATA (val) * 10; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1288 f[XLFD_PIXEL_INDEX] = alloca (12); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1289 len += sprintf (f[XLFD_PIXEL_INDEX], "*-%d", i) + 1; |
90400 | 1290 } |
1291 else | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1292 f[XLFD_PIXEL_INDEX] = "*-*", len += 4; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1293 |
94926 | 1294 if (INTEGERP (AREF (font, FONT_DPI_INDEX))) |
90400 | 1295 { |
94926 | 1296 i = XINT (AREF (font, FONT_DPI_INDEX)); |
1297 f[XLFD_RESX_INDEX] = alloca (22); | |
1298 len += sprintf (f[XLFD_RESX_INDEX], | |
1299 "%d-%d", i, i) + 1; | |
90400 | 1300 } |
1301 else | |
94926 | 1302 f[XLFD_RESX_INDEX] = "*-*", len += 4; |
1303 if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1304 { |
94926 | 1305 int spacing = XINT (AREF (font, FONT_SPACING_INDEX)); |
1306 | |
1307 f[XLFD_SPACING_INDEX] = (spacing <= FONT_SPACING_PROPORTIONAL ? "p" | |
1308 : spacing <= FONT_SPACING_DUAL ? "d" | |
1309 : spacing <= FONT_SPACING_MONO ? "m" | |
1310 : "c"); | |
1311 len += 2; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1312 } |
94926 | 1313 else |
1314 f[XLFD_SPACING_INDEX] = "*", len += 2; | |
1315 if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | |
1316 { | |
1317 f[XLFD_AVGWIDTH_INDEX] = alloca (11); | |
1318 len += sprintf (f[XLFD_AVGWIDTH_INDEX], | |
1319 "%d", XINT (AREF (font, FONT_AVGWIDTH_INDEX))) + 1; | |
1320 } | |
1321 else | |
1322 f[XLFD_AVGWIDTH_INDEX] = "*", len += 2; | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1323 len++; /* for terminating '\0'. */ |
90400 | 1324 if (len >= nbytes) |
1325 return -1; | |
94926 | 1326 return sprintf (name, "-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s", |
90400 | 1327 f[XLFD_FOUNDRY_INDEX], f[XLFD_FAMILY_INDEX], |
1328 f[XLFD_WEIGHT_INDEX], f[XLFD_SLANT_INDEX], | |
94926 | 1329 f[XLFD_SWIDTH_INDEX], f[XLFD_ADSTYLE_INDEX], |
1330 f[XLFD_PIXEL_INDEX], f[XLFD_RESX_INDEX], | |
1331 f[XLFD_SPACING_INDEX], f[XLFD_AVGWIDTH_INDEX], | |
1332 f[XLFD_REGISTRY_INDEX]); | |
90400 | 1333 } |
1334 | |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1335 /* Parse NAME (null terminated) and store information in FONT |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1336 (font-spec or font-entity). NAME is supplied in either the |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1337 Fontconfig or GTK font name format. If NAME is successfully |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1338 parsed, return 0. Otherwise return -1. |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1339 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1340 The fontconfig format is |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1341 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1342 FAMILY[-SIZE][:PROP1[=VAL1][:PROP2[=VAL2]...]] |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1343 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1344 The GTK format is |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1345 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1346 FAMILY [PROPS...] [SIZE] |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1347 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1348 This function tries to guess which format it is. */ |
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 int |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1351 font_parse_fcname (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 { |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1355 char *p, *q; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1356 char *size_beg = NULL, *size_end = NULL; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1357 char *props_beg = NULL, *family_end = NULL; |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1358 int len = strlen (name); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1359 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1360 if (len == 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1361 return -1; |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1362 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1363 for (p = name; *p; p++) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1364 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1365 if (*p == '\\' && p[1]) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1366 p++; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1367 else if (*p == ':') |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1368 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1369 family_end = p; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1370 props_beg = p + 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1371 break; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1372 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1373 else if (*p == '-') |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1374 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1375 int size_found = 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1376 for (q = p + 1; *q && *q != ':'; q++) |
95824
27e773c9952b
(font_parse_fcname): Fix last change; accept decimal points in font
Chong Yidong <cyd@stupidchicken.com>
parents:
95790
diff
changeset
|
1377 if (! isdigit(*q) && *q != '.') |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1378 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1379 size_found = 0; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1380 break; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1381 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1382 if (size_found) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1383 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1384 family_end = p; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1385 size_beg = p + 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1386 size_end = q; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1387 break; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1388 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1389 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1390 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1391 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1392 if (family_end) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1393 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1394 /* A fontconfig name with size and/or property data. */ |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1395 if (family_end > name) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1396 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1397 Lisp_Object family; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1398 family = font_intern_prop (name, family_end - name, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1399 ASET (font, FONT_FAMILY_INDEX, family); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1400 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1401 if (size_beg) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1402 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1403 double point_size = strtod (size_beg, &size_end); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1404 ASET (font, FONT_SIZE_INDEX, make_float (point_size)); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1405 if (*size_end == ':' && size_end[1]) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1406 props_beg = size_end + 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1407 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1408 if (props_beg) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1409 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1410 /* Now parse ":KEY=VAL" patterns. Store known keys and values in |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1411 extra, copy unknown ones to COPY. It is stored in extra slot by |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1412 the key QCfc_unknown_spec. */ |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1413 char *copy; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1414 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1415 name = copy = alloca (name + len - props_beg); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1416 if (! copy) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1417 return -1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1418 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1419 p = props_beg; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1420 while (*p) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1421 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1422 Lisp_Object val; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1423 int word_len, prop; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1424 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1425 #define PROP_MATCH(STR,N) ((word_len == N) && memcmp (p, STR, N) == 0) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1426 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1427 for (q = p + 1; *q && *q != '=' && *q != ':'; q++); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1428 word_len = q - p; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1429 if (*q != '=') |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1430 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1431 /* Must be an enumerated value. */ |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1432 val = font_intern_prop (p, q - p, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1433 if (PROP_MATCH ("light", 5) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1434 || PROP_MATCH ("medium", 6) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1435 || PROP_MATCH ("demibold", 8) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1436 || PROP_MATCH ("bold", 4) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1437 || PROP_MATCH ("black", 5)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1438 FONT_SET_STYLE (font, FONT_WEIGHT_INDEX, val); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1439 else if (PROP_MATCH ("roman", 5) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1440 || PROP_MATCH ("italic", 6) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1441 || PROP_MATCH ("oblique", 7)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1442 FONT_SET_STYLE (font, FONT_SLANT_INDEX, val); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1443 else if (PROP_MATCH ("charcell", 8)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1444 ASET (font, FONT_SPACING_INDEX, |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1445 make_number (FONT_SPACING_CHARCELL)); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1446 else if (PROP_MATCH ("mono", 4)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1447 ASET (font, FONT_SPACING_INDEX, |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1448 make_number (FONT_SPACING_MONO)); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1449 else if (PROP_MATCH ("proportional", 12)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1450 ASET (font, FONT_SPACING_INDEX, |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1451 make_number (FONT_SPACING_PROPORTIONAL)); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1452 else |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1453 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1454 /* Unknown key */ |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1455 bcopy (p, copy, word_len); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1456 copy += word_len; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1457 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1458 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1459 else /* KEY=VAL pairs */ |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1460 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1461 Lisp_Object key; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1462 char *keyhead = p; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1463 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1464 if (PROP_MATCH ("pixelsize=", 10)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1465 prop = FONT_SIZE_INDEX; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1466 else |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1467 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1468 key = font_intern_prop (p, q - p, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1469 prop = get_font_prop_index (key); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1470 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1471 p = q + 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1472 for (q = p; *q && *q != ':'; q++); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1473 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1474 val = font_intern_prop (p, word_len, 0); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1475 if (! NILP (val)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1476 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1477 if (prop >= FONT_FOUNDRY_INDEX |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1478 && prop < FONT_EXTRA_INDEX) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1479 ASET (font, prop, |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1480 font_prop_validate (prop, Qnil, val)); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1481 else if (prop >= 0) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1482 Ffont_put (font, key, val); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1483 else |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1484 bcopy (keyhead, copy, q - keyhead); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1485 copy += q - keyhead; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1486 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1487 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1488 p = *q ? q + 1 : q; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1489 #undef PROP_MATCH |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1490 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1491 if (name != copy) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1492 font_put_extra (font, QCfc_unknown_spec, |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1493 make_unibyte_string (name, copy - name)); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1494 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1495 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1496 else |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1497 { |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1498 /* Either a fontconfig-style name with no size and property |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1499 data, or a GTK-style name. */ |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1500 Lisp_Object prop; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1501 int word_len, prop_found = 0; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1502 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1503 for (p = name; *p; p = *q ? q + 1 : q) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1504 { |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1505 if (isdigit (*p)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1506 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1507 char *r; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1508 int size_found = 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1509 for (q = p + 1; *q && *q != ' '; q++) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1510 if (! isdigit (*q)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1511 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1512 size_found = 0; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1513 break; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1514 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1515 if (size_found) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1516 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1517 double point_size = strtod (p, &q); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1518 ASET (font, FONT_SIZE_INDEX, make_float (point_size)); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1519 continue; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1520 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1521 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1522 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1523 for (q = p + 1; *q && *q != ' '; q++) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1524 if (*q == '\\' && q[1]) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1525 q++; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1526 word_len = q - p; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1527 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1528 #define PROP_MATCH(STR,N) ((word_len == N) && memcmp (p, STR, N) == 0) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1529 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1530 if (PROP_MATCH ("Ultra-Light", 11)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1531 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1532 prop_found = 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1533 prop = font_intern_prop ("ultra-light", 11, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1534 FONT_SET_STYLE (font, FONT_WEIGHT_INDEX, prop); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1535 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1536 else if (PROP_MATCH ("Light", 5)) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1537 { |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1538 prop_found = 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1539 prop = font_intern_prop ("light", 5, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1540 FONT_SET_STYLE (font, FONT_WEIGHT_INDEX, prop); |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
1541 } |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1542 else if (PROP_MATCH ("Semi-Bold", 9)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1543 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1544 prop_found = 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1545 prop = font_intern_prop ("semi-bold", 9, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1546 FONT_SET_STYLE (font, FONT_WEIGHT_INDEX, prop); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1547 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1548 else if (PROP_MATCH ("Bold", 4)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1549 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1550 prop_found = 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1551 prop = font_intern_prop ("bold", 4, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1552 FONT_SET_STYLE (font, FONT_WEIGHT_INDEX, prop); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1553 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1554 else if (PROP_MATCH ("Italic", 6)) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1555 { |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1556 prop_found = 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1557 prop = font_intern_prop ("italic", 4, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1558 FONT_SET_STYLE (font, FONT_SLANT_INDEX, prop); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1559 } |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1560 else if (PROP_MATCH ("Oblique", 7)) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1561 { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1562 prop_found = 1; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1563 prop = font_intern_prop ("oblique", 7, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1564 FONT_SET_STYLE (font, FONT_SLANT_INDEX, prop); |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1565 } |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1566 else { |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1567 if (prop_found) |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1568 return -1; /* Unknown property in GTK-style font name. */ |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1569 family_end = q; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1570 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1571 } |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1572 #undef PROP_MATCH |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1573 |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1574 if (family_end) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1575 { |
95790
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1576 Lisp_Object family; |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1577 family = font_intern_prop (name, family_end - name, 1); |
a486132d892c
(font_parse_fcname): Accept GTK-style font names too.
Chong Yidong <cyd@stupidchicken.com>
parents:
95746
diff
changeset
|
1578 ASET (font, FONT_FAMILY_INDEX, family); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1579 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1580 } |
95886
c8bc52f94b6d
(syms_of_font) <font-weight-table, font-slant-table, font-width-table>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95875
diff
changeset
|
1581 |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
1582 return 0; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1583 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1584 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1585 /* 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
|
1586 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
|
1587 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
|
1588 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1589 int |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1590 font_unparse_fcname (font, pixel_size, name, nbytes) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1591 Lisp_Object font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1592 int pixel_size; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1593 char *name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1594 int nbytes; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1595 { |
94926 | 1596 Lisp_Object tail, val; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1597 int point_size; |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
1598 int dpi; |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1599 int i, len = 1; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1600 char *p; |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1601 Lisp_Object styles[3]; |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
1602 char *style_names[3] = { "weight", "slant", "width" }; |
94926 | 1603 char work[256]; |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1604 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1605 val = AREF (font, FONT_FAMILY_INDEX); |
94926 | 1606 if (STRINGP (val)) |
1607 len += SBYTES (val); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1608 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1609 val = AREF (font, FONT_SIZE_INDEX); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1610 if (INTEGERP (val)) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1611 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1612 if (XINT (val) != 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1613 pixel_size = XINT (val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1614 point_size = -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1615 len += 21; /* for ":pixelsize=NUM" */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1616 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1617 else if (FLOATP (val)) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1618 { |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1619 pixel_size = -1; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1620 point_size = (int) XFLOAT_DATA (val); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1621 len += 11; /* for "-NUM" */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1622 } |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1623 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1624 val = AREF (font, FONT_FOUNDRY_INDEX); |
94926 | 1625 if (STRINGP (val)) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1626 /* ":foundry=NAME" */ |
94926 | 1627 len += 9 + SBYTES (val); |
1628 | |
1629 for (i = 0; i < 3; i++) | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1630 { |
94926 | 1631 styles[i] = font_style_symbolic (font, FONT_WEIGHT_INDEX + i, 0); |
1632 if (! NILP (styles[i])) | |
1633 len += sprintf (work, ":%s=%s", style_names[i], | |
1634 SDATA (SYMBOL_NAME (styles[i]))); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1635 } |
94926 | 1636 |
1637 if (INTEGERP (AREF (font, FONT_DPI_INDEX))) | |
1638 len += sprintf (work, ":dpi=%d", dpi); | |
1639 if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) | |
1640 len += strlen (":spacing=100"); | |
1641 if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | |
1642 len += strlen (":scalable=false"); /* or ":scalable=true" */ | |
1643 for (tail = AREF (font, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1644 { |
94926 | 1645 Lisp_Object key = XCAR (XCAR (tail)), val = XCDR (XCAR (tail)); |
1646 | |
1647 len += SBYTES (SYMBOL_NAME (key)) + 1; /* for :KEY= */ | |
1648 if (STRINGP (val)) | |
1649 len += SBYTES (val); | |
1650 else if (INTEGERP (val)) | |
1651 len += sprintf (work, "%d", XINT (val)); | |
1652 else if (SYMBOLP (val)) | |
1653 len += (NILP (val) ? 5 : 4); /* for "false" or "true" */ | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1654 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1655 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1656 if (len > nbytes) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1657 return -1; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1658 p = name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1659 if (! NILP (AREF (font, FONT_FAMILY_INDEX))) |
94926 | 1660 p += sprintf(p, "%s", 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
|
1661 if (point_size > 0) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1662 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1663 if (p == name) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1664 p += sprintf (p, "%d", point_size); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1665 else |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1666 p += sprintf (p, "-%d", point_size); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1667 } |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1668 else if (pixel_size > 0) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1669 p += sprintf (p, ":pixelsize=%d", pixel_size); |
94926 | 1670 if (! NILP (AREF (font, FONT_FOUNDRY_INDEX))) |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1671 p += sprintf (p, ":foundry=%s", |
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1672 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
|
1673 for (i = 0; i < 3; i++) |
94926 | 1674 if (! NILP (styles[i])) |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
1675 p += sprintf (p, ":%s=%s", style_names[i], |
94926 | 1676 SDATA (SYMBOL_NAME (styles[i]))); |
1677 if (INTEGERP (AREF (font, FONT_DPI_INDEX))) | |
1678 p += sprintf (p, ":dpi=%d", XINT (AREF (font, FONT_DPI_INDEX))); | |
1679 if (INTEGERP (AREF (font, FONT_SPACING_INDEX))) | |
1680 p += sprintf (p, ":spacing=%d", XINT (AREF (font, FONT_SPACING_INDEX))); | |
1681 if (INTEGERP (AREF (font, FONT_AVGWIDTH_INDEX))) | |
1682 { | |
1683 if (XINT (AREF (font, FONT_AVGWIDTH_INDEX)) == 0) | |
1684 p += sprintf (p, ":scalable=true"); | |
1685 else | |
1686 p += sprintf (p, ":scalable=false"); | |
1687 } | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1688 return (p - name); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1689 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1690 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1691 /* 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
|
1692 (font-spec or font-entity). If NAME is successfully parsed, return |
94926 | 1693 0. Otherwise return -1. */ |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1694 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1695 static int |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1696 font_parse_name (name, font) |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1697 char *name; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1698 Lisp_Object font; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1699 { |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1700 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
|
1701 return font_parse_xlfd (name, font); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
1702 return font_parse_fcname (name, font); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1703 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
1704 |
94926 | 1705 |
1706 /* Merge FAMILY and REGISTRY into FONT_SPEC. FAMILY may have the form | |
1707 "FAMILY-FOUNDRY". REGISTRY may not contain charset-encoding | |
1708 part. */ | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1709 |
90400 | 1710 void |
94926 | 1711 font_parse_family_registry (family, registry, font_spec) |
1712 Lisp_Object family, registry, font_spec; | |
90400 | 1713 { |
94926 | 1714 int len; |
1715 char *p0, *p1; | |
1716 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
1717 if (! NILP (family) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
1718 && NILP (AREF (font_spec, FONT_FAMILY_INDEX))) |
90400 | 1719 { |
94926 | 1720 CHECK_STRING (family); |
1721 len = SBYTES (family); | |
1722 p0 = (char *) SDATA (family); | |
1723 p1 = index (p0, '-'); | |
1724 if (p1) | |
90400 | 1725 { |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
1726 if ((*p0 != '*' || p1 - p0 > 1) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
1727 && NILP (AREF (font_spec, FONT_FOUNDRY_INDEX))) |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1728 Ffont_put (font_spec, QCfoundry, font_intern_prop (p0, p1 - p0, 1)); |
94926 | 1729 p1++; |
1730 len -= p1 - p0; | |
95746
b490fda95b13
(font_intern_prop): New arg force_symbol.
Kenichi Handa <handa@m17n.org>
parents:
95699
diff
changeset
|
1731 Ffont_put (font_spec, QCfamily, font_intern_prop (p1, len, 1)); |
90400 | 1732 } |
94926 | 1733 else |
1734 ASET (font_spec, FONT_FAMILY_INDEX, Fintern (family, Qnil)); | |
1735 } | |
1736 if (! NILP (registry)) | |
1737 { | |
1738 /* Convert "XXX" and "XXX*" to "XXX*-*". */ | |
1739 CHECK_STRING (registry); | |
1740 len = SBYTES (registry); | |
1741 p0 = (char *) SDATA (registry); | |
1742 p1 = index (p0, '-'); | |
1743 if (! p1) | |
1744 { | |
1745 if (SDATA (registry)[len - 1] == '*') | |
1746 registry = concat2 (registry, build_string ("-*")); | |
1747 else | |
1748 registry = concat2 (registry, build_string ("*-*")); | |
1749 } | |
1750 registry = Fdowncase (registry); | |
1751 ASET (font_spec, FONT_REGISTRY_INDEX, Fintern (registry, Qnil)); | |
90400 | 1752 } |
1753 } | |
1754 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1755 |
94926 | 1756 /* This part (through the next ^L) is still experimental and not |
1757 tested much. We may drastically change codes. */ | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1758 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
1759 /* OTF handler */ |
90541 | 1760 |
95290
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
1761 #if 0 |
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
1762 |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1763 #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
|
1764 #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
|
1765 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1766 static int |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1767 check_gstring (gstring) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1768 Lisp_Object gstring; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1769 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1770 Lisp_Object val; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1771 int i, j; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1772 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1773 CHECK_VECTOR (gstring); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1774 val = AREF (gstring, 0); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1775 CHECK_VECTOR (val); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1776 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
|
1777 goto err; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1778 CHECK_FONT_OBJECT (LGSTRING_FONT (gstring)); |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1779 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_LBEARING))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1780 CHECK_NUMBER (LGSTRING_SLOT (gstring, LGSTRING_IX_LBEARING)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1781 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_RBEARING))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1782 CHECK_NUMBER (LGSTRING_SLOT (gstring, LGSTRING_IX_RBEARING)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1783 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_WIDTH))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1784 CHECK_NATNUM (LGSTRING_SLOT (gstring, LGSTRING_IX_WIDTH)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1785 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_ASCENT))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1786 CHECK_NUMBER (LGSTRING_SLOT (gstring, LGSTRING_IX_ASCENT)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1787 if (!NILP (LGSTRING_SLOT (gstring, LGSTRING_IX_ASCENT))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1788 CHECK_NUMBER (LGSTRING_SLOT (gstring, LGSTRING_IX_ASCENT)); |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1789 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1790 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
|
1791 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1792 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
|
1793 CHECK_VECTOR (val); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1794 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
|
1795 goto err; |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1796 if (NILP (AREF (val, LGLYPH_IX_CHAR))) |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1797 break; |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1798 CHECK_NATNUM (AREF (val, LGLYPH_IX_FROM)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1799 CHECK_NATNUM (AREF (val, LGLYPH_IX_TO)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1800 CHECK_CHARACTER (AREF (val, LGLYPH_IX_CHAR)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1801 if (!NILP (AREF (val, LGLYPH_IX_CODE))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1802 CHECK_NATNUM (AREF (val, LGLYPH_IX_CODE)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1803 if (!NILP (AREF (val, LGLYPH_IX_WIDTH))) |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1804 CHECK_NATNUM (AREF (val, LGLYPH_IX_WIDTH)); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1805 if (!NILP (AREF (val, LGLYPH_IX_ADJUSTMENT))) |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1806 { |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
1807 val = AREF (val, LGLYPH_IX_ADJUSTMENT); |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1808 CHECK_VECTOR (val); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1809 if (ASIZE (val) < 3) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1810 goto err; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1811 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
|
1812 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
|
1813 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1814 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1815 return i; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1816 err: |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1817 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
|
1818 return -1; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1819 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
1820 |
90823
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1821 static void |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1822 check_otf_features (otf_features) |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1823 Lisp_Object otf_features; |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1824 { |
94926 | 1825 Lisp_Object val; |
90823
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1826 |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1827 CHECK_CONS (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1828 CHECK_SYMBOL (XCAR (otf_features)); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1829 otf_features = XCDR (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1830 CHECK_CONS (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1831 CHECK_SYMBOL (XCAR (otf_features)); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1832 otf_features = XCDR (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1833 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
|
1834 { |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1835 CHECK_SYMBOL (Fcar (val)); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1836 if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4) |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1837 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
|
1838 } |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1839 otf_features = XCDR (otf_features); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1840 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
|
1841 { |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1842 CHECK_SYMBOL (Fcar (val)); |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1843 if (SBYTES (SYMBOL_NAME (XCAR (val))) > 4) |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1844 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
|
1845 } |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1846 } |
b08ad368c328
(check_otf_features): Define it regardless of
Kenichi Handa <handa@m17n.org>
parents:
90817
diff
changeset
|
1847 |
90400 | 1848 #ifdef HAVE_LIBOTF |
1849 #include <otf.h> | |
1850 | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1851 Lisp_Object otf_list; |
90400 | 1852 |
1853 static Lisp_Object | |
1854 otf_tag_symbol (tag) | |
1855 OTF_Tag tag; | |
1856 { | |
1857 char name[5]; | |
1858 | |
1859 OTF_tag_name (tag, name); | |
1860 return Fintern (make_unibyte_string (name, 4), Qnil); | |
1861 } | |
1862 | |
1863 static OTF * | |
94926 | 1864 otf_open (file) |
1865 Lisp_Object file; | |
90400 | 1866 { |
94926 | 1867 Lisp_Object val = Fassoc (file, otf_list); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1868 OTF *otf; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1869 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1870 if (! NILP (val)) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1871 otf = XSAVE_VALUE (XCDR (val))->pointer; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1872 else |
90400 | 1873 { |
94926 | 1874 otf = STRINGP (file) ? OTF_open ((char *) SDATA (file)) : NULL; |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1875 val = make_save_value (otf, 0); |
94926 | 1876 otf_list = Fcons (Fcons (file, val), otf_list); |
90400 | 1877 } |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1878 return otf; |
90400 | 1879 } |
1880 | |
1881 | |
1882 /* Return a list describing which scripts/languages FONT supports by | |
1883 which GSUB/GPOS features of OpenType tables. See the comment of | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
1884 (struct font_driver).otf_capability. */ |
90400 | 1885 |
1886 Lisp_Object | |
1887 font_otf_capability (font) | |
1888 struct font *font; | |
1889 { | |
1890 OTF *otf; | |
1891 Lisp_Object capability = Fcons (Qnil, Qnil); | |
1892 int i; | |
1893 | |
94926 | 1894 otf = otf_open (font->props[FONT_FILE_INDEX]); |
90400 | 1895 if (! otf) |
1896 return Qnil; | |
1897 for (i = 0; i < 2; i++) | |
1898 { | |
1899 OTF_GSUB_GPOS *gsub_gpos; | |
1900 Lisp_Object script_list = Qnil; | |
1901 int j; | |
1902 | |
1903 if (OTF_get_features (otf, i == 0) < 0) | |
1904 continue; | |
1905 gsub_gpos = i == 0 ? otf->gsub : otf->gpos; | |
1906 for (j = gsub_gpos->ScriptList.ScriptCount - 1; j >= 0; j--) | |
1907 { | |
1908 OTF_Script *script = gsub_gpos->ScriptList.Script + j; | |
1909 Lisp_Object langsys_list = Qnil; | |
1910 Lisp_Object script_tag = otf_tag_symbol (script->ScriptTag); | |
1911 int k; | |
1912 | |
1913 for (k = script->LangSysCount; k >= 0; k--) | |
1914 { | |
1915 OTF_LangSys *langsys; | |
1916 Lisp_Object feature_list = Qnil; | |
1917 Lisp_Object langsys_tag; | |
1918 int l; | |
1919 | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1920 if (k == script->LangSysCount) |
90400 | 1921 { |
1922 langsys = &script->DefaultLangSys; | |
1923 langsys_tag = Qnil; | |
1924 } | |
1925 else | |
1926 { | |
1927 langsys = script->LangSys + k; | |
1928 langsys_tag | |
1929 = otf_tag_symbol (script->LangSysRecord[k].LangSysTag); | |
1930 } | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1931 for (l = langsys->FeatureCount - 1; l >= 0; l--) |
90400 | 1932 { |
1933 OTF_Feature *feature | |
1934 = gsub_gpos->FeatureList.Feature + langsys->FeatureIndex[l]; | |
1935 Lisp_Object feature_tag | |
1936 = otf_tag_symbol (feature->FeatureTag); | |
1937 | |
1938 feature_list = Fcons (feature_tag, feature_list); | |
1939 } | |
1940 langsys_list = Fcons (Fcons (langsys_tag, feature_list), | |
1941 langsys_list); | |
1942 } | |
1943 script_list = Fcons (Fcons (script_tag, langsys_list), | |
1944 script_list); | |
1945 } | |
1946 | |
1947 if (i == 0) | |
1948 XSETCAR (capability, script_list); | |
1949 else | |
1950 XSETCDR (capability, script_list); | |
1951 } | |
1952 | |
1953 return capability; | |
1954 } | |
1955 | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1956 /* 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
|
1957 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
|
1958 assured that the sufficient memory has already allocated for |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1959 FEATURES. */ |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1960 |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1961 static void |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1962 generate_otf_features (spec, features) |
90400 | 1963 Lisp_Object spec; |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1964 char *features; |
90400 | 1965 { |
1966 Lisp_Object val; | |
94926 | 1967 char *p; |
90400 | 1968 int asterisk; |
1969 | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1970 p = features; |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1971 *p = '\0'; |
90400 | 1972 for (asterisk = 0; CONSP (spec); spec = XCDR (spec)) |
1973 { | |
1974 val = XCAR (spec); | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1975 CHECK_SYMBOL (val); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1976 if (p > features) |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1977 *p++ = ','; |
90400 | 1978 if (SREF (SYMBOL_NAME (val), 0) == '*') |
1979 { | |
1980 asterisk = 1; | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1981 *p++ = '*'; |
90400 | 1982 } |
1983 else if (! asterisk) | |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1984 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1985 val = SYMBOL_NAME (val); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1986 p += sprintf (p, "%s", SDATA (val)); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1987 } |
90400 | 1988 else |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1989 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1990 val = SYMBOL_NAME (val); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1991 p += sprintf (p, "~%s", SDATA (val)); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1992 } |
90400 | 1993 } |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1994 if (CONSP (spec)) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1995 error ("OTF spec too long"); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1996 } |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
1997 |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1998 Lisp_Object |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
1999 font_otf_DeviceTable (device_table) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2000 OTF_DeviceTable *device_table; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2001 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2002 int len = device_table->StartSize - device_table->EndSize + 1; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2003 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2004 return Fcons (make_number (len), |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2005 make_unibyte_string (device_table->DeltaValue, len)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2006 } |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2007 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2008 Lisp_Object |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2009 font_otf_ValueRecord (value_format, value_record) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2010 int value_format; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2011 OTF_ValueRecord *value_record; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2012 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2013 Lisp_Object val = Fmake_vector (make_number (8), Qnil); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2014 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2015 if (value_format & OTF_XPlacement) |
91909 | 2016 ASET (val, 0, make_number (value_record->XPlacement)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2017 if (value_format & OTF_YPlacement) |
91909 | 2018 ASET (val, 1, make_number (value_record->YPlacement)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2019 if (value_format & OTF_XAdvance) |
91909 | 2020 ASET (val, 2, make_number (value_record->XAdvance)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2021 if (value_format & OTF_YAdvance) |
91909 | 2022 ASET (val, 3, make_number (value_record->YAdvance)); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2023 if (value_format & OTF_XPlaDevice) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2024 ASET (val, 4, font_otf_DeviceTable (&value_record->XPlaDevice)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2025 if (value_format & OTF_YPlaDevice) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2026 ASET (val, 4, font_otf_DeviceTable (&value_record->YPlaDevice)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2027 if (value_format & OTF_XAdvDevice) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2028 ASET (val, 4, font_otf_DeviceTable (&value_record->XAdvDevice)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2029 if (value_format & OTF_YAdvDevice) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2030 ASET (val, 4, font_otf_DeviceTable (&value_record->YAdvDevice)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2031 return val; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2032 } |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2033 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2034 Lisp_Object |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2035 font_otf_Anchor (anchor) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2036 OTF_Anchor *anchor; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2037 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2038 Lisp_Object val; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2039 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2040 val = Fmake_vector (make_number (anchor->AnchorFormat + 1), Qnil); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2041 ASET (val, 0, make_number (anchor->XCoordinate)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2042 ASET (val, 1, make_number (anchor->YCoordinate)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2043 if (anchor->AnchorFormat == 2) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2044 ASET (val, 2, make_number (anchor->f.f1.AnchorPoint)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2045 else |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2046 { |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2047 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
|
2048 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
|
2049 } |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2050 return val; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
2051 } |
90400 | 2052 #endif /* HAVE_LIBOTF */ |
95290
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
2053 #endif /* 0 */ |
90400 | 2054 |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
2055 /* G-string (glyph string) handler */ |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
2056 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
2057 /* 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
|
2058 See the docstring of `font-make-gstring' for more detail. */ |
90400 | 2059 |
2060 struct font * | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2061 font_prepare_composition (cmp, f) |
90400 | 2062 struct composition *cmp; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2063 FRAME_PTR f; |
90400 | 2064 { |
2065 Lisp_Object gstring | |
2066 = AREF (XHASH_TABLE (composition_hash_table)->key_and_value, | |
2067 cmp->hash_index * 2); | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2068 |
94926 | 2069 cmp->font = XFONT_OBJECT (LGSTRING_FONT (gstring)); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2070 cmp->glyph_len = LGSTRING_LENGTH (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2071 cmp->pixel_width = LGSTRING_WIDTH (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2072 cmp->lbearing = LGSTRING_LBEARING (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2073 cmp->rbearing = LGSTRING_RBEARING (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2074 cmp->ascent = LGSTRING_ASCENT (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2075 cmp->descent = LGSTRING_DESCENT (gstring); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2076 cmp->width = cmp->pixel_width / FRAME_COLUMN_WIDTH (f); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2077 if (cmp->width == 0) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2078 cmp->width = 1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2079 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2080 return cmp->font; |
90400 | 2081 } |
2082 | |
2083 | |
2084 /* Font sorting */ | |
2085 | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2086 static unsigned font_score P_ ((Lisp_Object, Lisp_Object *)); |
90400 | 2087 static int font_compare P_ ((const void *, const void *)); |
2088 static Lisp_Object font_sort_entites P_ ((Lisp_Object, Lisp_Object, | |
94926 | 2089 Lisp_Object, Lisp_Object, |
2090 int)); | |
90400 | 2091 |
2092 /* We sort fonts by scoring each of them against a specified | |
2093 font-spec. The score value is 32 bit (`unsigned'), and the smaller | |
2094 the value is, the closer the font is to the font-spec. | |
2095 | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2096 The lowest 2 bits of the score is used for driver type. The font |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2097 available by the most preferred font driver is 0. |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2098 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2099 Each 7-bit in the higher 28 bits are used for numeric properties |
90400 | 2100 WEIGHT, SLANT, WIDTH, and SIZE. */ |
2101 | |
2102 /* How many bits to shift to store the difference value of each font | |
94926 | 2103 property in a score. Note that flots for FONT_TYPE_INDEX and |
2104 FONT_REGISTRY_INDEX are not used. */ | |
90400 | 2105 static int sort_shift_bits[FONT_SIZE_INDEX + 1]; |
2106 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2107 /* 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
|
2108 The return value indicates how different ENTITY is compared with |
94926 | 2109 SPEC_PROP. |
2110 | |
2111 ALTERNATE_FAMILIES, if non-nil, is a pre-calculated list of | |
2112 alternate family names for AREF (SPEC_PROP, FONT_FAMILY_INDEX). */ | |
90400 | 2113 |
2114 static unsigned | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2115 font_score (entity, spec_prop) |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2116 Lisp_Object entity, *spec_prop; |
90400 | 2117 { |
2118 unsigned score = 0; | |
2119 int i; | |
94926 | 2120 |
2121 /* Score three style numeric fields. Maximum difference is 127. */ | |
2122 for (i = FONT_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; i++) | |
2123 if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i])) | |
2124 { | |
2125 int diff = (XINT (AREF (entity, i)) >> 8) - (XINT (spec_prop[i]) >> 8); | |
2126 | |
2127 if (diff < 0) | |
2128 diff = - diff; | |
95875
d56319d0f726
(font_score): Ignore the diffference of alias style symbols.
Kenichi Handa <handa@m17n.org>
parents:
95869
diff
changeset
|
2129 if (diff > 0) |
d56319d0f726
(font_score): Ignore the diffference of alias style symbols.
Kenichi Handa <handa@m17n.org>
parents:
95869
diff
changeset
|
2130 score |= min (diff, 127) << sort_shift_bits[i]; |
94926 | 2131 } |
2132 | |
2133 /* Score the size. Maximum difference is 127. */ | |
2134 i = FONT_SIZE_INDEX; | |
2135 if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i]) | |
2136 && XINT (AREF (entity, i)) > 0) | |
90400 | 2137 { |
94926 | 2138 /* We use the higher 6-bit for the actual size difference. The |
2139 lowest bit is set if the DPI is different. */ | |
2140 int diff = XINT (spec_prop[i]) - XINT (AREF (entity, i)); | |
2141 | |
2142 if (diff < 0) | |
2143 diff = - diff; | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2144 diff <<= 1; |
94926 | 2145 if (! NILP (spec_prop[FONT_DPI_INDEX]) |
2146 && ! EQ (spec_prop[FONT_DPI_INDEX], AREF (entity, FONT_DPI_INDEX))) | |
2147 diff |= 1; | |
2148 score |= min (diff, 127) << sort_shift_bits[FONT_SIZE_INDEX]; | |
90400 | 2149 } |
2150 | |
2151 return score; | |
2152 } | |
2153 | |
2154 | |
2155 /* The comparison function for qsort. */ | |
2156 | |
2157 static int | |
2158 font_compare (d1, d2) | |
2159 const void *d1, *d2; | |
2160 { | |
94926 | 2161 return (*(unsigned *) d1 - *(unsigned *) d2); |
90400 | 2162 } |
2163 | |
2164 | |
2165 /* The structure for elements being sorted by qsort. */ | |
2166 struct font_sort_data | |
2167 { | |
2168 unsigned score; | |
2169 Lisp_Object entity; | |
2170 }; | |
2171 | |
2172 | |
2173 /* Sort font-entities in vector VEC by closeness to font-spec PREFER. | |
2174 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
|
2175 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
|
2176 of FRAME before sorting. If SPEC is not nil, it is a font-spec to |
94926 | 2177 get the font-entities in VEC. |
2178 | |
2179 If BEST-ONLY is nonzero, return the best matching entity. Otherwise, | |
2180 return the sorted VEC. */ | |
90400 | 2181 |
2182 static Lisp_Object | |
94926 | 2183 font_sort_entites (vec, prefer, frame, spec, best_only) |
90400 | 2184 Lisp_Object vec, prefer, frame, spec; |
94926 | 2185 int best_only; |
90400 | 2186 { |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2187 Lisp_Object prefer_prop[FONT_SPEC_MAX]; |
90400 | 2188 int len, i; |
2189 struct font_sort_data *data; | |
94926 | 2190 unsigned best_score; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2191 Lisp_Object best_entity, driver_type; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2192 int driver_order; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2193 struct frame *f = XFRAME (frame); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2194 struct font_driver_list *list; |
90400 | 2195 USE_SAFE_ALLOCA; |
2196 | |
2197 len = ASIZE (vec); | |
2198 if (len <= 1) | |
94926 | 2199 return best_only ? AREF (vec, 0) : vec; |
2200 | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2201 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
|
2202 prefer_prop[i] = AREF (prefer, i); |
90400 | 2203 |
2204 if (! NILP (spec)) | |
2205 { | |
94926 | 2206 /* A font driver may return a font that has a property value |
2207 different from the value specified in SPEC if the driver | |
2208 thinks they are the same. That happens, for instance, such a | |
2209 generic family name as "serif" is specified. So, to ignore | |
2210 such a difference, for all properties specified in SPEC, set | |
2211 the corresponding properties in PREFER_PROP to nil. */ | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2212 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
|
2213 if (! NILP (AREF (spec, i))) |
94926 | 2214 prefer_prop[i] = Qnil; |
90400 | 2215 } |
2216 | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2217 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
|
2218 prefer_prop[FONT_SIZE_INDEX] |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
2219 = 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
|
2220 |
90400 | 2221 /* Scoring and sorting. */ |
2222 SAFE_ALLOCA (data, struct font_sort_data *, (sizeof *data) * len); | |
94926 | 2223 best_score = 0xFFFFFFFF; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2224 /* We are sure that the length of VEC > 1. */ |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2225 driver_type = AREF (AREF (vec, 0), FONT_TYPE_INDEX); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2226 for (driver_order = 0, list = f->font_driver_list; list; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2227 driver_order++, list = list->next) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2228 if (EQ (driver_type, list->driver->type)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2229 break; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2230 best_entity = data[0].entity = AREF (vec, 0); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2231 best_score = data[0].score |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2232 = font_score (data[0].entity, prefer_prop) | driver_order; |
90400 | 2233 for (i = 0; i < len; i++) |
2234 { | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2235 if (!EQ (driver_type, AREF (AREF (vec, i), FONT_TYPE_INDEX))) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2236 for (driver_order = 0, list = f->font_driver_list; list; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2237 driver_order++, list = list->next) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2238 if (EQ (driver_type, list->driver->type)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2239 break; |
90400 | 2240 data[i].entity = AREF (vec, i); |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2241 data[i].score = font_score (data[i].entity, prefer_prop) | driver_order; |
94926 | 2242 if (best_only && best_score > data[i].score) |
2243 { | |
2244 best_score = data[i].score; | |
2245 best_entity = data[i].entity; | |
2246 if (best_score == 0) | |
2247 break; | |
2248 } | |
90400 | 2249 } |
94926 | 2250 if (NILP (best_entity)) |
2251 { | |
2252 qsort (data, len, sizeof *data, font_compare); | |
2253 for (i = 0; i < len; i++) | |
2254 ASET (vec, i, data[i].entity); | |
2255 } | |
2256 else | |
2257 vec = best_entity; | |
90400 | 2258 SAFE_FREE (); |
2259 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2260 font_add_log ("sort-by", prefer, vec); |
90400 | 2261 return vec; |
2262 } | |
2263 | |
2264 | |
2265 /* API of Font Service Layer. */ | |
2266 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2267 /* Reflect ORDER (see the variable font_sort_order in xfaces.c) to |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2268 sort_shift_bits. Finternal_set_font_selection_order calls this |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2269 function with font_sort_order after setting up it. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2270 |
90400 | 2271 void |
2272 font_update_sort_order (order) | |
2273 int *order; | |
2274 { | |
94926 | 2275 int i, shift_bits; |
2276 | |
95869
14ab94c436d7
(font_update_sort_order): Setting of sort_shift_bits adjusted for the
Kenichi Handa <handa@m17n.org>
parents:
95867
diff
changeset
|
2277 for (i = 0, shift_bits = 23; i < 4; i++, shift_bits -= 7) |
90400 | 2278 { |
2279 int xlfd_idx = order[i]; | |
2280 | |
2281 if (xlfd_idx == XLFD_WEIGHT_INDEX) | |
2282 sort_shift_bits[FONT_WEIGHT_INDEX] = shift_bits; | |
2283 else if (xlfd_idx == XLFD_SLANT_INDEX) | |
2284 sort_shift_bits[FONT_SLANT_INDEX] = shift_bits; | |
2285 else if (xlfd_idx == XLFD_SWIDTH_INDEX) | |
2286 sort_shift_bits[FONT_WIDTH_INDEX] = shift_bits; | |
2287 else | |
2288 sort_shift_bits[FONT_SIZE_INDEX] = shift_bits; | |
2289 } | |
2290 } | |
2291 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2292 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2293 /* Check if ENTITY matches with the font specification SPEC. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2294 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2295 int |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2296 font_match_p (spec, entity) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2297 Lisp_Object spec, entity; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2298 { |
94926 | 2299 Lisp_Object prefer_prop[FONT_SPEC_MAX]; |
2300 Lisp_Object alternate_families = Qnil; | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2301 int i; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2302 |
94926 | 2303 for (i = FONT_FOUNDRY_INDEX; i <= FONT_SIZE_INDEX; i++) |
2304 prefer_prop[i] = AREF (spec, i); | |
2305 if (FLOATP (prefer_prop[FONT_SIZE_INDEX])) | |
2306 prefer_prop[FONT_SIZE_INDEX] | |
2307 = make_number (font_pixel_size (XFRAME (selected_frame), spec)); | |
2308 if (! NILP (prefer_prop[FONT_FAMILY_INDEX])) | |
2309 { | |
2310 alternate_families | |
2311 = Fassoc_string (prefer_prop[FONT_FAMILY_INDEX], | |
2312 Vface_alternative_font_family_alist, Qt); | |
2313 if (CONSP (alternate_families)) | |
2314 alternate_families = XCDR (alternate_families); | |
2315 } | |
2316 | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2317 return (font_score (entity, prefer_prop) == 0); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2318 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2319 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2320 |
94926 | 2321 /* CHeck a lispy font object corresponding to FONT. */ |
2322 | |
2323 int | |
2324 font_check_object (font) | |
90400 | 2325 struct font *font; |
2326 { | |
2327 Lisp_Object tail, elt; | |
2328 | |
94926 | 2329 for (tail = font->props[FONT_OBJLIST_INDEX]; CONSP (tail); |
90400 | 2330 tail = XCDR (tail)) |
2331 { | |
2332 elt = XCAR (tail); | |
94926 | 2333 if (font == XFONT_OBJECT (elt)) |
2334 return 1; | |
90400 | 2335 } |
94926 | 2336 return 0; |
90400 | 2337 } |
2338 | |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2339 |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
2340 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2341 /* Font cache |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2342 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2343 Each font backend has the callback function get_cache, and it |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2344 returns a cons cell of which cdr part can be freely used for |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2345 caching fonts. The cons cell may be shared by multiple frames |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2346 and/or multiple font drivers. So, we arrange the cdr part as this: |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2347 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2348 ((DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) ...) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2349 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2350 where DRIVER-TYPE is a symbol such as `x', `xft', etc., NUM-FRAMES |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2351 is a number frames sharing this cache, and FONT-CACHE-DATA is a |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2352 cons (FONT-SPEC FONT-ENTITY ...). */ |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2353 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2354 static void font_prepare_cache P_ ((FRAME_PTR, struct font_driver *)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2355 static void font_finish_cache P_ ((FRAME_PTR, struct font_driver *)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2356 static Lisp_Object font_get_cache P_ ((FRAME_PTR, struct font_driver *)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2357 static void font_clear_cache P_ ((FRAME_PTR, Lisp_Object, |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2358 struct font_driver *)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2359 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2360 static void |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2361 font_prepare_cache (f, driver) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2362 FRAME_PTR f; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2363 struct font_driver *driver; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2364 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2365 Lisp_Object cache, val; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2366 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2367 cache = driver->get_cache (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2368 val = XCDR (cache); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2369 while (CONSP (val) && ! EQ (XCAR (XCAR (val)), driver->type)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2370 val = XCDR (val); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2371 if (NILP (val)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2372 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2373 val = Fcons (driver->type, Fcons (make_number (1), Qnil)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2374 XSETCDR (cache, Fcons (val, XCDR (cache))); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2375 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2376 else |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2377 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2378 val = XCDR (XCAR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2379 XSETCAR (val, make_number (XINT (XCAR (val)) + 1)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2380 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2381 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2382 |
91909 | 2383 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2384 static void |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2385 font_finish_cache (f, driver) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2386 FRAME_PTR f; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2387 struct font_driver *driver; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2388 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2389 Lisp_Object cache, val, tmp; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2390 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2391 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2392 cache = driver->get_cache (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2393 val = XCDR (cache); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2394 while (CONSP (val) && ! EQ (XCAR (XCAR (val)), driver->type)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2395 cache = val, val = XCDR (val); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2396 font_assert (! NILP (val)); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2397 tmp = XCDR (XCAR (val)); |
91909 | 2398 XSETCAR (tmp, make_number (XINT (XCAR (tmp)) - 1)); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2399 if (XINT (XCAR (tmp)) == 0) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2400 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2401 font_clear_cache (f, XCAR (val), driver); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2402 XSETCDR (cache, XCDR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2403 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2404 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2405 |
91909 | 2406 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2407 static Lisp_Object |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2408 font_get_cache (f, driver) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2409 FRAME_PTR f; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2410 struct font_driver *driver; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2411 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2412 Lisp_Object val = driver->get_cache (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2413 Lisp_Object type = driver->type; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2414 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2415 font_assert (CONSP (val)); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2416 for (val = XCDR (val); ! EQ (XCAR (XCAR (val)), type); val = XCDR (val)); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2417 font_assert (CONSP (val)); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2418 /* VAL = ((DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) ...) */ |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2419 val = XCDR (XCAR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2420 return val; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2421 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2422 |
91909 | 2423 static int num_fonts; |
2424 | |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2425 static void |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2426 font_clear_cache (f, cache, driver) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2427 FRAME_PTR f; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2428 Lisp_Object cache; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2429 struct font_driver *driver; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2430 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2431 Lisp_Object tail, elt; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
2432 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2433 /* CACHE = (DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...) */ |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2434 for (tail = XCDR (XCDR (cache)); CONSP (tail); tail = XCDR (tail)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2435 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2436 elt = XCAR (tail); |
94968
e87ef440216b
(font_clear_cache): Check if the cached vector of entities is nil
Kenichi Handa <handa@m17n.org>
parents:
94964
diff
changeset
|
2437 if (CONSP (elt) && FONT_SPEC_P (XCAR (elt)) && VECTORP (XCDR (elt))) |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2438 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2439 Lisp_Object vec = XCDR (elt); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2440 int i; |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2441 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2442 for (i = 0; i < ASIZE (vec); i++) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2443 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2444 Lisp_Object entity = AREF (vec, i); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2445 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2446 if (EQ (driver->type, AREF (entity, FONT_TYPE_INDEX))) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2447 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2448 Lisp_Object objlist = AREF (entity, FONT_OBJLIST_INDEX); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2449 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2450 for (; CONSP (objlist); objlist = XCDR (objlist)) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2451 { |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2452 Lisp_Object val = XCAR (objlist); |
94926 | 2453 struct font *font = XFONT_OBJECT (val); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2454 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2455 font_assert (font && driver == font->driver); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2456 driver->close (f, font); |
91909 | 2457 num_fonts--; |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2458 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2459 if (driver->free_entity) |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2460 driver->free_entity (entity); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2461 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2462 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2463 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2464 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2465 XSETCDR (cache, Qnil); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2466 } |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2467 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2468 |
90400 | 2469 static Lisp_Object scratch_font_spec, scratch_font_prefer; |
2470 | |
94926 | 2471 Lisp_Object |
2472 font_delete_unmatched (list, spec, size) | |
2473 Lisp_Object list, spec; | |
2474 int size; | |
2475 { | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2476 Lisp_Object entity, val; |
94926 | 2477 enum font_property_index prop; |
2478 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2479 for (val = Qnil; CONSP (list); list = XCDR (list)) |
94926 | 2480 { |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2481 entity = XCAR (list); |
94926 | 2482 for (prop = FONT_WEIGHT_INDEX; prop < FONT_SIZE_INDEX; prop++) |
2483 if (INTEGERP (AREF (spec, prop)) | |
2484 && ((XINT (AREF (spec, prop)) >> 8) | |
2485 != (XINT (AREF (entity, prop)) >> 8))) | |
2486 prop = FONT_SPEC_MAX; | |
2487 if (prop++ <= FONT_SIZE_INDEX | |
2488 && size | |
2489 && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0) | |
2490 { | |
2491 int diff = XINT (AREF (entity, FONT_SIZE_INDEX)) - size; | |
2492 | |
2493 if (diff != 0 | |
2494 && (diff < 0 ? -diff > FONT_PIXEL_SIZE_QUANTUM | |
2495 : diff > FONT_PIXEL_SIZE_QUANTUM)) | |
2496 prop = FONT_SPEC_MAX; | |
2497 } | |
2498 if (prop < FONT_SPEC_MAX) | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2499 val = Fcons (entity, val); |
94926 | 2500 } |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2501 return val; |
94926 | 2502 } |
2503 | |
2504 | |
2505 /* Return a vector of font-entities matching with SPEC on FRAME. */ | |
2506 | |
2507 Lisp_Object | |
90400 | 2508 font_list_entities (frame, spec) |
2509 Lisp_Object frame, spec; | |
2510 { | |
2511 FRAME_PTR f = XFRAME (frame); | |
2512 struct font_driver_list *driver_list = f->font_driver_list; | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2513 Lisp_Object ftype, val; |
94926 | 2514 Lisp_Object *vec; |
2515 int size; | |
2516 int need_filtering = 0; | |
90400 | 2517 int i; |
2518 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2519 font_assert (FONT_SPEC_P (spec)); |
90400 | 2520 |
94926 | 2521 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX))) |
2522 size = XINT (AREF (spec, FONT_SIZE_INDEX)); | |
2523 else if (FLOATP (AREF (spec, FONT_SIZE_INDEX))) | |
2524 size = font_pixel_size (f, spec); | |
2525 else | |
2526 size = 0; | |
2527 | |
90400 | 2528 ftype = AREF (spec, FONT_TYPE_INDEX); |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2529 for (i = FONT_FOUNDRY_INDEX; i <= FONT_REGISTRY_INDEX; i++) |
94926 | 2530 ASET (scratch_font_spec, i, AREF (spec, i)); |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2531 for (i = FONT_WEIGHT_INDEX; i < FONT_EXTRA_INDEX; i++) |
94926 | 2532 { |
2533 ASET (scratch_font_spec, i, Qnil); | |
2534 if (! NILP (AREF (spec, i))) | |
2535 need_filtering = 1; | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2536 if (i == FONT_DPI_INDEX) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2537 /* Skip FONT_SPACING_INDEX */ |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2538 i++; |
94926 | 2539 } |
95359
f6580a4c58da
(font_parse_family_registry): Use Ffont_put to validate
Kenichi Handa <handa@m17n.org>
parents:
95290
diff
changeset
|
2540 ASET (scratch_font_spec, FONT_SPACING_INDEX, AREF (spec, FONT_SPACING_INDEX)); |
94926 | 2541 ASET (scratch_font_spec, FONT_EXTRA_INDEX, AREF (spec, FONT_EXTRA_INDEX)); |
2542 | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2543 vec = alloca (sizeof (Lisp_Object) * num_font_drivers); |
94926 | 2544 if (! vec) |
2545 return null_vector; | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
2546 |
90400 | 2547 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
|
2548 if (driver_list->on |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
2549 && (NILP (ftype) || EQ (driver_list->driver->type, ftype))) |
90400 | 2550 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2551 Lisp_Object cache = font_get_cache (f, driver_list->driver); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2552 |
95437
6e6db01383e4
(font_list_entities): Fix the car part of data to be
Kenichi Handa <handa@m17n.org>
parents:
95421
diff
changeset
|
2553 ASET (scratch_font_spec, FONT_TYPE_INDEX, driver_list->driver->type); |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2554 val = assoc_no_quit (scratch_font_spec, XCDR (cache)); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2555 if (CONSP (val)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2556 val = XCDR (val); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2557 else |
90400 | 2558 { |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2559 Lisp_Object copy; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2560 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2561 val = driver_list->driver->list (frame, scratch_font_spec); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2562 copy = Fcopy_font_spec (scratch_font_spec); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2563 ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2564 XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache))); |
90400 | 2565 } |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2566 if (! NILP (val) && need_filtering) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2567 val = font_delete_unmatched (val, spec, size); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2568 if (! NILP (val)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2569 vec[i++] = val; |
90400 | 2570 } |
94926 | 2571 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2572 val = (i > 0 ? Fvconcat (i, vec) : null_vector); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2573 font_add_log ("list", spec, val); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2574 return (val); |
90400 | 2575 } |
2576 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2577 |
94926 | 2578 /* Return a font entity matching with SPEC on FRAME. ATTRS, if non |
2579 nil, is an array of face's attributes, which specifies preferred | |
2580 font-related attributes. */ | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2581 |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2582 static Lisp_Object |
94926 | 2583 font_matching_entity (f, attrs, spec) |
2584 FRAME_PTR f; | |
2585 Lisp_Object *attrs, spec; | |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2586 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2587 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
|
2588 Lisp_Object ftype, size, entity; |
94926 | 2589 Lisp_Object frame; |
2590 | |
2591 XSETFRAME (frame, f); | |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2592 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
|
2593 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
|
2594 if (FLOATP (size)) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2595 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
|
2596 entity = Qnil; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2597 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
|
2598 if (driver_list->on |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2599 && (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
|
2600 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
2601 Lisp_Object cache = font_get_cache (f, driver_list->driver); |
95104
ae4280e6a166
(font_list_entities): Fix handling of cache.
Kenichi Handa <handa@m17n.org>
parents:
95013
diff
changeset
|
2602 Lisp_Object copy; |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2603 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2604 ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type); |
94926 | 2605 entity = assoc_no_quit (spec, XCDR (cache)); |
95104
ae4280e6a166
(font_list_entities): Fix handling of cache.
Kenichi Handa <handa@m17n.org>
parents:
95013
diff
changeset
|
2606 if (CONSP (entity)) |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2607 entity = XCDR (entity); |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2608 else |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2609 { |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2610 entity = driver_list->driver->match (frame, spec); |
95104
ae4280e6a166
(font_list_entities): Fix handling of cache.
Kenichi Handa <handa@m17n.org>
parents:
95013
diff
changeset
|
2611 copy = Fcopy_font_spec (spec); |
ae4280e6a166
(font_list_entities): Fix handling of cache.
Kenichi Handa <handa@m17n.org>
parents:
95013
diff
changeset
|
2612 ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); |
ae4280e6a166
(font_list_entities): Fix handling of cache.
Kenichi Handa <handa@m17n.org>
parents:
95013
diff
changeset
|
2613 XSETCDR (cache, Fcons (Fcons (copy, entity), XCDR (cache))); |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2614 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2615 if (! NILP (entity)) |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2616 break; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2617 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2618 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
|
2619 ASET (spec, FONT_SIZE_INDEX, size); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2620 font_add_log ("match", spec, entity); |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2621 return entity; |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2622 } |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
2623 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2624 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2625 /* Open a font of ENTITY and PIXEL_SIZE on frame F, and return the |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2626 opened font object. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2627 |
90400 | 2628 static Lisp_Object |
2629 font_open_entity (f, entity, pixel_size) | |
2630 FRAME_PTR f; | |
2631 Lisp_Object entity; | |
2632 int pixel_size; | |
2633 { | |
2634 struct font_driver_list *driver_list; | |
91909 | 2635 Lisp_Object objlist, size, val, font_object; |
90400 | 2636 struct font *font; |
94926 | 2637 int min_width; |
2638 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2639 font_assert (FONT_ENTITY_P (entity)); |
90400 | 2640 size = AREF (entity, FONT_SIZE_INDEX); |
2641 if (XINT (size) != 0) | |
2642 pixel_size = XINT (size); | |
2643 | |
2644 for (objlist = AREF (entity, FONT_OBJLIST_INDEX); CONSP (objlist); | |
2645 objlist = XCDR (objlist)) | |
94926 | 2646 if (XFONT_OBJECT (XCAR (objlist))->pixel_size == pixel_size) |
2647 return XCAR (objlist); | |
2648 | |
2649 val = AREF (entity, FONT_TYPE_INDEX); | |
2650 for (driver_list = f->font_driver_list; | |
2651 driver_list && ! EQ (driver_list->driver->type, val); | |
2652 driver_list = driver_list->next); | |
2653 if (! driver_list) | |
2654 return Qnil; | |
2655 | |
2656 font_object = driver_list->driver->open (f, entity, pixel_size); | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2657 font_add_log ("open", entity, font_object); |
91909 | 2658 if (NILP (font_object)) |
94926 | 2659 return Qnil; |
2660 ASET (entity, FONT_OBJLIST_INDEX, | |
2661 Fcons (font_object, AREF (entity, FONT_OBJLIST_INDEX))); | |
2662 ASET (font_object, FONT_OBJLIST_INDEX, AREF (entity, FONT_OBJLIST_INDEX)); | |
2663 num_fonts++; | |
2664 | |
2665 font = XFONT_OBJECT (font_object); | |
2666 min_width = (font->min_width ? font->min_width | |
2667 : font->average_width ? font->average_width | |
2668 : font->space_width ? font->space_width | |
2669 : 1); | |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
2670 #ifdef HAVE_WINDOW_SYSTEM |
94926 | 2671 FRAME_X_DISPLAY_INFO (f)->n_fonts++; |
2672 if (FRAME_X_DISPLAY_INFO (f)->n_fonts == 1) | |
91909 | 2673 { |
94926 | 2674 FRAME_SMALLEST_CHAR_WIDTH (f) = min_width; |
2675 FRAME_SMALLEST_FONT_HEIGHT (f) = font->height; | |
2676 fonts_changed_p = 1; | |
91909 | 2677 } |
94926 | 2678 else |
2679 { | |
2680 if (FRAME_SMALLEST_CHAR_WIDTH (f) > min_width) | |
2681 FRAME_SMALLEST_CHAR_WIDTH (f) = min_width, fonts_changed_p = 1; | |
2682 if (FRAME_SMALLEST_FONT_HEIGHT (f) > font->height) | |
2683 FRAME_SMALLEST_FONT_HEIGHT (f) = font->height, fonts_changed_p = 1; | |
2684 } | |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
2685 #endif |
91909 | 2686 |
2687 return font_object; | |
90400 | 2688 } |
2689 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2690 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2691 /* Close FONT_OBJECT that is opened on frame F. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2692 |
90400 | 2693 void |
2694 font_close_object (f, font_object) | |
2695 FRAME_PTR f; | |
2696 Lisp_Object font_object; | |
2697 { | |
94926 | 2698 struct font *font = XFONT_OBJECT (font_object); |
90541 | 2699 Lisp_Object objlist; |
90400 | 2700 Lisp_Object tail, prev = Qnil; |
2701 | |
94926 | 2702 objlist = AREF (font_object, FONT_OBJLIST_INDEX); |
90400 | 2703 for (prev = Qnil, tail = objlist; CONSP (tail); |
2704 prev = tail, tail = XCDR (tail)) | |
2705 if (EQ (font_object, XCAR (tail))) | |
2706 { | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2707 font_add_log ("close", font_object, Qnil); |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
2708 font->driver->close (f, font); |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
2709 #ifdef HAVE_WINDOW_SYSTEM |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2710 font_assert (FRAME_X_DISPLAY_INFO (f)->n_fonts); |
94926 | 2711 FRAME_X_DISPLAY_INFO (f)->n_fonts--; |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
2712 #endif |
90541 | 2713 if (NILP (prev)) |
94926 | 2714 ASET (font_object, FONT_OBJLIST_INDEX, XCDR (objlist)); |
90541 | 2715 else |
2716 XSETCDR (prev, XCDR (objlist)); | |
91909 | 2717 num_fonts--; |
90541 | 2718 return; |
90400 | 2719 } |
90541 | 2720 abort (); |
90400 | 2721 } |
2722 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2723 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2724 /* Return 1 if FONT on F has a glyph for character C, 0 if not, -1 if |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2725 FONT is a font-entity and it must be opened to check. */ |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2726 |
90400 | 2727 int |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2728 font_has_char (f, font, c) |
90400 | 2729 FRAME_PTR f; |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2730 Lisp_Object font; |
90400 | 2731 int c; |
2732 { | |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2733 struct font *fontp; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2734 |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2735 if (FONT_ENTITY_P (font)) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2736 { |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2737 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
|
2738 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
|
2739 |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2740 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
|
2741 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
|
2742 driver_list = driver_list->next); |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2743 if (! driver_list) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2744 return 0; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2745 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
|
2746 return -1; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2747 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
|
2748 } |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2749 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2750 font_assert (FONT_OBJECT_P (font)); |
94926 | 2751 fontp = XFONT_OBJECT (font); |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2752 if (fontp->driver->has_char) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2753 { |
94926 | 2754 int result = fontp->driver->has_char (font, c); |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2755 |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2756 if (result >= 0) |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2757 return result; |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2758 } |
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
2759 return (fontp->driver->encode_char (fontp, c) != FONT_INVALID_CODE); |
90400 | 2760 } |
2761 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2762 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2763 /* Return the glyph ID of FONT_OBJECT for character C. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2764 |
90400 | 2765 unsigned |
2766 font_encode_char (font_object, c) | |
2767 Lisp_Object font_object; | |
2768 int c; | |
2769 { | |
94926 | 2770 struct font *font; |
2771 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2772 font_assert (FONT_OBJECT_P (font_object)); |
94926 | 2773 font = XFONT_OBJECT (font_object); |
90400 | 2774 return font->driver->encode_char (font, c); |
2775 } | |
2776 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2777 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2778 /* Return the name of FONT_OBJECT. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2779 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2780 Lisp_Object |
90400 | 2781 font_get_name (font_object) |
2782 Lisp_Object font_object; | |
2783 { | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2784 font_assert (FONT_OBJECT_P (font_object)); |
94926 | 2785 return AREF (font_object, FONT_NAME_INDEX); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2786 } |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2787 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2788 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2789 /* Return the specification of FONT_OBJECT. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2790 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2791 Lisp_Object |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2792 font_get_spec (font_object) |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2793 Lisp_Object font_object; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2794 { |
94926 | 2795 Lisp_Object spec = font_make_spec (); |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2796 int i; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2797 |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2798 for (i = 0; i < FONT_SIZE_INDEX; i++) |
94926 | 2799 ASET (spec, i, AREF (font_object, i)); |
2800 ASET (spec, FONT_SIZE_INDEX, | |
2801 make_number (XFONT_OBJECT (font_object)->pixel_size)); | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
2802 return spec; |
90400 | 2803 } |
2804 | |
2805 Lisp_Object | |
94926 | 2806 font_spec_from_name (font_name) |
2807 Lisp_Object font_name; | |
2808 { | |
2809 Lisp_Object args[2]; | |
2810 | |
2811 args[0] = QCname; | |
2812 args[1] = font_name; | |
2813 return Ffont_spec (2, args); | |
2814 } | |
2815 | |
2816 | |
2817 void | |
2818 font_clear_prop (attrs, prop) | |
2819 Lisp_Object *attrs; | |
2820 enum font_property_index prop; | |
2821 { | |
2822 Lisp_Object font = attrs[LFACE_FONT_INDEX]; | |
2823 | |
2824 if (! FONTP (font)) | |
2825 return; | |
2826 if (NILP (AREF (font, prop)) | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2827 && prop != FONT_FAMILY_INDEX && prop != FONT_FOUNDRY_INDEX |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2828 && prop != FONT_SIZE_INDEX) |
94926 | 2829 return; |
2830 font = Fcopy_font_spec (font); | |
2831 ASET (font, prop, Qnil); | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2832 if (prop == FONT_FAMILY_INDEX || prop == FONT_FOUNDRY_INDEX) |
94926 | 2833 { |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2834 if (prop == FONT_FAMILY_INDEX) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2835 ASET (font, FONT_FOUNDRY_INDEX, Qnil); |
94926 | 2836 ASET (font, FONT_ADSTYLE_INDEX, Qnil); |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2837 ASET (font, FONT_REGISTRY_INDEX, Qnil); |
94926 | 2838 ASET (font, FONT_SIZE_INDEX, Qnil); |
2839 ASET (font, FONT_DPI_INDEX, Qnil); | |
2840 ASET (font, FONT_SPACING_INDEX, Qnil); | |
2841 ASET (font, FONT_AVGWIDTH_INDEX, Qnil); | |
2842 } | |
2843 else if (prop == FONT_SIZE_INDEX) | |
2844 { | |
2845 ASET (font, FONT_DPI_INDEX, Qnil); | |
2846 ASET (font, FONT_SPACING_INDEX, Qnil); | |
2847 ASET (font, FONT_AVGWIDTH_INDEX, Qnil); | |
2848 } | |
2849 attrs[LFACE_FONT_INDEX] = font; | |
2850 } | |
2851 | |
2852 void | |
2853 font_update_lface (f, attrs) | |
2854 FRAME_PTR f; | |
2855 Lisp_Object *attrs; | |
90400 | 2856 { |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
2857 Lisp_Object spec; |
94926 | 2858 |
2859 spec = attrs[LFACE_FONT_INDEX]; | |
2860 if (! FONT_SPEC_P (spec)) | |
2861 return; | |
2862 | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2863 if (! NILP (AREF (spec, FONT_FOUNDRY_INDEX))) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2864 attrs[LFACE_FOUNDRY_INDEX] = SYMBOL_NAME (AREF (spec, FONT_FOUNDRY_INDEX)); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2865 if (! NILP (AREF (spec, FONT_FAMILY_INDEX))) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2866 attrs[LFACE_FAMILY_INDEX] = SYMBOL_NAME (AREF (spec, FONT_FAMILY_INDEX)); |
94926 | 2867 if (! NILP (AREF (spec, FONT_WEIGHT_INDEX))) |
2868 attrs[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (spec); | |
2869 if (! NILP (AREF (spec, FONT_SLANT_INDEX))) | |
2870 attrs[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (spec);; | |
2871 if (! NILP (AREF (spec, FONT_WIDTH_INDEX))) | |
2872 attrs[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (spec); | |
2873 if (! NILP (AREF (spec, FONT_SIZE_INDEX))) | |
2874 { | |
2875 int point; | |
2876 | |
2877 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX))) | |
2878 { | |
2879 Lisp_Object val; | |
2880 int dpi = f->resy; | |
2881 | |
2882 val = Ffont_get (spec, QCdpi); | |
2883 if (! NILP (val)) | |
2884 dpi = XINT (val); | |
2885 point = PIXEL_TO_POINT (XINT (AREF (spec, FONT_SIZE_INDEX)) * 10, | |
2886 dpi); | |
2887 } | |
2888 else if (FLOATP (AREF (spec, FONT_SIZE_INDEX))) | |
2889 point = XFLOAT_DATA (AREF (spec, FONT_SIZE_INDEX)) * 10; | |
2890 attrs[LFACE_HEIGHT_INDEX] = make_number (point); | |
2891 } | |
90400 | 2892 } |
2893 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
2894 |
94926 | 2895 /* Return a font-entity satisfying SPEC and best matching with face's |
2896 font related attributes in ATTRS. C, if not negative, is a | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2897 character that the entity must support. */ |
90400 | 2898 |
2899 Lisp_Object | |
94926 | 2900 font_find_for_lface (f, attrs, spec, c) |
90400 | 2901 FRAME_PTR f; |
94926 | 2902 Lisp_Object *attrs; |
90400 | 2903 Lisp_Object spec; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
2904 int c; |
90400 | 2905 { |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2906 Lisp_Object work; |
94926 | 2907 Lisp_Object frame, entities, val, props[FONT_REGISTRY_INDEX + 1] ; |
95888
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2908 Lisp_Object size, foundry[3], *family, registry[3]; |
95475
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
2909 int pixel_size; |
95888
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2910 int i, j, k, result; |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2911 |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2912 registry[0] = AREF (spec, FONT_REGISTRY_INDEX); |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2913 if (NILP (registry[0])) |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2914 { |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2915 registry[0] = Qiso8859_1; |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2916 registry[1] = Qascii_0; |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2917 registry[2] = null_vector; |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2918 } |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2919 else |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
2920 registry[1] = null_vector; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2921 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2922 if (c >= 0 && ! NILP (AREF (spec, FONT_REGISTRY_INDEX))) |
94926 | 2923 { |
2924 struct charset *encoding, *repertory; | |
2925 | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2926 if (font_registry_charsets (AREF (spec, FONT_REGISTRY_INDEX), |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2927 &encoding, &repertory) < 0) |
94926 | 2928 return Qnil; |
2929 if (repertory) | |
2930 { | |
2931 if (ENCODE_CHAR (repertory, c) == CHARSET_INVALID_CODE (repertory)) | |
2932 return Qnil; | |
2933 /* Any font of this registry support C. So, let's | |
2934 suppress the further checking. */ | |
2935 c = -1; | |
2936 } | |
2937 else if (c > encoding->max_char) | |
2938 return Qnil; | |
2939 } | |
2940 | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2941 work = Fcopy_font_spec (spec); |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
2942 XSETFRAME (frame, f); |
94926 | 2943 size = AREF (spec, FONT_SIZE_INDEX); |
95475
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
2944 pixel_size = font_pixel_size (f, spec); |
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
2945 if (pixel_size == 0) |
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
2946 { |
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
2947 double pt = XINT (attrs[LFACE_HEIGHT_INDEX]); |
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
2948 |
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
2949 pixel_size = POINT_TO_PIXEL (pt / 10, f->resy); |
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
2950 } |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2951 ASET (work, FONT_SIZE_INDEX, Qnil); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2952 foundry[0] = AREF (work, FONT_FOUNDRY_INDEX); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2953 if (! NILP (foundry[0])) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2954 foundry[1] = null_vector; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2955 else if (STRINGP (attrs[LFACE_FOUNDRY_INDEX])) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2956 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2957 foundry[0] = font_intern_prop (SDATA (attrs[LFACE_FOUNDRY_INDEX]), |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2958 SBYTES (attrs[LFACE_FOUNDRY_INDEX]), 1); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2959 foundry[1] = Qnil; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2960 foundry[2] = null_vector; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2961 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2962 else |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2963 foundry[0] = Qnil, foundry[1] = null_vector; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2964 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2965 val = AREF (work, FONT_FAMILY_INDEX); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2966 if (NILP (val) && STRINGP (attrs[LFACE_FAMILY_INDEX])) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2967 val = font_intern_prop (SDATA (attrs[LFACE_FAMILY_INDEX]), |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2968 SBYTES (attrs[LFACE_FAMILY_INDEX]), 1); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2969 if (NILP (val)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2970 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2971 family = alloca ((sizeof family[0]) * 2); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2972 family[0] = Qnil; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2973 family[1] = null_vector; /* terminator. */ |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2974 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2975 else |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2976 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2977 Lisp_Object alters |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2978 = Fassoc_string (val, Vface_alternative_font_family_alist, Qt); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2979 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2980 if (! NILP (alters)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2981 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2982 family = alloca ((sizeof family[0]) * (XINT (Flength (alters)) + 2)); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2983 for (i = 0; CONSP (alters); i++, alters = XCDR (alters)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2984 family[i] = XCAR (alters); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2985 if (NILP (AREF (spec, FONT_FAMILY_INDEX))) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2986 family[i++] = Qnil; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2987 family[i] = null_vector; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2988 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2989 else |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2990 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2991 family = alloca ((sizeof family[0]) * 3); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2992 i = 0; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2993 family[i++] = val; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2994 if (NILP (AREF (spec, FONT_FAMILY_INDEX))) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2995 family[i++] = Qnil; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2996 family[i] = null_vector; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2997 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2998 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
2999 |
95888
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3000 for (i = 0; SYMBOLP (family[i]); i++) |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3001 { |
95888
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3002 ASET (work, FONT_FAMILY_INDEX, family[i]); |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3003 for (j = 0; SYMBOLP (foundry[j]); j++) |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3004 { |
95888
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3005 ASET (work, FONT_FOUNDRY_INDEX, foundry[j]); |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3006 for (k = 0; SYMBOLP (registry[k]); k++) |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3007 { |
95890
e6e6c351339d
(font_find_for_lface): Fix typo of the previous change.
Kenichi Handa <handa@m17n.org>
parents:
95888
diff
changeset
|
3008 ASET (work, FONT_REGISTRY_INDEX, registry[k]); |
95888
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3009 entities = font_list_entities (frame, work); |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3010 if (ASIZE (entities) > 0) |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3011 goto found; |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3012 } |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3013 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3014 } |
95888
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3015 return Qnil; |
ff04c95494e4
(font_find_for_lface): If registry is NULL, try iso8859-1 and ascii-0.
Kenichi Handa <handa@m17n.org>
parents:
95886
diff
changeset
|
3016 found: |
94926 | 3017 if (ASIZE (entities) == 1) |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
3018 { |
94926 | 3019 if (c < 0) |
3020 return AREF (entities, 0); | |
90490
8ef2cbaf626a
(font_parse_xlfd): Fix generating of CHARSET_REGISTRY field.
Kenichi Handa <handa@m17n.org>
parents:
90483
diff
changeset
|
3021 } |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
3022 else |
90400 | 3023 { |
90507
4a6034a7c870
(font_find_for_lface): Code optimized.
Kenichi Handa <handa@m17n.org>
parents:
90503
diff
changeset
|
3024 /* 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
|
3025 Lisp_Object prefer = scratch_font_prefer; |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3026 |
94926 | 3027 for (i = 0; i < FONT_EXTRA_INDEX; i++) |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3028 ASET (prefer, i, AREF (work, i)); |
95013
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
3029 if (FONTP (attrs[LFACE_FONT_INDEX])) |
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
3030 { |
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
3031 Lisp_Object face_font = attrs[LFACE_FONT_INDEX]; |
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
3032 |
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
3033 for (i = 0; i < FONT_EXTRA_INDEX; i++) |
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
3034 if (NILP (AREF (prefer, i))) |
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
3035 ASET (prefer, i, AREF (face_font, i)); |
125a7ecf00db
(font_find_for_lface): Reflect LFACE_FONT in the font
Kenichi Handa <handa@m17n.org>
parents:
94968
diff
changeset
|
3036 } |
94926 | 3037 if (NILP (AREF (prefer, FONT_WEIGHT_INDEX))) |
3038 FONT_SET_STYLE (prefer, FONT_WEIGHT_INDEX, attrs[LFACE_WEIGHT_INDEX]); | |
3039 if (NILP (AREF (prefer, FONT_SLANT_INDEX))) | |
3040 FONT_SET_STYLE (prefer, FONT_SLANT_INDEX, attrs[LFACE_SLANT_INDEX]); | |
3041 if (NILP (AREF (prefer, FONT_WIDTH_INDEX))) | |
3042 FONT_SET_STYLE (prefer, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); | |
95475
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
3043 ASET (prefer, FONT_SIZE_INDEX, make_number (pixel_size)); |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3044 entities = font_sort_entites (entities, prefer, frame, work, c < 0); |
90400 | 3045 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3046 if (c < 0) |
94926 | 3047 return entities; |
3048 | |
3049 for (i = 0; i < ASIZE (entities); i++) | |
3050 { | |
3051 int j; | |
3052 | |
3053 val = AREF (entities, i); | |
3054 if (i > 0) | |
3055 { | |
3056 for (j = FONT_FOUNDRY_INDEX; j <= FONT_REGISTRY_INDEX; j++) | |
3057 if (! EQ (AREF (val, j), props[j])) | |
3058 break; | |
3059 if (j > FONT_REGISTRY_INDEX) | |
3060 continue; | |
3061 } | |
3062 for (j = FONT_FOUNDRY_INDEX; j <= FONT_REGISTRY_INDEX; j++) | |
3063 props[j] = AREF (val, j); | |
3064 result = font_has_char (f, val, c); | |
3065 if (result > 0) | |
3066 return val; | |
3067 if (result == 0) | |
3068 return Qnil; | |
3069 val = font_open_for_lface (f, val, attrs, spec); | |
3070 if (NILP (val)) | |
3071 continue; | |
3072 result = font_has_char (f, val, c); | |
3073 font_close_object (f, val); | |
3074 if (result > 0) | |
3075 return AREF (entities, i); | |
3076 } | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3077 return Qnil; |
90400 | 3078 } |
3079 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3080 |
90400 | 3081 Lisp_Object |
94926 | 3082 font_open_for_lface (f, entity, attrs, spec) |
90400 | 3083 FRAME_PTR f; |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3084 Lisp_Object entity; |
94926 | 3085 Lisp_Object *attrs; |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3086 Lisp_Object spec; |
90400 | 3087 { |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
3088 int size; |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
3089 |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3090 if (INTEGERP (AREF (entity, FONT_SIZE_INDEX)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3091 && XINT (AREF (entity, FONT_SIZE_INDEX)) > 0) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3092 size = XINT (AREF (entity, FONT_SIZE_INDEX)); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3093 else if (FONT_SPEC_P (spec) && ! NILP (AREF (spec, FONT_SIZE_INDEX))) |
95475
e1e8d6b9d465
(font_find_for_lface): Handle float font size.
Kenichi Handa <handa@m17n.org>
parents:
95437
diff
changeset
|
3094 size = font_pixel_size (f, spec); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3095 else |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3096 { |
94926 | 3097 double pt = XINT (attrs[LFACE_HEIGHT_INDEX]); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3098 |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3099 pt /= 10; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3100 size = POINT_TO_PIXEL (pt, f->resy); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3101 } |
90400 | 3102 return font_open_entity (f, entity, size); |
3103 } | |
3104 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3105 |
94926 | 3106 /* Find a font satisfying SPEC and best matching with face's |
3107 attributes in ATTRS on FRAME, and return the opened | |
3108 font-object. */ | |
3109 | |
3110 Lisp_Object | |
3111 font_load_for_lface (f, attrs, spec) | |
90400 | 3112 FRAME_PTR f; |
94926 | 3113 Lisp_Object *attrs, spec; |
90400 | 3114 { |
94926 | 3115 Lisp_Object entity; |
3116 | |
3117 entity = font_find_for_lface (f, attrs, spec, -1); | |
3118 if (NILP (entity)) | |
91350
9673276f310c
(font_load_for_face): Handle the case that the font in
Kenichi Handa <handa@m17n.org>
parents:
91337
diff
changeset
|
3119 { |
94926 | 3120 /* No font is listed for SPEC, but each font-backend may have |
3121 the different criteria about "font matching". So, try | |
3122 it. */ | |
3123 entity = font_matching_entity (f, attrs, spec); | |
3124 if (NILP (entity)) | |
3125 return Qnil; | |
91350
9673276f310c
(font_load_for_face): Handle the case that the font in
Kenichi Handa <handa@m17n.org>
parents:
91337
diff
changeset
|
3126 } |
94926 | 3127 return font_open_for_lface (f, entity, attrs, spec); |
90400 | 3128 } |
3129 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3130 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3131 /* Make FACE on frame F ready to use the font opened for FACE. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3132 |
90400 | 3133 void |
3134 font_prepare_for_face (f, face) | |
3135 FRAME_PTR f; | |
3136 struct face *face; | |
3137 { | |
94926 | 3138 if (face->font->driver->prepare_face) |
3139 face->font->driver->prepare_face (f, face); | |
90400 | 3140 } |
3141 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3142 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3143 /* Make FACE on frame F stop using the font opened for FACE. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3144 |
90400 | 3145 void |
3146 font_done_for_face (f, face) | |
3147 FRAME_PTR f; | |
3148 struct face *face; | |
3149 { | |
94926 | 3150 if (face->font->driver->done_face) |
3151 face->font->driver->done_face (f, face); | |
90400 | 3152 face->extra = NULL; |
3153 } | |
3154 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3155 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3156 /* Open a font best matching with NAME on frame F. If no proper font |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3157 is found, return Qnil. */ |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3158 |
90400 | 3159 Lisp_Object |
3160 font_open_by_name (f, name) | |
3161 FRAME_PTR f; | |
3162 char *name; | |
3163 { | |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
3164 Lisp_Object args[2]; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3165 Lisp_Object spec, attrs[LFACE_VECTOR_SIZE]; |
90476
017a6aec5d77
(font_parse_fcname): Fix parsing of point-size.
Kenichi Handa <handa@m17n.org>
parents:
90468
diff
changeset
|
3166 |
90468
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
3167 args[0] = QCname; |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
3168 args[1] = make_unibyte_string (name, strlen (name)); |
5424215feef6
(XLFD_SMALLNUM_MASK): Delete this macro.
Kenichi Handa <handa@m17n.org>
parents:
90451
diff
changeset
|
3169 spec = Ffont_spec (2, args); |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3170 /* We set up the default font-related attributes of a face to prefer |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3171 a moderate font. */ |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3172 attrs[LFACE_FAMILY_INDEX] = attrs[LFACE_FOUNDRY_INDEX] = Qnil; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3173 attrs[LFACE_SWIDTH_INDEX] = attrs[LFACE_WEIGHT_INDEX] |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3174 = attrs[LFACE_SLANT_INDEX] = Qnormal; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3175 attrs[LFACE_HEIGHT_INDEX] = make_number (120); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3176 attrs[LFACE_FONT_INDEX] = Qnil; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3177 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3178 return font_load_for_lface (f, attrs, spec); |
90400 | 3179 } |
3180 | |
3181 | |
3182 /* Register font-driver DRIVER. This function is used in two ways. | |
3183 | |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3184 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
|
3185 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
|
3186 (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
|
3187 an available font-driver. |
90400 | 3188 |
3189 The second is with frame F NULL. In this case, DRIVER is globally | |
3190 registered in the variable `font_driver_list'. All font-driver | |
3191 implementations must call this function in its syms_of_XXXX | |
3192 (e.g. syms_of_xfont). */ | |
3193 | |
3194 void | |
3195 register_font_driver (driver, f) | |
3196 struct font_driver *driver; | |
3197 FRAME_PTR f; | |
3198 { | |
3199 struct font_driver_list *root = f ? f->font_driver_list : font_driver_list; | |
3200 struct font_driver_list *prev, *list; | |
3201 | |
3202 if (f && ! driver->draw) | |
92113
2a9ed1c080b4
(font_match_xlfd, font_check_xlfd_parse): New funs.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91943
diff
changeset
|
3203 error ("Unusable font driver for a frame: %s", |
90400 | 3204 SDATA (SYMBOL_NAME (driver->type))); |
3205 | |
3206 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
|
3207 if (EQ (list->driver->type, driver->type)) |
90400 | 3208 error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type))); |
3209 | |
3210 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
|
3211 list->on = 0; |
90400 | 3212 list->driver = driver; |
3213 list->next = NULL; | |
3214 if (prev) | |
3215 prev->next = list; | |
3216 else if (f) | |
3217 f->font_driver_list = list; | |
3218 else | |
3219 font_driver_list = list; | |
95403
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
3220 if (! f) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
3221 num_font_drivers++; |
90400 | 3222 } |
3223 | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3224 |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3225 /* Make the frame F use font backends listed in NEW_DRIVERS (list of |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3226 symbols, e.g. xft, x). If NEW_DRIVERS is t, make F use all |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3227 available font drivers. If NEW_DRIVERS is nil, finalize all drivers. |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3228 |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3229 A caller must free all realized faces if any in advance. The |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3230 return value is a list of font backends actually made used on |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3231 F. */ |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3232 |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3233 Lisp_Object |
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3234 font_update_drivers (f, new_drivers) |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3235 FRAME_PTR f; |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3236 Lisp_Object new_drivers; |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3237 { |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3238 Lisp_Object active_drivers = Qnil; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3239 struct font_driver *driver; |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3240 struct font_driver_list *list; |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3241 |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3242 /* At first, turn off non-requested drivers, and turn on requested |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3243 drivers. */ |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3244 for (list = f->font_driver_list; list; list = list->next) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3245 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3246 driver = list->driver; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3247 if ((EQ (new_drivers, Qt) || ! NILP (Fmemq (driver->type, new_drivers))) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3248 != list->on) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3249 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3250 if (list->on) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3251 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3252 if (driver->end_for_frame) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3253 driver->end_for_frame (f); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3254 font_finish_cache (f, driver); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3255 list->on = 0; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3256 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3257 else |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3258 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3259 if (! driver->start_for_frame |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3260 || driver->start_for_frame (f) == 0) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3261 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3262 font_prepare_cache (f, driver); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3263 list->on = 1; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3264 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3265 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3266 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3267 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3268 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3269 if (NILP (new_drivers)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3270 return Qnil; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3271 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3272 if (! EQ (new_drivers, Qt)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3273 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3274 /* Re-order the driver list according to new_drivers. */ |
95958
fbdde312e09d
(font_update_drivers): Fix crash when no drivers match.
Andreas Schwab <schwab@suse.de>
parents:
95894
diff
changeset
|
3275 struct font_driver_list **list_table, **next; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3276 Lisp_Object tail; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3277 int i; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3278 |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3279 list_table = alloca (sizeof list_table[0] * (num_font_drivers + 1)); |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3280 for (i = 0, tail = new_drivers; ! NILP (tail); tail = XCDR (tail)) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3281 { |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3282 for (list = f->font_driver_list; list; list = list->next) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3283 if (list->on && EQ (list->driver->type, XCAR (tail))) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3284 break; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3285 if (list) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3286 list_table[i++] = list; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3287 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3288 for (list = f->font_driver_list; list; list = list->next) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3289 if (! list->on) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3290 list_table[i] = list; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3291 list_table[i] = NULL; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3292 |
95958
fbdde312e09d
(font_update_drivers): Fix crash when no drivers match.
Andreas Schwab <schwab@suse.de>
parents:
95894
diff
changeset
|
3293 next = &f->font_driver_list; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3294 for (i = 0; list_table[i]; i++) |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3295 { |
95958
fbdde312e09d
(font_update_drivers): Fix crash when no drivers match.
Andreas Schwab <schwab@suse.de>
parents:
95894
diff
changeset
|
3296 *next = list_table[i]; |
fbdde312e09d
(font_update_drivers): Fix crash when no drivers match.
Andreas Schwab <schwab@suse.de>
parents:
95894
diff
changeset
|
3297 next = &(*next)->next; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3298 } |
95958
fbdde312e09d
(font_update_drivers): Fix crash when no drivers match.
Andreas Schwab <schwab@suse.de>
parents:
95894
diff
changeset
|
3299 *next = NULL; |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3300 } |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3301 |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3302 for (list = f->font_driver_list; list; list = list->next) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3303 if (list->on) |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3304 active_drivers = nconc2 (active_drivers, |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
3305 Fcons (list->driver->type, Qnil)); |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3306 return active_drivers; |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3307 } |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3308 |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3309 int |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3310 font_put_frame_data (f, driver, data) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3311 FRAME_PTR f; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3312 struct font_driver *driver; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3313 void *data; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3314 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3315 struct font_data_list *list, *prev; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3316 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3317 for (prev = NULL, list = f->font_data_list; list; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3318 prev = list, list = list->next) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3319 if (list->driver == driver) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3320 break; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3321 if (! data) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3322 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3323 if (list) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3324 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3325 if (prev) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3326 prev->next = list->next; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3327 else |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3328 f->font_data_list = list->next; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3329 free (list); |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3330 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3331 return 0; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3332 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3333 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3334 if (! list) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3335 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3336 list = malloc (sizeof (struct font_data_list)); |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3337 if (! list) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3338 return -1; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3339 list->driver = driver; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3340 list->next = f->font_data_list; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3341 f->font_data_list = list; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3342 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3343 list->data = data; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3344 return 0; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3345 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3346 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3347 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3348 void * |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3349 font_get_frame_data (f, driver) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3350 FRAME_PTR f; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3351 struct font_driver *driver; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3352 { |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3353 struct font_data_list *list; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3354 |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3355 for (list = f->font_data_list; list; list = list->next) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3356 if (list->driver == driver) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3357 break; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3358 if (! list) |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3359 return NULL; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3360 return list->data; |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3361 } |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3362 |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3363 |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3364 /* Return the font used to draw character C by FACE at buffer position |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3365 POS in window W. If STRING is non-nil, it is a string containing C |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3366 at index POS. If C is negative, get C from the current buffer or |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3367 STRING. */ |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3368 |
90541 | 3369 Lisp_Object |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3370 font_at (c, pos, face, w, string) |
90541 | 3371 int c; |
3372 EMACS_INT pos; | |
3373 struct face *face; | |
3374 struct window *w; | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3375 Lisp_Object string; |
90541 | 3376 { |
3377 FRAME_PTR f; | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3378 int multibyte; |
94926 | 3379 Lisp_Object font_object; |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3380 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3381 if (c < 0) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3382 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3383 if (NILP (string)) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3384 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3385 multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3386 if (multibyte) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3387 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3388 EMACS_INT pos_byte = CHAR_TO_BYTE (pos); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3389 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3390 c = FETCH_CHAR (pos_byte); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3391 } |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3392 else |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3393 c = FETCH_BYTE (pos); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3394 } |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3395 else |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3396 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3397 unsigned char *str; |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3398 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3399 multibyte = STRING_MULTIBYTE (string); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3400 if (multibyte) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3401 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3402 EMACS_INT pos_byte = string_char_to_byte (string, pos); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3403 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3404 str = SDATA (string) + pos_byte; |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3405 c = STRING_CHAR (str, 0); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3406 } |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3407 else |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3408 c = SDATA (string)[pos]; |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3409 } |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3410 } |
90541 | 3411 |
3412 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
|
3413 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
|
3414 return Qnil; |
90541 | 3415 if (! face) |
3416 { | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3417 int face_id; |
92237
ce06567a933d
* dispextern.h (face_at_buffer_position, face_for_overlay_string)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92233
diff
changeset
|
3418 EMACS_INT endptr; |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3419 |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3420 if (STRINGP (string)) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3421 face_id = face_at_string_position (w, string, pos, 0, -1, -1, &endptr, |
90541 | 3422 DEFAULT_FACE_ID, 0); |
3423 else | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3424 face_id = face_at_buffer_position (w, pos, -1, -1, &endptr, |
90541 | 3425 pos + 100, 0); |
3426 face = FACE_FROM_ID (f, face_id); | |
3427 } | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3428 if (multibyte) |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3429 { |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3430 int face_id = FACE_FOR_CHAR (f, face, c, pos, string); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3431 face = FACE_FROM_ID (f, face_id); |
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
3432 } |
94926 | 3433 if (! face->font) |
90541 | 3434 return Qnil; |
94926 | 3435 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3436 font_assert (font_check_object ((struct font *) face->font)); |
94926 | 3437 XSETFONT (font_object, face->font); |
3438 return font_object; | |
3439 } | |
3440 | |
3441 | |
3442 /* Check how many characters after POS (at most to LIMIT) can be | |
3443 displayed by the same font. FACE is the face selected for the | |
3444 character as POS on frame F. STRING, if not nil, is the string to | |
3445 check instead of the current buffer. | |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
3446 |
94926 | 3447 The return value is the position of the character that is displayed |
3448 by the differnt font than that of the character as POS. */ | |
3449 | |
3450 EMACS_INT | |
3451 font_range (pos, limit, face, f, string) | |
3452 EMACS_INT pos, limit; | |
3453 struct face *face; | |
3454 FRAME_PTR f; | |
3455 Lisp_Object string; | |
3456 { | |
3457 int multibyte; | |
3458 EMACS_INT pos_byte; | |
3459 int c; | |
3460 struct font *font; | |
3461 int first = 1; | |
3462 | |
3463 if (NILP (string)) | |
3464 { | |
3465 multibyte = ! NILP (current_buffer->enable_multibyte_characters); | |
3466 pos_byte = CHAR_TO_BYTE (pos); | |
3467 } | |
3468 else | |
3469 { | |
3470 multibyte = STRING_MULTIBYTE (string); | |
3471 pos_byte = string_char_to_byte (string, pos); | |
3472 } | |
3473 | |
3474 if (! multibyte) | |
3475 /* All unibyte character are displayed by the same font. */ | |
3476 return limit; | |
3477 | |
3478 while (pos < limit) | |
3479 { | |
3480 int face_id; | |
3481 | |
3482 if (NILP (string)) | |
3483 FETCH_CHAR_ADVANCE_NO_CHECK (c, pos, pos_byte); | |
3484 else | |
3485 FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, string, pos, pos_byte); | |
3486 face_id = FACE_FOR_CHAR (f, face, c, pos, string); | |
3487 face = FACE_FROM_ID (f, face_id); | |
3488 if (first) | |
3489 { | |
3490 font = face->font; | |
3491 first = 0; | |
3492 continue; | |
3493 } | |
3494 else if (font != face->font) | |
3495 { | |
3496 pos--; | |
3497 break; | |
3498 } | |
3499 } | |
3500 return pos; | |
90541 | 3501 } |
3502 | |
90400 | 3503 |
3504 /* Lisp API */ | |
3505 | |
94926 | 3506 DEFUN ("fontp", Ffontp, Sfontp, 1, 2, 0, |
91353
b93ade1a3602
(font_find_for_lface): Check if the character C is
Kenichi Handa <handa@m17n.org>
parents:
91350
diff
changeset
|
3507 doc: /* Return t if OBJECT is a font-spec, font-entity, or font-object. |
94926 | 3508 Return nil otherwise. |
3509 Optional 2nd argument EXTRA-TYPE, if non-nil, specifies to check | |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
3510 which kind of font it is. It must be one of `font-spec', `font-entity', |
94926 | 3511 `font-object'. */) |
3512 (object, extra_type) | |
3513 Lisp_Object object, extra_type; | |
90400 | 3514 { |
94926 | 3515 if (NILP (extra_type)) |
3516 return (FONTP (object) ? Qt : Qnil); | |
3517 if (EQ (extra_type, Qfont_spec)) | |
3518 return (FONT_SPEC_P (object) ? Qt : Qnil); | |
3519 if (EQ (extra_type, Qfont_entity)) | |
3520 return (FONT_ENTITY_P (object) ? Qt : Qnil); | |
3521 if (EQ (extra_type, Qfont_object)) | |
3522 return (FONT_OBJECT_P (object) ? Qt : Qnil); | |
3523 wrong_type_argument (intern ("font-extra-type"), extra_type); | |
90400 | 3524 } |
3525 | |
3526 DEFUN ("font-spec", Ffont_spec, Sfont_spec, 0, MANY, 0, | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3527 doc: /* Return a newly created font-spec with arguments as properties. |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3528 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3529 ARGS must come in pairs KEY VALUE of font properties. KEY must be a |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3530 valid font property name listed below: |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3531 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3532 `:family', `:weight', `:slant', `:width' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3533 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3534 They are the same as face attributes of the same name. See |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3535 `set-face-attribute'. |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3536 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3537 `:foundry' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3538 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3539 VALUE must be a string or a symbol specifying the font foundry, e.g. ``misc''. |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3540 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3541 `:adstyle' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3542 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3543 VALUE must be a string or a symbol specifying the additional |
94926 | 3544 typographic style information of a font, e.g. ``sans''. |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3545 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3546 `:registry' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3547 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3548 VALUE must be a string or a symbol specifying the charset registry and |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3549 encoding of a font, e.g. ``iso8859-1''. |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3550 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3551 `:size' |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3552 |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3553 VALUE must be a non-negative integer or a floating point number |
94926 | 3554 specifying the font size. It specifies the font size in pixels |
91112
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3555 (if VALUE is an integer), or in points (if VALUE is a float). |
8042dbbb0419
(font_update_drivers): Call driver->start_for_frame and
Kenichi Handa <handa@m17n.org>
parents:
91081
diff
changeset
|
3556 usage: (font-spec ARGS ...) */) |
90400 | 3557 (nargs, args) |
3558 int nargs; | |
3559 Lisp_Object *args; | |
3560 { | |
94926 | 3561 Lisp_Object spec = font_make_spec (); |
90400 | 3562 int i; |
3563 | |
3564 for (i = 0; i < nargs; i += 2) | |
3565 { | |
3566 Lisp_Object key = args[i], val = args[i + 1]; | |
3567 | |
94926 | 3568 if (EQ (key, QCname)) |
3569 { | |
3570 CHECK_STRING (val); | |
3571 font_parse_name ((char *) SDATA (val), spec); | |
3572 font_put_extra (spec, key, val); | |
3573 } | |
90400 | 3574 else |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
3575 { |
94926 | 3576 int idx = get_font_prop_index (key); |
3577 | |
3578 if (idx >= 0) | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3579 { |
94926 | 3580 val = font_prop_validate (idx, Qnil, val); |
3581 if (idx < FONT_EXTRA_INDEX) | |
3582 ASET (spec, idx, val); | |
3583 else | |
3584 font_put_extra (spec, key, val); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
3585 } |
94926 | 3586 else |
3587 font_put_extra (spec, key, font_prop_validate (0, key, val)); | |
90451
6ffc9b378367
(enum xlfd_field_index): Rename XLFD_XXX_SIZE_INDEX to
Kenichi Handa <handa@m17n.org>
parents:
90448
diff
changeset
|
3588 } |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3589 } |
90400 | 3590 return spec; |
3591 } | |
3592 | |
94926 | 3593 DEFUN ("copy-font-spec", Fcopy_font_spec, Scopy_font_spec, 1, 1, 0, |
3594 doc: /* Return a copy of FONT as a font-spec. */) | |
3595 (font) | |
3596 Lisp_Object font; | |
3597 { | |
3598 Lisp_Object new_spec, tail, extra; | |
3599 int i; | |
3600 | |
3601 CHECK_FONT (font); | |
3602 new_spec = font_make_spec (); | |
3603 for (i = 1; i < FONT_EXTRA_INDEX; i++) | |
3604 ASET (new_spec, i, AREF (font, i)); | |
3605 extra = Qnil; | |
3606 for (tail = AREF (font, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) | |
3607 { | |
3608 if (! EQ (XCAR (XCAR (tail)), QCfont_entity)) | |
3609 extra = Fcons (Fcons (XCAR (XCAR (tail)), XCDR (XCAR (tail))), extra); | |
3610 } | |
3611 ASET (new_spec, FONT_EXTRA_INDEX, extra); | |
3612 return new_spec; | |
3613 } | |
3614 | |
3615 DEFUN ("merge-font-spec", Fmerge_font_spec, Smerge_font_spec, 2, 2, 0, | |
3616 doc: /* Merge font-specs FROM and TO, and return a new font-spec. | |
3617 Every specified properties in FROM override the corresponding | |
3618 properties in TO. */) | |
3619 (from, to) | |
3620 Lisp_Object from, to; | |
3621 { | |
3622 Lisp_Object extra, tail; | |
3623 int i; | |
3624 | |
3625 CHECK_FONT (from); | |
3626 CHECK_FONT (to); | |
3627 to = Fcopy_font_spec (to); | |
3628 for (i = 0; i < FONT_EXTRA_INDEX; i++) | |
3629 ASET (to, i, AREF (from, i)); | |
3630 extra = AREF (to, FONT_EXTRA_INDEX); | |
3631 for (tail = AREF (from, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) | |
3632 if (! EQ (XCAR (XCAR (tail)), Qfont_entity)) | |
3633 { | |
3634 Lisp_Object slot = assq_no_quit (XCAR (XCAR (tail)), extra); | |
3635 | |
3636 if (! NILP (slot)) | |
3637 XSETCDR (slot, XCDR (XCAR (tail))); | |
3638 else | |
3639 extra = Fcons (Fcons (XCAR (XCAR (tail)), XCDR (XCAR (tail))), extra); | |
3640 } | |
3641 ASET (to, FONT_EXTRA_INDEX, extra); | |
3642 return to; | |
3643 } | |
90400 | 3644 |
3645 DEFUN ("font-get", Ffont_get, Sfont_get, 2, 2, 0, | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3646 doc: /* Return the value of FONT's property KEY. |
90563
7c29515f7c2a
(font_parse_fcname): Don't change :name property of FONT.
Kenichi Handa <handa@m17n.org>
parents:
90556
diff
changeset
|
3647 FONT is a font-spec, a font-entity, or a font-object. */) |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3648 (font, key) |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3649 Lisp_Object font, key; |
90400 | 3650 { |
94926 | 3651 int idx; |
3652 | |
3653 CHECK_FONT (font); | |
3654 CHECK_SYMBOL (key); | |
3655 | |
3656 idx = get_font_prop_index (key); | |
3657 if (idx >= 0 && idx < FONT_EXTRA_INDEX) | |
90400 | 3658 return AREF (font, idx); |
94926 | 3659 return Fcdr (Fassq (key, AREF (font, FONT_EXTRA_INDEX))); |
90400 | 3660 } |
3661 | |
3662 | |
3663 DEFUN ("font-put", Ffont_put, Sfont_put, 3, 3, 0, | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3664 doc: /* Set one property of FONT-SPEC: give property PROP value VAL. */) |
90400 | 3665 (font_spec, prop, val) |
3666 Lisp_Object font_spec, prop, val; | |
3667 { | |
94926 | 3668 int idx; |
90400 | 3669 |
3670 CHECK_FONT_SPEC (font_spec); | |
94926 | 3671 idx = get_font_prop_index (prop); |
3672 if (idx >= 0 && idx < FONT_EXTRA_INDEX) | |
95573
0da1a8e03099
(Ffont_put): Don't use font_parse_family_registry for
Kenichi Handa <handa@m17n.org>
parents:
95572
diff
changeset
|
3673 ASET (font_spec, idx, font_prop_validate (idx, Qnil, val)); |
90400 | 3674 else |
94926 | 3675 font_put_extra (font_spec, prop, font_prop_validate (0, prop, val)); |
90400 | 3676 return val; |
3677 } | |
3678 | |
3679 DEFUN ("list-fonts", Flist_fonts, Slist_fonts, 1, 4, 0, | |
3680 doc: /* List available fonts matching FONT-SPEC on the current frame. | |
3681 Optional 2nd argument FRAME specifies the target frame. | |
3682 Optional 3rd argument NUM, if non-nil, limits the number of returned fonts. | |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3683 Optional 4th argument PREFER, if non-nil, is a font-spec to |
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3684 control the order of the returned list. Fonts are sorted by |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
3685 how close they are to PREFER. */) |
90400 | 3686 (font_spec, frame, num, prefer) |
3687 Lisp_Object font_spec, frame, num, prefer; | |
3688 { | |
3689 Lisp_Object vec, list, tail; | |
3690 int n = 0, i, len; | |
3691 | |
3692 if (NILP (frame)) | |
3693 frame = selected_frame; | |
3694 CHECK_LIVE_FRAME (frame); | |
94926 | 3695 CHECK_FONT_SPEC (font_spec); |
90400 | 3696 if (! NILP (num)) |
3697 { | |
3698 CHECK_NUMBER (num); | |
3699 n = XINT (num); | |
3700 if (n <= 0) | |
3701 return Qnil; | |
3702 } | |
3703 if (! NILP (prefer)) | |
94926 | 3704 CHECK_FONT_SPEC (prefer); |
90400 | 3705 |
3706 vec = font_list_entities (frame, font_spec); | |
3707 len = ASIZE (vec); | |
3708 if (len == 0) | |
3709 return Qnil; | |
3710 if (len == 1) | |
3711 return Fcons (AREF (vec, 0), Qnil); | |
3712 | |
3713 if (! NILP (prefer)) | |
94926 | 3714 vec = font_sort_entites (vec, prefer, frame, font_spec, 0); |
90400 | 3715 |
3716 list = tail = Fcons (AREF (vec, 0), Qnil); | |
3717 if (n == 0 || n > len) | |
3718 n = len; | |
3719 for (i = 1; i < n; i++) | |
3720 { | |
3721 Lisp_Object val = Fcons (AREF (vec, i), Qnil); | |
3722 | |
3723 XSETCDR (tail, val); | |
3724 tail = val; | |
3725 } | |
3726 return list; | |
3727 } | |
3728 | |
94926 | 3729 DEFUN ("font-family-list", Ffont_family_list, Sfont_family_list, 0, 1, 0, |
90400 | 3730 doc: /* List available font families on the current frame. |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
3731 Optional argument FRAME, if non-nil, specifies the target frame. */) |
90400 | 3732 (frame) |
3733 Lisp_Object frame; | |
3734 { | |
3735 FRAME_PTR f; | |
3736 struct font_driver_list *driver_list; | |
3737 Lisp_Object list; | |
3738 | |
3739 if (NILP (frame)) | |
3740 frame = selected_frame; | |
3741 CHECK_LIVE_FRAME (frame); | |
3742 f = XFRAME (frame); | |
3743 list = Qnil; | |
3744 for (driver_list = f->font_driver_list; driver_list; | |
3745 driver_list = driver_list->next) | |
3746 if (driver_list->driver->list_family) | |
3747 { | |
3748 Lisp_Object val = driver_list->driver->list_family (frame); | |
3749 | |
3750 if (NILP (list)) | |
3751 list = val; | |
3752 else | |
3753 { | |
3754 Lisp_Object tail = list; | |
3755 | |
3756 for (; CONSP (val); val = XCDR (val)) | |
3757 if (NILP (Fmemq (XCAR (val), tail))) | |
3758 list = Fcons (XCAR (val), list); | |
3759 } | |
3760 } | |
3761 return list; | |
3762 } | |
3763 | |
3764 DEFUN ("find-font", Ffind_font, Sfind_font, 1, 2, 0, | |
3765 doc: /* Return a font-entity matching with FONT-SPEC on the current frame. | |
3766 Optional 2nd argument FRAME, if non-nil, specifies the target frame. */) | |
3767 (font_spec, frame) | |
3768 Lisp_Object font_spec, frame; | |
3769 { | |
3770 Lisp_Object val = Flist_fonts (font_spec, frame, make_number (1), Qnil); | |
3771 | |
3772 if (CONSP (val)) | |
3773 val = XCAR (val); | |
3774 return val; | |
3775 } | |
3776 | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3777 DEFUN ("font-xlfd-name", Ffont_xlfd_name, Sfont_xlfd_name, 1, 2, 0, |
90400 | 3778 doc: /* Return XLFD name of FONT. |
3779 FONT is a font-spec, font-entity, or font-object. | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3780 If the name is too long for XLFD (maximum 255 chars), return nil. |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3781 If the 2nd optional arg FOLD-WILDCARDS is non-nil, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3782 the consecutive wildcards are folded to one. */) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3783 (font, fold_wildcards) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3784 Lisp_Object font, fold_wildcards; |
90400 | 3785 { |
3786 char name[256]; | |
3787 int pixel_size = 0; | |
3788 | |
94926 | 3789 CHECK_FONT (font); |
3790 | |
3791 if (FONT_OBJECT_P (font)) | |
90400 | 3792 { |
94926 | 3793 Lisp_Object font_name = AREF (font, FONT_NAME_INDEX); |
3794 | |
3795 if (STRINGP (font_name) | |
3796 && SDATA (font_name)[0] == '-') | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3797 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3798 if (NILP (fold_wildcards)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3799 return font_name; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3800 strcpy (name, (char *) SDATA (font_name)); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3801 goto done; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3802 } |
94926 | 3803 pixel_size = XFONT_OBJECT (font)->pixel_size; |
90400 | 3804 } |
3805 if (font_unparse_xlfd (font, pixel_size, name, 256) < 0) | |
3806 return Qnil; | |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3807 done: |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3808 if (! NILP (fold_wildcards)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3809 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3810 char *p0 = name, *p1; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3811 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3812 while ((p1 = strstr (p0, "-*-*"))) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3813 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3814 strcpy (p1, p1 + 2); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3815 p0 = p1; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3816 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3817 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3818 |
90400 | 3819 return build_string (name); |
3820 } | |
3821 | |
3822 DEFUN ("clear-font-cache", Fclear_font_cache, Sclear_font_cache, 0, 0, 0, | |
3823 doc: /* Clear font cache. */) | |
3824 () | |
3825 { | |
3826 Lisp_Object list, frame; | |
3827 | |
3828 FOR_EACH_FRAME (list, frame) | |
3829 { | |
3830 FRAME_PTR f = XFRAME (frame); | |
3831 struct font_driver_list *driver_list = f->font_driver_list; | |
3832 | |
3833 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
|
3834 if (driver_list->on) |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3835 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3836 Lisp_Object cache = driver_list->driver->get_cache (f); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3837 Lisp_Object val; |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3838 |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3839 val = XCDR (cache); |
91909 | 3840 while (! NILP (val) |
3841 && ! EQ (XCAR (XCAR (val)), driver_list->driver->type)) | |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3842 val = XCDR (val); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
3843 font_assert (! NILP (val)); |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3844 val = XCDR (XCAR (val)); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3845 if (XINT (XCAR (val)) == 0) |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3846 { |
91247
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3847 font_clear_cache (f, XCAR (val), driver_list->driver); |
217eabc2db11
(font_prepare_cache, font_finish_cache, font_get_cache): New
Kenichi Handa <handa@m17n.org>
parents:
91240
diff
changeset
|
3848 XSETCDR (cache, XCDR (val)); |
90549
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3849 } |
5dab62a4573c
(font_unparse_fcname): Fix typo (swidth->width).
Kenichi Handa <handa@m17n.org>
parents:
90541
diff
changeset
|
3850 } |
90400 | 3851 } |
3852 | |
3853 return Qnil; | |
3854 } | |
3855 | |
95177 | 3856 /* The following three functions are still experimental. */ |
91081
2c767d9f0bb1
(font_prop_validate_symbol): The argument prop_index is
Kenichi Handa <handa@m17n.org>
parents:
90993
diff
changeset
|
3857 |
90400 | 3858 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
|
3859 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
|
3860 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
|
3861 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3862 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
|
3863 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
|
3864 [ HEADER GLYPH ... ] |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3865 HEADER is a vector of this form: |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3866 [FONT-OBJECT WIDTH LBEARING RBEARING ASCENT DESCENT] |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3867 where |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
3868 FONT-OBJECT is a font-object for all glyphs in the g-string, |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
3869 WIDTH thru DESCENT are the metrics (in pixels) of the whole G-string. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3870 GLYPH is a vector of this form: |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3871 [ FROM-IDX TO-IDX C CODE WIDTH LBEARING RBEARING ASCENT DESCENT |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3872 [ [X-OFF Y-OFF WADJUST] | nil] ] |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3873 where |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3874 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
|
3875 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
|
3876 CODE is the glyph-code of C in FONT-OBJECT. |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
3877 WIDTH thru DESCENT are the metrics (in pixels) of the glyph. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
3878 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
|
3879 WADJUST is the adjustment to the normal width of the glyph. */) |
90400 | 3880 (font_object, num) |
3881 Lisp_Object font_object, num; | |
3882 { | |
3883 Lisp_Object gstring, g; | |
3884 int len; | |
3885 int i; | |
3886 | |
3887 if (! NILP (font_object)) | |
3888 CHECK_FONT_OBJECT (font_object); | |
3889 CHECK_NATNUM (num); | |
3890 | |
3891 len = XINT (num) + 1; | |
3892 gstring = Fmake_vector (make_number (len), Qnil); | |
3893 g = Fmake_vector (make_number (6), Qnil); | |
3894 ASET (g, 0, font_object); | |
3895 ASET (gstring, 0, g); | |
3896 for (i = 1; i < len; i++) | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3897 ASET (gstring, i, Fmake_vector (make_number (10), Qnil)); |
90400 | 3898 return gstring; |
3899 } | |
3900 | |
3901 DEFUN ("font-fill-gstring", Ffont_fill_gstring, Sfont_fill_gstring, 4, 5, 0, | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3902 doc: /* Fill in glyph-string GSTRING by characters for FONT-OBJECT. |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3903 START and END specify the region to extract characters. |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3904 If optional 5rd argument OBJECT is non-nil, it is a buffer or a string from |
90400 | 3905 where to extract characters. |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
3906 FONT-OBJECT may be nil if GSTRING already contains one. */) |
90400 | 3907 (gstring, font_object, start, end, object) |
3908 Lisp_Object gstring, font_object, start, end, object; | |
3909 { | |
3910 int len, i, c; | |
3911 unsigned code; | |
3912 struct font *font; | |
3913 | |
3914 CHECK_VECTOR (gstring); | |
3915 if (NILP (font_object)) | |
90541 | 3916 font_object = LGSTRING_FONT (gstring); |
94926 | 3917 font = XFONT_OBJECT (font_object); |
90400 | 3918 |
3919 if (STRINGP (object)) | |
3920 { | |
3921 const unsigned char *p; | |
3922 | |
3923 CHECK_NATNUM (start); | |
3924 CHECK_NATNUM (end); | |
3925 if (XINT (start) > XINT (end) | |
3926 || XINT (end) > ASIZE (object) | |
90541 | 3927 || XINT (end) - XINT (start) > LGSTRING_LENGTH (gstring)) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3928 args_out_of_range_3 (object, start, end); |
90400 | 3929 |
3930 len = XINT (end) - XINT (start); | |
3931 p = SDATA (object) + string_char_to_byte (object, XINT (start)); | |
3932 for (i = 0; i < len; i++) | |
3933 { | |
3934 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3935 /* Shut up GCC warning in comparison with |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3936 MOST_POSITIVE_FIXNUM below. */ |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3937 EMACS_INT cod; |
90400 | 3938 |
3939 c = STRING_CHAR_ADVANCE (p); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3940 cod = code = font->driver->encode_char (font, c); |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3941 if (cod > MOST_POSITIVE_FIXNUM || code == FONT_INVALID_CODE) |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3942 break; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3943 LGLYPH_SET_FROM (g, i); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3944 LGLYPH_SET_TO (g, i); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3945 LGLYPH_SET_CHAR (g, c); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3946 LGLYPH_SET_CODE (g, code); |
90400 | 3947 } |
3948 } | |
3949 else | |
3950 { | |
3951 int pos, pos_byte; | |
3952 | |
3953 if (! NILP (object)) | |
3954 Fset_buffer (object); | |
3955 validate_region (&start, &end); | |
90541 | 3956 if (XINT (end) - XINT (start) > LGSTRING_LENGTH (gstring)) |
90400 | 3957 args_out_of_range (start, end); |
3958 len = XINT (end) - XINT (start); | |
3959 pos = XINT (start); | |
3960 pos_byte = CHAR_TO_BYTE (pos); | |
3961 for (i = 0; i < len; i++) | |
3962 { | |
3963 Lisp_Object g = LGSTRING_GLYPH (gstring, i); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3964 /* Shut up GCC warning in comparison with |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3965 MOST_POSITIVE_FIXNUM below. */ |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3966 EMACS_INT cod; |
90400 | 3967 |
3968 FETCH_CHAR_ADVANCE (c, pos, pos_byte); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3969 cod = code = font->driver->encode_char (font, c); |
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
3970 if (cod > MOST_POSITIVE_FIXNUM || code == FONT_INVALID_CODE) |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3971 break; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3972 LGLYPH_SET_FROM (g, i); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3973 LGLYPH_SET_TO (g, i); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3974 LGLYPH_SET_CHAR (g, c); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3975 LGLYPH_SET_CODE (g, code); |
90400 | 3976 } |
3977 } | |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3978 for (; i < LGSTRING_LENGTH (gstring); i++) |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
3979 LGSTRING_SET_GLYPH (gstring, i, Qnil); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3980 return Qnil; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3981 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3982 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3983 DEFUN ("font-shape-text", Ffont_shape_text, Sfont_shape_text, 3, 4, 0, |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3984 doc: /* Shape text between FROM and TO by FONT-OBJECT. |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3985 If optional 4th argument STRING is non-nil, it is a string to shape, |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3986 and FROM and TO are indices to the string. |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3987 The value is the end position of the text that can be shaped by |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
3988 FONT-OBJECT. */) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3989 (from, to, font_object, string) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3990 Lisp_Object from, to, font_object, string; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3991 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3992 struct font *font; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3993 struct font_metrics metrics; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3994 EMACS_INT start, end; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3995 Lisp_Object gstring, n; |
94926 | 3996 int len, i; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
3997 |
92183
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3998 if (! FONT_OBJECT_P (font_object)) |
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
3999 return Qnil; |
94926 | 4000 font = XFONT_OBJECT (font_object); |
92183
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
4001 if (! font->driver->shape) |
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
4002 return Qnil; |
275e5e980fc4
If the font driver doesn't have `shape' function, return Qnil.
Kenichi Handa <handa@m17n.org>
parents:
92113
diff
changeset
|
4003 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4004 if (NILP (string)) |
90541 | 4005 { |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4006 validate_region (&from, &to); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4007 start = XFASTINT (from); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4008 end = XFASTINT (to); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4009 modify_region (current_buffer, start, end, 0); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4010 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4011 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4012 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4013 CHECK_STRING (string); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4014 start = XINT (from); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4015 end = XINT (to); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4016 if (start < 0 || start > end || end > SCHARS (string)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4017 args_out_of_range_3 (string, from, to); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4018 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4019 |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4020 len = end - start; |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4021 gstring = Ffont_make_gstring (font_object, make_number (len)); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4022 Ffont_fill_gstring (gstring, font_object, from, to, string); |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4023 |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4024 /* Try at most three times with larger gstring each time. */ |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4025 for (i = 0; i < 3; i++) |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4026 { |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4027 Lisp_Object args[2]; |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4028 |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4029 n = font->driver->shape (gstring); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4030 if (INTEGERP (n)) |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4031 break; |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4032 args[0] = gstring; |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4033 args[1] = Fmake_vector (make_number (len), Qnil); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4034 gstring = Fvconcat (2, args); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4035 } |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4036 if (! INTEGERP (n) || XINT (n) == 0) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4037 return Qnil; |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4038 len = XINT (n); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4039 |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4040 for (i = 0; i < len;) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4041 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4042 Lisp_Object gstr; |
90541 | 4043 Lisp_Object g = LGSTRING_GLYPH (gstring, i); |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4044 EMACS_INT this_from = LGLYPH_FROM (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4045 EMACS_INT this_to = LGLYPH_TO (g) + 1; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4046 int j, k; |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4047 int need_composition = 0; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4048 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4049 metrics.lbearing = LGLYPH_LBEARING (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4050 metrics.rbearing = LGLYPH_RBEARING (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4051 metrics.ascent = LGLYPH_ASCENT (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4052 metrics.descent = LGLYPH_DESCENT (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4053 if (NILP (LGLYPH_ADJUSTMENT (g))) |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4054 { |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4055 metrics.width = LGLYPH_WIDTH (g); |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
4056 if (LGLYPH_CHAR (g) == 0 || metrics.width == 0) |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4057 need_composition = 1; |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4058 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4059 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4060 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4061 metrics.width = LGLYPH_WADJUST (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4062 metrics.lbearing += LGLYPH_XOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4063 metrics.rbearing += LGLYPH_XOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4064 metrics.ascent -= LGLYPH_YOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4065 metrics.descent += LGLYPH_YOFF (g); |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4066 need_composition = 1; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4067 } |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4068 for (j = i + 1; j < len; j++) |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4069 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4070 int x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4071 |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4072 g = LGSTRING_GLYPH (gstring, j); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4073 if (this_from != LGLYPH_FROM (g)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4074 break; |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4075 need_composition = 1; |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4076 x = metrics.width + LGLYPH_LBEARING (g) + LGLYPH_XOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4077 if (metrics.lbearing > x) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4078 metrics.lbearing = x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4079 x = metrics.width + LGLYPH_RBEARING (g) + LGLYPH_XOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4080 if (metrics.rbearing < x) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4081 metrics.rbearing = x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4082 x = LGLYPH_ASCENT (g) - LGLYPH_YOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4083 if (metrics.ascent < x) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4084 metrics.ascent = x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4085 x = LGLYPH_DESCENT (g) - LGLYPH_YOFF (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4086 if (metrics.descent < x) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4087 metrics.descent = x; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4088 if (NILP (LGLYPH_ADJUSTMENT (g))) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4089 metrics.width += LGLYPH_WIDTH (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4090 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4091 metrics.width += LGLYPH_WADJUST (g); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4092 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4093 |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4094 if (need_composition) |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4095 { |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4096 gstr = Ffont_make_gstring (font_object, make_number (j - i)); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4097 LGSTRING_SET_WIDTH (gstr, metrics.width); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4098 LGSTRING_SET_LBEARING (gstr, metrics.lbearing); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4099 LGSTRING_SET_RBEARING (gstr, metrics.rbearing); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4100 LGSTRING_SET_ASCENT (gstr, metrics.ascent); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4101 LGSTRING_SET_DESCENT (gstr, metrics.descent); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4102 for (k = i; i < j; i++) |
91307
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
4103 { |
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
4104 Lisp_Object g = LGSTRING_GLYPH (gstring, i); |
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
4105 |
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
4106 LGLYPH_SET_FROM (g, LGLYPH_FROM (g) - this_from); |
91309
3f56aab091ed
(Ffont_shape_text): Fix setting of `to' field of glyphs.
Kenichi Handa <handa@m17n.org>
parents:
91307
diff
changeset
|
4107 LGLYPH_SET_TO (g, LGLYPH_TO (g) - this_from); |
91307
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
4108 LGSTRING_SET_GLYPH (gstr, i - k, LGSTRING_GLYPH (gstring, i)); |
0afaa00ae397
(Ffont_shape_text): If the font driver doesn't have a
Kenichi Handa <handa@m17n.org>
parents:
91273
diff
changeset
|
4109 } |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4110 from = make_number (start + this_from); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4111 to = make_number (start + this_to); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4112 if (NILP (string)) |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4113 Fcompose_region_internal (from, to, gstr, Qnil); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4114 else |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4115 Fcompose_string_internal (string, from, to, gstr, Qnil); |
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4116 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4117 else |
91267
0fa5916e5871
(Ffont_shape_text): Avoid unnecessary composition.
Kenichi Handa <handa@m17n.org>
parents:
91261
diff
changeset
|
4118 i = j; |
90541 | 4119 } |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4120 |
91192
bcad98389aeb
(Ffont_shape_text): Fix the return value.
Kenichi Handa <handa@m17n.org>
parents:
91174
diff
changeset
|
4121 return to; |
90400 | 4122 } |
4123 | |
95290
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
4124 #if 0 |
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
4125 |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4126 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
|
4127 doc: /* Apply OpenType features on glyph-string GSTRING-IN. |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4128 OTF-FEATURES specifies which features to apply in this format: |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4129 (SCRIPT LANGSYS GSUB GPOS) |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4130 where |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4131 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
|
4132 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
|
4133 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
|
4134 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4135 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
|
4136 |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4137 The features are applied in the order they appear in the list. The |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4138 symbol `*' means to apply all available features not present in this |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4139 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
|
4140 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
|
4141 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
|
4142 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4143 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
|
4144 the glyph-string GSTRING-IN. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4145 |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4146 If some feature is actually applicable, the resulting glyphs are |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4147 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
|
4148 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
|
4149 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4150 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
|
4151 the value is 0. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4152 |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4153 If GSTRING-OUT is too short to hold produced glyphs, no glyphs are |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4154 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
|
4155 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4156 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
|
4157 glyph-string. */) |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4158 (otf_features, gstring_in, from, to, gstring_out, index) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4159 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
|
4160 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4161 Lisp_Object font_object = LGSTRING_FONT (gstring_in); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4162 Lisp_Object val; |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4163 struct font *font; |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4164 int len, num; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4165 |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4166 check_otf_features (otf_features); |
94926 | 4167 CHECK_FONT_OBJECT (font_object); |
4168 font = XFONT_OBJECT (font_object); | |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4169 if (! font->driver->otf_drive) |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4170 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
|
4171 SDATA (SYMBOL_NAME (font->driver->type))); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4172 CHECK_CONS (otf_features); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4173 CHECK_SYMBOL (XCAR (otf_features)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4174 val = XCDR (otf_features); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4175 CHECK_SYMBOL (XCAR (val)); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4176 val = XCDR (otf_features); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4177 if (! NILP (val)) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4178 CHECK_CONS (val); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4179 len = check_gstring (gstring_in); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4180 CHECK_VECTOR (gstring_out); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4181 CHECK_NATNUM (from); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4182 CHECK_NATNUM (to); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4183 CHECK_NATNUM (index); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4184 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4185 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
|
4186 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
|
4187 if (XINT (index) >= ASIZE (gstring_out)) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4188 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
|
4189 num = font->driver->otf_drive (font, otf_features, |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4190 gstring_in, XINT (from), XINT (to), |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4191 gstring_out, XINT (index), 0); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4192 if (num < 0) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4193 return Qnil; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4194 return make_number (num); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4195 } |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4196 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4197 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
|
4198 3, 3, 0, |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4199 doc: /* Return a list of alternate glyphs of CHARACTER in FONT-OBJECT. |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4200 OTF-FEATURES specifies which features of the font FONT-OBJECT to apply |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4201 in this format: |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4202 (SCRIPT LANGSYS FEATURE ...) |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
4203 See the documentation of `font-drive-otf' for more detail. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4204 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4205 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
|
4206 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
|
4207 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
|
4208 corresponding character. */) |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4209 (font_object, character, otf_features) |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4210 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
|
4211 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4212 struct font *font; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4213 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
|
4214 Lisp_Object alternates; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4215 int i, num; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4216 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4217 CHECK_FONT_GET_OBJECT (font_object, font); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4218 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
|
4219 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
|
4220 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
|
4221 CHECK_CHARACTER (character); |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4222 CHECK_CONS (otf_features); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4223 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4224 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
|
4225 g = LGSTRING_GLYPH (gstring_in, 0); |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
4226 LGLYPH_SET_CHAR (g, XINT (character)); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4227 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
|
4228 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
|
4229 gstring_out, 0, 1)) < 0) |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4230 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
|
4231 make_number (ASIZE (gstring_out) * 2)); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4232 alternates = Qnil; |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4233 for (i = 0; i < num; i++) |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4234 { |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4235 Lisp_Object g = LGSTRING_GLYPH (gstring_out, i); |
91550
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
4236 int c = LGLYPH_CHAR (g); |
83267bc0360a
(check_gstring): Use them and AREF to access the vector before
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91360
diff
changeset
|
4237 unsigned code = LGLYPH_CODE (g); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4238 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4239 alternates = Fcons (Fcons (make_number (code), |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4240 c > 0 ? make_number (c) : Qnil), |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4241 alternates); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4242 } |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4243 return Fnreverse (alternates); |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4244 } |
95290
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
4245 #endif /* 0 */ |
90400 | 4246 |
4247 #ifdef FONT_DEBUG | |
4248 | |
4249 DEFUN ("open-font", Fopen_font, Sopen_font, 1, 3, 0, | |
4250 doc: /* Open FONT-ENTITY. */) | |
4251 (font_entity, size, frame) | |
4252 Lisp_Object font_entity; | |
4253 Lisp_Object size; | |
4254 Lisp_Object frame; | |
4255 { | |
4256 int isize; | |
4257 | |
4258 CHECK_FONT_ENTITY (font_entity); | |
4259 if (NILP (frame)) | |
4260 frame = selected_frame; | |
4261 CHECK_LIVE_FRAME (frame); | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4262 |
94926 | 4263 if (NILP (size)) |
4264 isize = XINT (AREF (font_entity, FONT_SIZE_INDEX)); | |
4265 else | |
4266 { | |
4267 CHECK_NUMBER_OR_FLOAT (size); | |
4268 if (FLOATP (size)) | |
4269 isize = POINT_TO_PIXEL (- isize, XFRAME (frame)->resy); | |
4270 else | |
4271 isize = XINT (size); | |
4272 if (isize == 0) | |
4273 isize = 120; | |
4274 } | |
90400 | 4275 return font_open_entity (XFRAME (frame), font_entity, isize); |
4276 } | |
4277 | |
4278 DEFUN ("close-font", Fclose_font, Sclose_font, 1, 2, 0, | |
4279 doc: /* Close FONT-OBJECT. */) | |
4280 (font_object, frame) | |
4281 Lisp_Object font_object, frame; | |
4282 { | |
4283 CHECK_FONT_OBJECT (font_object); | |
4284 if (NILP (frame)) | |
4285 frame = selected_frame; | |
4286 CHECK_LIVE_FRAME (frame); | |
4287 font_close_object (XFRAME (frame), font_object); | |
4288 return Qnil; | |
4289 } | |
4290 | |
4291 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
|
4292 doc: /* Return information about FONT-OBJECT. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4293 The value is a vector: |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4294 [ 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
|
4295 CAPABILITY ] |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4296 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4297 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
|
4298 provide a name). |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4299 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4300 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
|
4301 doesn't provide a file name). |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4302 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4303 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
|
4304 |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
4305 SIZE is a maximum advance width of the font in pixels. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4306 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4307 ASCENT, DESCENT, SPACE-WIDTH, AVERAGE-WIDTH are metrics of the font in |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
4308 pixels. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4309 |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4310 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
|
4311 font format \(x, opentype, truetype, type1, pcf, or bdf) and the |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
4312 remaining elements describe the details of the font capability. |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4313 |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4314 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
|
4315 \(opentype GSUB GPOS) |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4316 where GSUB shows which "GSUB" features the font supports, and GPOS |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4317 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
|
4318 lists of the format: |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4319 \((SCRIPT (LANGSYS FEATURE ...) ...) ...) |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4320 |
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4321 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
|
4322 one. |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4323 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4324 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
|
4325 |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4326 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
|
4327 representing the default langsys. |
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4328 |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4329 FEATURE is a symbol representing OpenType feature tag. |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4330 |
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4331 If the font is not OpenType font, CAPABILITY is nil. */) |
90400 | 4332 (font_object) |
4333 Lisp_Object font_object; | |
4334 { | |
4335 struct font *font; | |
4336 Lisp_Object val; | |
4337 | |
4338 CHECK_FONT_GET_OBJECT (font_object, font); | |
4339 | |
4340 val = Fmake_vector (make_number (9), Qnil); | |
94926 | 4341 ASET (val, 0, AREF (font_object, FONT_NAME_INDEX)); |
4342 ASET (val, 1, AREF (font_object, FONT_FILE_INDEX)); | |
90400 | 4343 ASET (val, 2, make_number (font->pixel_size)); |
94926 | 4344 ASET (val, 3, make_number (font->max_width)); |
90400 | 4345 ASET (val, 4, make_number (font->ascent)); |
4346 ASET (val, 5, make_number (font->descent)); | |
94926 | 4347 ASET (val, 6, make_number (font->space_width)); |
4348 ASET (val, 7, make_number (font->average_width)); | |
90400 | 4349 if (font->driver->otf_capability) |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4350 ASET (val, 8, Fcons (Qopentype, font->driver->otf_capability (font))); |
90400 | 4351 return val; |
4352 } | |
4353 | |
4354 DEFUN ("get-font-glyphs", Fget_font_glyphs, Sget_font_glyphs, 2, 2, 0, | |
4355 doc: /* Return a vector of glyphs of FONT-OBJECT for drawing STRING. | |
4356 Each element is a vector [GLYPH-CODE LBEARING RBEARING WIDTH ASCENT DESCENT]. */) | |
4357 (font_object, string) | |
4358 Lisp_Object font_object, string; | |
4359 { | |
4360 struct font *font; | |
4361 int i, len; | |
4362 Lisp_Object vec; | |
4363 | |
4364 CHECK_FONT_GET_OBJECT (font_object, font); | |
4365 CHECK_STRING (string); | |
4366 len = SCHARS (string); | |
4367 vec = Fmake_vector (make_number (len), Qnil); | |
4368 for (i = 0; i < len; i++) | |
4369 { | |
4370 Lisp_Object ch = Faref (string, make_number (i)); | |
4371 Lisp_Object val; | |
4372 int c = XINT (ch); | |
4373 unsigned code; | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
4374 EMACS_INT cod; |
90400 | 4375 struct font_metrics metrics; |
4376 | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
4377 cod = code = font->driver->encode_char (font, c); |
90400 | 4378 if (code == FONT_INVALID_CODE) |
4379 continue; | |
4380 val = Fmake_vector (make_number (6), Qnil); | |
91871
436548f01688
(Ffont_fill_gstring, Fget_font_glyphs): Fix compilation warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
91553
diff
changeset
|
4381 if (cod <= MOST_POSITIVE_FIXNUM) |
90400 | 4382 ASET (val, 0, make_number (code)); |
4383 else | |
4384 ASET (val, 0, Fcons (make_number (code >> 16), | |
4385 make_number (code & 0xFFFF))); | |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4386 font->driver->text_extents (font, &code, 1, &metrics); |
90400 | 4387 ASET (val, 1, make_number (metrics.lbearing)); |
4388 ASET (val, 2, make_number (metrics.rbearing)); | |
4389 ASET (val, 3, make_number (metrics.width)); | |
4390 ASET (val, 4, make_number (metrics.ascent)); | |
4391 ASET (val, 5, make_number (metrics.descent)); | |
4392 ASET (vec, i, val); | |
4393 } | |
4394 return vec; | |
4395 } | |
4396 | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4397 DEFUN ("font-match-p", Ffont_match_p, Sfont_match_p, 2, 2, 0, |
94745
a995b289585f
(Ffont_match_p): Don't use `iff' in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
94394
diff
changeset
|
4398 doc: /* Return t if and only if font-spec SPEC matches with FONT. |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4399 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
|
4400 (spec, font) |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4401 Lisp_Object spec, font; |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4402 { |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4403 CHECK_FONT_SPEC (spec); |
94926 | 4404 CHECK_FONT (font); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4405 |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4406 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
|
4407 } |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4408 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4409 DEFUN ("font-at", Ffont_at, Sfont_at, 1, 3, 0, |
92233
3642a8778bbf
(Ffont_spec, Ffont_at): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
92183
diff
changeset
|
4410 doc: /* Return a font-object for displaying a character at POSITION. |
90541 | 4411 Optional second arg WINDOW, if non-nil, is a window displaying |
4412 the current buffer. It defaults to the currently selected window. */) | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4413 (position, window, string) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4414 Lisp_Object position, window, string; |
90541 | 4415 { |
4416 struct window *w; | |
91236
e3ba579aab1f
(font_at): Handle the case that the arg C is negative.
Kenichi Handa <handa@m17n.org>
parents:
91192
diff
changeset
|
4417 EMACS_INT pos; |
90541 | 4418 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4419 if (NILP (string)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4420 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4421 CHECK_NUMBER_COERCE_MARKER (position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4422 pos = XINT (position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4423 if (pos < BEGV || pos >= ZV) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4424 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4425 } |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4426 else |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4427 { |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4428 CHECK_NUMBER (position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4429 CHECK_STRING (string); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4430 pos = XINT (position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4431 if (pos < 0 || pos >= SCHARS (string)) |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4432 args_out_of_range (string, position); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4433 } |
90541 | 4434 if (NILP (window)) |
4435 window = selected_window; | |
4436 CHECK_LIVE_WINDOW (window); | |
91273
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4437 w = XWINDOW (window); |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4438 |
f19e3a3100e2
(Ffont_fill_gstring): Stop filling when a character not
Kenichi Handa <handa@m17n.org>
parents:
91267
diff
changeset
|
4439 return font_at (-1, pos, NULL, w, string); |
90541 | 4440 } |
4441 | |
90400 | 4442 #if 0 |
4443 DEFUN ("draw-string", Fdraw_string, Sdraw_string, 2, 2, 0, | |
4444 doc: /* Draw STRING by FONT-OBJECT on the top left corner of the current frame. | |
4445 The value is a number of glyphs drawn. | |
4446 Type C-l to recover what previously shown. */) | |
4447 (font_object, string) | |
4448 Lisp_Object font_object, string; | |
4449 { | |
4450 Lisp_Object frame = selected_frame; | |
4451 FRAME_PTR f = XFRAME (frame); | |
4452 struct font *font; | |
4453 struct face *face; | |
4454 int i, len, width; | |
4455 unsigned *code; | |
4456 | |
4457 CHECK_FONT_GET_OBJECT (font_object, font); | |
4458 CHECK_STRING (string); | |
4459 len = SCHARS (string); | |
4460 code = alloca (sizeof (unsigned) * len); | |
4461 for (i = 0; i < len; i++) | |
4462 { | |
4463 Lisp_Object ch = Faref (string, make_number (i)); | |
4464 Lisp_Object val; | |
4465 int c = XINT (ch); | |
4466 | |
4467 code[i] = font->driver->encode_char (font, c); | |
4468 if (code[i] == FONT_INVALID_CODE) | |
4469 break; | |
4470 } | |
4471 face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
4472 face->fontp = font; | |
4473 if (font->driver->prepare_face) | |
4474 font->driver->prepare_face (f, face); | |
4475 width = font->driver->text_extents (font, code, i, NULL); | |
4476 len = font->driver->draw_text (f, face, 0, font->ascent, code, i, width); | |
4477 if (font->driver->done_face) | |
4478 font->driver->done_face (f, face); | |
4479 face->fontp = NULL; | |
4480 return make_number (len); | |
4481 } | |
4482 #endif | |
4483 | |
4484 #endif /* FONT_DEBUG */ | |
4485 | |
95421
3350c9ac1f37
(Ffont_info): Define only if HAVE_WINDOW_SYSTEM is
Kenichi Handa <handa@m17n.org>
parents:
95403
diff
changeset
|
4486 #ifdef HAVE_WINDOW_SYSTEM |
3350c9ac1f37
(Ffont_info): Define only if HAVE_WINDOW_SYSTEM is
Kenichi Handa <handa@m17n.org>
parents:
95403
diff
changeset
|
4487 |
95403
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4488 DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0, |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4489 doc: /* Return information about a font named NAME on frame FRAME. |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4490 If FRAME is omitted or nil, use the selected frame. |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4491 The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE, |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4492 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT, |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4493 where |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4494 OPENED-NAME is the name used for opening the font, |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4495 FULL-NAME is the full name of the font, |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4496 SIZE is the maximum bound width of the font, |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4497 HEIGHT is the height of the font, |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4498 BASELINE-OFFSET is the upward offset pixels from ASCII baseline, |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4499 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4500 how to compose characters. |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4501 If the named font is not yet loaded, return nil. */) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4502 (name, frame) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4503 Lisp_Object name, frame; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4504 { |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4505 FRAME_PTR f; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4506 struct font *font; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4507 Lisp_Object info; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4508 Lisp_Object font_object; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4509 |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4510 (*check_window_system_func) (); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4511 |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4512 if (! FONTP (name)) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4513 CHECK_STRING (name); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4514 if (NILP (frame)) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4515 frame = selected_frame; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4516 CHECK_LIVE_FRAME (frame); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4517 f = XFRAME (frame); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4518 |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4519 if (STRINGP (name)) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4520 { |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4521 int fontset = fs_query_fontset (name, 0); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4522 |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4523 if (fontset >= 0) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4524 name = fontset_ascii (fontset); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4525 font_object = font_open_by_name (f, (char *) SDATA (name)); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4526 } |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4527 else if (FONT_OBJECT_P (name)) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4528 font_object = name; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4529 else if (FONT_ENTITY_P (name)) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4530 font_object = font_open_entity (f, name, 0); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4531 else |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4532 { |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4533 struct face *face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4534 Lisp_Object entity = font_matching_entity (f, face->lface, name); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4535 |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4536 font_object = ! NILP (entity) ? font_open_entity (f, entity, 0) : Qnil; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4537 } |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4538 if (NILP (font_object)) |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4539 return Qnil; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4540 font = XFONT_OBJECT (font_object); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4541 |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4542 info = Fmake_vector (make_number (7), Qnil); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4543 XVECTOR (info)->contents[0] = AREF (font_object, FONT_NAME_INDEX); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4544 XVECTOR (info)->contents[1] = AREF (font_object, FONT_NAME_INDEX); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4545 XVECTOR (info)->contents[2] = make_number (font->pixel_size); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4546 XVECTOR (info)->contents[3] = make_number (font->height); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4547 XVECTOR (info)->contents[4] = make_number (font->baseline_offset); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4548 XVECTOR (info)->contents[5] = make_number (font->relative_compose); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4549 XVECTOR (info)->contents[6] = make_number (font->default_ascent); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4550 |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4551 #if 0 |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4552 /* As font_object is still in FONT_OBJLIST of the entity, we can't |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4553 close it now. Perhaps, we should manage font-objects |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4554 by `reference-count'. */ |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4555 font_close_object (f, font_object); |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4556 #endif |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4557 return info; |
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4558 } |
95421
3350c9ac1f37
(Ffont_info): Define only if HAVE_WINDOW_SYSTEM is
Kenichi Handa <handa@m17n.org>
parents:
95403
diff
changeset
|
4559 #endif |
95403
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4560 |
90400 | 4561 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4562 #define BUILD_STYLE_TABLE(TBL) \ |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4563 build_style_table ((TBL), sizeof TBL / sizeof (struct table_entry)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4564 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4565 static Lisp_Object |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4566 build_style_table (entry, nelement) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4567 struct table_entry *entry; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4568 int nelement; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4569 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4570 int i, j; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4571 Lisp_Object table, elt; |
95886
c8bc52f94b6d
(syms_of_font) <font-weight-table, font-slant-table, font-width-table>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95875
diff
changeset
|
4572 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4573 table = Fmake_vector (make_number (nelement), Qnil); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4574 for (i = 0; i < nelement; i++) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4575 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4576 for (j = 0; entry[i].names[j]; j++); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4577 elt = Fmake_vector (make_number (j + 1), Qnil); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4578 ASET (elt, 0, make_number (entry[i].numeric)); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4579 for (j = 0; entry[i].names[j]; j++) |
95886
c8bc52f94b6d
(syms_of_font) <font-weight-table, font-slant-table, font-width-table>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95875
diff
changeset
|
4580 ASET (elt, j + 1, intern (entry[i].names[j])); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4581 ASET (table, i, elt); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4582 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4583 return table; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4584 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4585 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4586 static Lisp_Object Vfont_log; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4587 static int font_log_env_checked; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4588 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4589 void |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4590 font_add_log (action, arg, result) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4591 char *action; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4592 Lisp_Object arg, result; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4593 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4594 Lisp_Object tail, val; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4595 int i; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4596 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4597 if (! font_log_env_checked) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4598 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4599 Vfont_log = egetenv ("EMACS_FONT_LOG") ? Qnil : Qt; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4600 font_log_env_checked = 1; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4601 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4602 if (EQ (Vfont_log, Qt)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4603 return; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4604 if (FONTP (arg)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4605 arg = Ffont_xlfd_name (arg, Qt); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4606 if (FONTP (result)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4607 result = Ffont_xlfd_name (result, Qt); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4608 else if (CONSP (result)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4609 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4610 result = Fcopy_sequence (result); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4611 for (tail = result; CONSP (tail); tail = XCDR (tail)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4612 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4613 val = XCAR (tail); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4614 if (FONTP (val)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4615 val = Ffont_xlfd_name (val, Qt); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4616 XSETCAR (tail, val); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4617 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4618 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4619 else if (VECTORP (result)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4620 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4621 result = Fcopy_sequence (result); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4622 for (i = 0; i < ASIZE (result); i++) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4623 { |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4624 val = AREF (result, i); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4625 if (FONTP (val)) |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4626 val = Ffont_xlfd_name (val, Qt); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4627 ASET (result, i, val); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4628 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4629 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4630 Vfont_log = Fcons (list3 (intern (action), arg, result), Vfont_log); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4631 } |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4632 |
90400 | 4633 extern void syms_of_ftfont P_ (()); |
4634 extern void syms_of_xfont P_ (()); | |
4635 extern void syms_of_xftfont P_ (()); | |
4636 extern void syms_of_ftxfont P_ (()); | |
4637 extern void syms_of_bdffont P_ (()); | |
4638 extern void syms_of_w32font P_ (()); | |
4639 extern void syms_of_atmfont P_ (()); | |
4640 | |
4641 void | |
4642 syms_of_font () | |
4643 { | |
95867
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
4644 sort_shift_bits[FONT_TYPE_INDEX] = 0; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
4645 sort_shift_bits[FONT_SLANT_INDEX] = 2; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
4646 sort_shift_bits[FONT_WEIGHT_INDEX] = 9; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
4647 sort_shift_bits[FONT_SIZE_INDEX] = 16; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
4648 sort_shift_bits[FONT_WIDTH_INDEX] = 23; |
2a64ffbf0ec3
(font_score): Delete arg alternate_families. Check only
Kenichi Handa <handa@m17n.org>
parents:
95824
diff
changeset
|
4649 /* Note that the other elements in sort_shift_bits are not used. */ |
90400 | 4650 |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4651 staticpro (&font_charset_alist); |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4652 font_charset_alist = Qnil; |
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4653 |
94926 | 4654 DEFSYM (Qfont_spec, "font-spec"); |
4655 DEFSYM (Qfont_entity, "font-entity"); | |
4656 DEFSYM (Qfont_object, "font-object"); | |
4657 | |
90677
424dec0c7b5d
(Qopentype): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90640
diff
changeset
|
4658 DEFSYM (Qopentype, "opentype"); |
90400 | 4659 |
95699 | 4660 DEFSYM (Qascii_0, "ascii-0"); |
90439
fb253905e9c3
* font.c (Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved from
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
4661 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
|
4662 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
|
4663 DEFSYM (Qunicode_bmp, "unicode-bmp"); |
90622
bb9362e3a03b
(Qunicode_sip): New variable.
Kenichi Handa <handa@m17n.org>
parents:
90590
diff
changeset
|
4664 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
|
4665 |
90400 | 4666 DEFSYM (QCotf, ":otf"); |
94926 | 4667 DEFSYM (QClang, ":lang"); |
90400 | 4668 DEFSYM (QCscript, ":script"); |
91125
6c9a19ff6c55
(Qfontp): Remove unused symbol.
Jason Rumney <jasonr@gnu.org>
parents:
91112
diff
changeset
|
4669 DEFSYM (QCantialias, ":antialias"); |
90400 | 4670 |
4671 DEFSYM (QCfoundry, ":foundry"); | |
4672 DEFSYM (QCadstyle, ":adstyle"); | |
4673 DEFSYM (QCregistry, ":registry"); | |
90481
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
4674 DEFSYM (QCspacing, ":spacing"); |
93690200f520
(POINT_TO_PIXEL): Don't divice POINT by 10.
Kenichi Handa <handa@m17n.org>
parents:
90476
diff
changeset
|
4675 DEFSYM (QCdpi, ":dpi"); |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4676 DEFSYM (QCscalable, ":scalable"); |
94926 | 4677 DEFSYM (QCavgwidth, ":avgwidth"); |
4678 DEFSYM (QCfont_entity, ":font-entity"); | |
4679 DEFSYM (QCfc_unknown_spec, ":fc-unknown-spec"); | |
90400 | 4680 |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4681 DEFSYM (Qc, "c"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4682 DEFSYM (Qm, "m"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4683 DEFSYM (Qp, "p"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4684 DEFSYM (Qd, "d"); |
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4685 |
90400 | 4686 staticpro (&null_vector); |
4687 null_vector = Fmake_vector (make_number (0), Qnil); | |
4688 | |
4689 staticpro (&scratch_font_spec); | |
4690 scratch_font_spec = Ffont_spec (0, NULL); | |
4691 staticpro (&scratch_font_prefer); | |
4692 scratch_font_prefer = Ffont_spec (0, NULL); | |
4693 | |
95290
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
4694 #if 0 |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4695 #ifdef HAVE_LIBOTF |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4696 staticpro (&otf_list); |
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4697 otf_list = Qnil; |
95290
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
4698 #endif /* HAVE_LIBOTF */ |
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
4699 #endif /* 0 */ |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4700 |
90400 | 4701 defsubr (&Sfontp); |
4702 defsubr (&Sfont_spec); | |
4703 defsubr (&Sfont_get); | |
4704 defsubr (&Sfont_put); | |
4705 defsubr (&Slist_fonts); | |
94926 | 4706 defsubr (&Sfont_family_list); |
90400 | 4707 defsubr (&Sfind_font); |
4708 defsubr (&Sfont_xlfd_name); | |
4709 defsubr (&Sclear_font_cache); | |
4710 defsubr (&Sfont_make_gstring); | |
4711 defsubr (&Sfont_fill_gstring); | |
91135
49dbc35e3f99
* font.c [HAVE_M17N_FLT]: Include <m17n-flt.h>.
Kenichi Handa <handa@m17n.org>
parents:
91125
diff
changeset
|
4712 defsubr (&Sfont_shape_text); |
95290
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
4713 #if 0 |
90817
d2c230a67741
(struct otf_list): Delete it.
Kenichi Handa <handa@m17n.org>
parents:
90811
diff
changeset
|
4714 defsubr (&Sfont_drive_otf); |
90556
e56a86aa94cc
(font_otf_capability): Fix handling of the default
Kenichi Handa <handa@m17n.org>
parents:
90549
diff
changeset
|
4715 defsubr (&Sfont_otf_alternates); |
95290
e3e5f8759ca5
(LGSTRING_HEADER_SIZE, LGSTRING_GLYPH_SIZE)
Kenichi Handa <handa@m17n.org>
parents:
95225
diff
changeset
|
4716 #endif /* 0 */ |
90400 | 4717 |
4718 #ifdef FONT_DEBUG | |
4719 defsubr (&Sopen_font); | |
4720 defsubr (&Sclose_font); | |
4721 defsubr (&Squery_font); | |
4722 defsubr (&Sget_font_glyphs); | |
90503
8e3ffc0a529f
(QCscalable, Qc, Qm, Qp, Qd): New variables.
Kenichi Handa <handa@m17n.org>
parents:
90490
diff
changeset
|
4723 defsubr (&Sfont_match_p); |
90541 | 4724 defsubr (&Sfont_at); |
90400 | 4725 #if 0 |
4726 defsubr (&Sdraw_string); | |
4727 #endif | |
4728 #endif /* FONT_DEBUG */ | |
95421
3350c9ac1f37
(Ffont_info): Define only if HAVE_WINDOW_SYSTEM is
Kenichi Handa <handa@m17n.org>
parents:
95403
diff
changeset
|
4729 #ifdef HAVE_WINDOW_SYSTEM |
95403
26df7325a6ff
(font_style_to_value, font_score): Delete casting of the
Kenichi Handa <handa@m17n.org>
parents:
95359
diff
changeset
|
4730 defsubr (&Sfont_info); |
95421
3350c9ac1f37
(Ffont_info): Define only if HAVE_WINDOW_SYSTEM is
Kenichi Handa <handa@m17n.org>
parents:
95403
diff
changeset
|
4731 #endif |
90400 | 4732 |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4733 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist, |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4734 doc: /* |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4735 Alist of fontname patterns vs the corresponding encoding and repertory info. |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4736 Each element looks like (REGEXP . (ENCODING . REPERTORY)), |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4737 where ENCODING is a charset or a char-table, |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4738 and REPERTORY is a charset, a char-table, or nil. |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4739 |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
4740 If ENCODING and REPERTORY are the same, the element can have the form |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4741 \(REGEXP . ENCODING). |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4742 |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4743 ENCODING is for converting a character to a glyph code of the font. |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4744 If ENCODING is a charset, encoding a character by the charset gives |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4745 the corresponding glyph code. If ENCODING is a char-table, looking up |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4746 the table by a character gives the corresponding glyph code. |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4747 |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4748 REPERTORY specifies a repertory of characters supported by the font. |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4749 If REPERTORY is a charset, all characters beloging to the charset are |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4750 supported. If REPERTORY is a char-table, all characters who have a |
95142
f64ddc606a66
(syms-of-font) <font-encoding-alist>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95126
diff
changeset
|
4751 non-nil value in the table are supported. If REPERTORY is nil, Emacs |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4752 gets the repertory information by an opened font and ENCODING. */); |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4753 Vfont_encoding_alist = Qnil; |
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4754 |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4755 DEFVAR_LISP_NOPRO ("font-weight-table", &Vfont_weight_table, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4756 doc: /* Vector of valid font weight values. |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4757 Each element has the form: |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4758 [NUMERIC-VALUE SYMBOLIC-NAME ALIAS-NAME ...] |
95886
c8bc52f94b6d
(syms_of_font) <font-weight-table, font-slant-table, font-width-table>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95875
diff
changeset
|
4759 NUMERIC-VALUE is an integer, and SYMBOLIC-NAME and ALIAS-NAME are symbols. */); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4760 Vfont_weight_table = BUILD_STYLE_TABLE (weight_table); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4761 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4762 DEFVAR_LISP_NOPRO ("font-slant-table", &Vfont_slant_table, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4763 doc: /* Vector of font slant symbols vs the corresponding numeric values. |
95886
c8bc52f94b6d
(syms_of_font) <font-weight-table, font-slant-table, font-width-table>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95875
diff
changeset
|
4764 See `font-weight-table' for the format of the vector. */); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4765 Vfont_slant_table = BUILD_STYLE_TABLE (slant_table); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4766 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4767 DEFVAR_LISP_NOPRO ("font-width-table", &Vfont_width_table, |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4768 doc: /* Alist of font width symbols vs the corresponding numeric values. |
95886
c8bc52f94b6d
(syms_of_font) <font-weight-table, font-slant-table, font-width-table>:
Juanma Barranquero <lekktu@gmail.com>
parents:
95875
diff
changeset
|
4769 See `font-weight-table' for the format of the vector. */); |
95176
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4770 Vfont_width_table = BUILD_STYLE_TABLE (width_table); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4771 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4772 staticpro (&font_style_table); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4773 font_style_table = Fmake_vector (make_number (3), Qnil); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4774 ASET (font_style_table, 0, Vfont_weight_table); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4775 ASET (font_style_table, 1, Vfont_slant_table); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4776 ASET (font_style_table, 2, Vfont_width_table); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4777 |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4778 DEFVAR_LISP ("font-log", &Vfont_log, doc: /* |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4779 *Logging list of font related actions and results. |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4780 The value t means to suppress the logging. |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4781 The initial value is set to nil if the environment variable |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4782 EMACS_FONT_LOG is set. Otherwise, it is set to t. */); |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4783 Vfont_log = Qnil; |
686d116f748d
Checking of FONT_DEBUG is moved to font.h. All calls of
Kenichi Handa <handa@m17n.org>
parents:
95142
diff
changeset
|
4784 |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4785 #ifdef HAVE_WINDOW_SYSTEM |
90400 | 4786 #ifdef HAVE_FREETYPE |
94926 | 4787 syms_of_ftfont (); |
90400 | 4788 #ifdef HAVE_X_WINDOWS |
94926 | 4789 syms_of_xfont (); |
4790 syms_of_ftxfont (); | |
90400 | 4791 #ifdef HAVE_XFT |
94926 | 4792 syms_of_xftfont (); |
90400 | 4793 #endif /* HAVE_XFT */ |
4794 #endif /* HAVE_X_WINDOWS */ | |
4795 #else /* not HAVE_FREETYPE */ | |
4796 #ifdef HAVE_X_WINDOWS | |
94926 | 4797 syms_of_xfont (); |
90400 | 4798 #endif /* HAVE_X_WINDOWS */ |
4799 #endif /* not HAVE_FREETYPE */ | |
4800 #ifdef HAVE_BDFFONT | |
94926 | 4801 syms_of_bdffont (); |
90400 | 4802 #endif /* HAVE_BDFFONT */ |
4803 #ifdef WINDOWSNT | |
94926 | 4804 syms_of_w32font (); |
90400 | 4805 #endif /* WINDOWSNT */ |
4806 #ifdef MAC_OS | |
94926 | 4807 syms_of_atmfont (); |
90400 | 4808 #endif /* MAC_OS */ |
95126
b7cee987e982
(Vfont_encoding_alist, find_font_encoding): Moved from
Kenichi Handa <handa@m17n.org>
parents:
95104
diff
changeset
|
4809 #endif /* HAVE_WINDOW_SYSTEM */ |
90400 | 4810 } |
90427 | 4811 |
4812 /* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846 | |
4813 (do not change this comment) */ |