Mercurial > emacs
annotate src/xfont.c @ 94954:81ec00f72dc6
(setup-default-fontset): For kana, han,
hangul, and cjk-misc, move an entry with font-spec at the end.
(generate-fontset-menu): Exclue fontset-auto* from the list.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Wed, 14 May 2008 01:55:46 +0000 |
| parents | 061d44df20b7 |
| children | 8971ddf55736 |
| rev | line source |
|---|---|
| 90400 | 1 /* xfont.c -- X core font driver. |
|
91554
8d25c5588e59
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91270
diff
changeset
|
2 Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. |
|
8d25c5588e59
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91270
diff
changeset
|
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 | |
| 9 GNU Emacs is free software; you can redistribute it and/or modify | |
| 10 it under the terms of the GNU General Public License as published by | |
|
91554
8d25c5588e59
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91270
diff
changeset
|
11 the Free Software Foundation; either version 3, or (at your option) |
| 90400 | 12 any later version. |
| 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 | |
| 20 along with GNU Emacs; see the file COPYING. If not, write to | |
| 21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 22 Boston, MA 02110-1301, USA. */ | |
| 23 | |
| 24 #include <config.h> | |
| 25 #include <stdio.h> | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
26 #include <stdlib.h> |
| 90400 | 27 #include <X11/Xlib.h> |
| 28 | |
| 29 #include "lisp.h" | |
| 30 #include "dispextern.h" | |
| 31 #include "xterm.h" | |
| 32 #include "frame.h" | |
| 33 #include "blockinput.h" | |
| 34 #include "character.h" | |
| 35 #include "charset.h" | |
| 36 #include "fontset.h" | |
| 37 #include "font.h" | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
38 #include "ccl.h" |
| 90400 | 39 |
| 40 | |
| 41 /* X core font driver. */ | |
| 42 | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
43 struct xfont_info |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
44 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
45 struct font font; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
46 Display *display; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
47 XFontStruct *xfont; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
48 }; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
49 |
| 90400 | 50 /* Prototypes of support functions. */ |
| 51 extern void x_clear_errors P_ ((Display *)); | |
| 52 | |
| 53 static XCharStruct *xfont_get_pcm P_ ((XFontStruct *, XChar2b *)); | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
54 static void xfont_find_ccl_program P_ ((struct font *)); |
| 90400 | 55 static int xfont_registry_charsets P_ ((Lisp_Object, struct charset **, |
| 56 struct charset **)); | |
| 57 | |
| 58 | |
| 59 /* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B | |
| 60 is not contained in the font. */ | |
| 61 | |
| 62 static XCharStruct * | |
| 63 xfont_get_pcm (xfont, char2b) | |
| 64 XFontStruct *xfont; | |
| 65 XChar2b *char2b; | |
| 66 { | |
| 67 /* The result metric information. */ | |
| 68 XCharStruct *pcm = NULL; | |
| 69 | |
| 70 xassert (xfont && char2b); | |
| 71 | |
| 72 if (xfont->per_char != NULL) | |
| 73 { | |
| 74 if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) | |
| 75 { | |
| 76 /* min_char_or_byte2 specifies the linear character index | |
| 77 corresponding to the first element of the per_char array, | |
| 78 max_char_or_byte2 is the index of the last character. A | |
| 79 character with non-zero CHAR2B->byte1 is not in the font. | |
| 80 A character with byte2 less than min_char_or_byte2 or | |
| 81 greater max_char_or_byte2 is not in the font. */ | |
| 82 if (char2b->byte1 == 0 | |
| 83 && char2b->byte2 >= xfont->min_char_or_byte2 | |
| 84 && char2b->byte2 <= xfont->max_char_or_byte2) | |
| 85 pcm = xfont->per_char + char2b->byte2 - xfont->min_char_or_byte2; | |
| 86 } | |
| 87 else | |
| 88 { | |
| 89 /* If either min_byte1 or max_byte1 are nonzero, both | |
| 90 min_char_or_byte2 and max_char_or_byte2 are less than | |
| 91 256, and the 2-byte character index values corresponding | |
| 92 to the per_char array element N (counting from 0) are: | |
| 93 | |
| 94 byte1 = N/D + min_byte1 | |
| 95 byte2 = N\D + min_char_or_byte2 | |
| 96 | |
| 97 where: | |
| 98 | |
| 99 D = max_char_or_byte2 - min_char_or_byte2 + 1 | |
| 100 / = integer division | |
| 101 \ = integer modulus */ | |
| 102 if (char2b->byte1 >= xfont->min_byte1 | |
| 103 && char2b->byte1 <= xfont->max_byte1 | |
| 104 && char2b->byte2 >= xfont->min_char_or_byte2 | |
| 105 && char2b->byte2 <= xfont->max_char_or_byte2) | |
| 106 pcm = (xfont->per_char | |
| 107 + ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1) | |
| 108 * (char2b->byte1 - xfont->min_byte1)) | |
| 109 + (char2b->byte2 - xfont->min_char_or_byte2)); | |
| 110 } | |
| 111 } | |
| 112 else | |
| 113 { | |
| 114 /* If the per_char pointer is null, all glyphs between the first | |
| 115 and last character indexes inclusive have the same | |
| 116 information, as given by both min_bounds and max_bounds. */ | |
| 117 if (char2b->byte2 >= xfont->min_char_or_byte2 | |
| 118 && char2b->byte2 <= xfont->max_char_or_byte2) | |
| 119 pcm = &xfont->max_bounds; | |
| 120 } | |
| 121 | |
| 122 return ((pcm == NULL | |
| 123 || (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0)) | |
| 124 ? NULL : pcm); | |
| 125 } | |
| 126 | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
127 /* Find a CCL program for a font specified by FONTP, and set the member |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
128 `encoder' of the structure. */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
129 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
130 static void |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
131 xfont_find_ccl_program (font) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
132 struct font *font; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
133 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
134 Lisp_Object list, elt; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
135 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
136 elt = Qnil; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
137 for (list = Vfont_ccl_encoder_alist; CONSP (list); list = XCDR (list)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
138 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
139 elt = XCAR (list); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
140 if (CONSP (elt) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
141 && STRINGP (XCAR (elt)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
142 && ((fast_string_match_ignore_case (XCAR (elt), |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
143 font->props[FONT_NAME_INDEX]) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
144 >= 0) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
145 || (fast_string_match_ignore_case (XCAR (elt), |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
146 font->props[FONT_FULLNAME_INDEX]) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
147 >= 0))) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
148 break; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
149 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
150 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
151 if (! NILP (list)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
152 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
153 struct ccl_program *ccl |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
154 = (struct ccl_program *) xmalloc (sizeof (struct ccl_program)); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
155 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
156 if (setup_ccl_program (ccl, XCDR (elt)) < 0) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
157 xfree (ccl); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
158 else |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
159 font->font_encoder = ccl; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
160 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
161 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
162 |
|
91245
26541bdcecd0
(xfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91177
diff
changeset
|
163 static Lisp_Object xfont_get_cache P_ ((FRAME_PTR)); |
| 90400 | 164 static Lisp_Object xfont_list P_ ((Lisp_Object, Lisp_Object)); |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
165 static Lisp_Object xfont_match P_ ((Lisp_Object, Lisp_Object)); |
| 90400 | 166 static Lisp_Object xfont_list_family P_ ((Lisp_Object)); |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
167 static Lisp_Object xfont_open P_ ((FRAME_PTR, Lisp_Object, int)); |
| 90400 | 168 static void xfont_close P_ ((FRAME_PTR, struct font *)); |
| 169 static int xfont_prepare_face P_ ((FRAME_PTR, struct face *)); | |
| 170 static int xfont_has_char P_ ((Lisp_Object, int)); | |
| 171 static unsigned xfont_encode_char P_ ((struct font *, int)); | |
| 172 static int xfont_text_extents P_ ((struct font *, unsigned *, int, | |
| 173 struct font_metrics *)); | |
| 174 static int xfont_draw P_ ((struct glyph_string *, int, int, int, int, int)); | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
175 static int xfont_check P_ ((FRAME_PTR, struct font *)); |
| 90400 | 176 |
| 177 struct font_driver xfont_driver = | |
| 178 { | |
|
90698
a31984e21969
(xfont_driver): Initialize ftfont_driver.type by 0.
Kenichi Handa <handa@m17n.org>
parents:
90679
diff
changeset
|
179 0, /* Qx */ |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
180 0, /* case insensitive */ |
| 90400 | 181 xfont_get_cache, |
| 182 xfont_list, | |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
183 xfont_match, |
| 90400 | 184 xfont_list_family, |
| 185 NULL, | |
| 186 xfont_open, | |
| 187 xfont_close, | |
| 188 xfont_prepare_face, | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
189 NULL, |
| 90400 | 190 xfont_has_char, |
| 191 xfont_encode_char, | |
| 192 xfont_text_extents, | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
193 xfont_draw, |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
194 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
195 xfont_check |
| 90400 | 196 }; |
| 197 | |
| 198 extern Lisp_Object QCname; | |
| 199 | |
| 200 static Lisp_Object | |
|
91245
26541bdcecd0
(xfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91177
diff
changeset
|
201 xfont_get_cache (f) |
|
26541bdcecd0
(xfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91177
diff
changeset
|
202 FRAME_PTR f; |
| 90400 | 203 { |
|
91245
26541bdcecd0
(xfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91177
diff
changeset
|
204 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
| 90400 | 205 |
| 206 return (dpyinfo->name_list_element); | |
| 207 } | |
| 208 | |
| 209 extern Lisp_Object Vface_alternative_font_registry_alist; | |
| 210 | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
211 static int |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
212 compare_font_names (const void *name1, const void *name2) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
213 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
214 return strcasecmp (*(const char **) name1, *(const char **) name2); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
215 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
216 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
217 static Lisp_Object xfont_list_pattern P_ ((Lisp_Object, Display *, char *)); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
218 |
| 90400 | 219 static Lisp_Object |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
220 xfont_list_pattern (frame, display, pattern) |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
221 Lisp_Object frame; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
222 Display *display; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
223 char *pattern; |
| 90400 | 224 { |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
225 Lisp_Object list = Qnil; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
226 int i, limit, num_fonts; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
227 char **names; |
| 90400 | 228 |
| 229 BLOCK_INPUT; | |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
230 x_catch_errors (display); |
| 90400 | 231 |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
232 for (limit = 512; ; limit *= 2) |
| 90400 | 233 { |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
234 names = XListFonts (display, pattern, limit, &num_fonts); |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
235 if (x_had_errors_p (display)) |
| 90400 | 236 { |
| 237 /* This error is perhaps due to insufficient memory on X | |
| 238 server. Let's just ignore it. */ | |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
239 x_clear_errors (display); |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
240 num_fonts = 0; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
241 break; |
| 90400 | 242 } |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
243 if (num_fonts < limit) |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
244 break; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
245 XFreeFontNames (names); |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
246 } |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
247 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
248 if (num_fonts > 0) |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
249 { |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
250 char **indices = alloca (sizeof (char *) * num_fonts); |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
251 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
252 for (i = 0; i < num_fonts; i++) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
253 indices[i] = names[i]; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
254 qsort (indices, num_fonts, sizeof (char *), compare_font_names); |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
255 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
256 for (i = 0; i < num_fonts; i++) |
| 90400 | 257 { |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
258 Lisp_Object entity; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
259 int result; |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
260 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
261 if (i > 0 && strcasecmp (indices[i - 1], indices[i]) == 0) |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
262 continue; |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
263 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
264 entity = font_make_entity (); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
265 ASET (entity, FONT_TYPE_INDEX, Qx); |
| 90400 | 266 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
267 result = font_parse_xlfd (indices[i], entity); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
268 if (result < 0) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
269 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
270 /* This may be an alias name. Try to get the full XLFD name |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
271 from XA_FONT property of the font. */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
272 XFontStruct *font = XLoadQueryFont (display, indices[i]); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
273 unsigned long value; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
274 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
275 if (! font) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
276 continue; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
277 if (XGetFontProperty (font, XA_FONT, &value)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
278 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
279 char *name = (char *) XGetAtomName (display, (Atom) value); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
280 int len = strlen (name); |
| 90400 | 281 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
282 /* If DXPC (a Differential X Protocol Compressor) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
283 Ver.3.7 is running, XGetAtomName will return null |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
284 string. We must avoid such a name. */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
285 if (len > 0) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
286 result = font_parse_xlfd (name, entity); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
287 XFree (name); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
288 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
289 XFreeFont (display, font); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
290 } |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
291 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
292 if (result == 0 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
293 /* Avoid auto-scaled fonts. */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
294 && (XINT (AREF (entity, FONT_DPI_INDEX)) == 0 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
295 || XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) > 0)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
296 list = Fcons (entity, list); |
| 90400 | 297 } |
| 298 } | |
| 299 | |
| 300 x_uncatch_errors (); | |
| 301 UNBLOCK_INPUT; | |
| 302 | |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
303 return list; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
304 } |
| 90400 | 305 |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
306 static Lisp_Object |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
307 xfont_list (frame, spec) |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
308 Lisp_Object frame, spec; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
309 { |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
310 FRAME_PTR f = XFRAME (frame); |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
311 Display *display = FRAME_X_DISPLAY_INFO (f)->display; |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
312 Lisp_Object registry, list, val, extra, font_name; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
313 Lisp_Object dpi, avgwidth; |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
314 int len; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
315 char name[256]; |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
316 |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
317 extra = AREF (spec, FONT_EXTRA_INDEX); |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
318 if (CONSP (extra)) |
| 90400 | 319 { |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
320 val = assq_no_quit (QCotf, extra); |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
321 if (! NILP (val)) |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
322 return Qnil; |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
323 val = assq_no_quit (QCscript, extra); |
|
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
324 if (! NILP (val)) |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
325 return Qnil; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
326 val = assq_no_quit (QClang, extra); |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
327 if (! NILP (val)) |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
328 return Qnil; |
| 90400 | 329 } |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
330 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
331 registry = AREF (spec, FONT_REGISTRY_INDEX); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
332 if (NILP (registry)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
333 ASET (spec, FONT_REGISTRY_INDEX, Qiso8859_1); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
334 len = font_unparse_xlfd (spec, 0, name, 256); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
335 ASET (spec, FONT_REGISTRY_INDEX, registry); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
336 if (len < 0) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
337 return Qnil; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
338 list = xfont_list_pattern (frame, display, name); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
339 if (NILP (list) && NILP (registry)) |
| 90400 | 340 { |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
341 /* Try iso10646-1 */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
342 char *r = name + len - 9; /* 9 == strlen (iso8859-1) */ |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
343 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
344 if (r - name + 10 < 256) /* 10 == strlen (iso10646-1) */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
345 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
346 strcpy (r, "iso10646-1"); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
347 list = xfont_list_pattern (frame, display, name); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
348 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
349 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
350 if (NILP (list) && ! NILP (registry)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
351 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
352 Lisp_Object alter; |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
353 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
354 if ((alter = Fassoc (SYMBOL_NAME (registry), |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
355 Vface_alternative_font_registry_alist), |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
356 CONSP (alter))) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
357 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
358 /* Pointer to REGISTRY-ENCODING field. */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
359 char *r = name + len - SBYTES (SYMBOL_NAME (registry)); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
360 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
361 for (alter = XCDR (alter); CONSP (alter); alter = XCDR (alter)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
362 if (STRINGP (XCAR (alter)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
363 && ((r - name) + SBYTES (XCAR (alter))) < 256) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
364 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
365 strcpy (r, (char *) SDATA (XCAR (alter))); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
366 list = xfont_list_pattern (frame, display, name); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
367 if (! NILP (list)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
368 break; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
369 } |
|
90501
2ef165ebcc7d
(xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents:
90461
diff
changeset
|
370 } |
| 90400 | 371 } |
| 372 | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
373 return list; |
| 90400 | 374 } |
| 375 | |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
376 static Lisp_Object |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
377 xfont_match (frame, spec) |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
378 Lisp_Object frame, spec; |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
379 { |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
380 FRAME_PTR f = XFRAME (frame); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
381 Display *display = FRAME_X_DISPLAY_INFO (f)->display; |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
382 Lisp_Object extra, val, entity; |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
383 char buf[256], *name; |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
384 XFontStruct *xfont; |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
385 unsigned long value; |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
386 |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
387 extra = AREF (spec, FONT_EXTRA_INDEX); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
388 val = assq_no_quit (QCname, extra); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
389 if (! CONSP (val) || ! STRINGP (XCDR (val))) |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
390 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
391 if (font_unparse_xlfd (spec, 0, buf, 256) < 0) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
392 return Qnil; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
393 name = buf; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
394 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
395 else |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
396 name = (char *) SDATA (XCDR (val)); |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
397 |
|
90569
0af2dbdeaeb3
(xfont_match): Block and unblock input while callin Xlib.
Kenichi Handa <handa@m17n.org>
parents:
90561
diff
changeset
|
398 BLOCK_INPUT; |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
399 entity = Qnil; |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
400 xfont = XLoadQueryFont (display, name); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
401 if (xfont) |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
402 { |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
403 if (XGetFontProperty (xfont, XA_FONT, &value)) |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
404 { |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
405 int len; |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
406 |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
407 name = (char *) XGetAtomName (display, (Atom) value); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
408 len = strlen (name); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
409 |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
410 /* If DXPC (a Differential X Protocol Compressor) |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
411 Ver.3.7 is running, XGetAtomName will return null |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
412 string. We must avoid such a name. */ |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
413 if (len > 0) |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
414 { |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
415 entity = font_make_entity (); |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
416 ASET (entity, FONT_TYPE_INDEX, Qx); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
417 if (font_parse_xlfd (name, entity) < 0) |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
418 entity = Qnil; |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
419 } |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
420 XFree (name); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
421 } |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
422 XFreeFont (display, xfont); |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
423 } |
|
90569
0af2dbdeaeb3
(xfont_match): Block and unblock input while callin Xlib.
Kenichi Handa <handa@m17n.org>
parents:
90561
diff
changeset
|
424 UNBLOCK_INPUT; |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
425 |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
426 return entity; |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
427 } |
|
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
428 |
| 90400 | 429 static int |
| 430 memq_no_quit (elt, list) | |
| 431 Lisp_Object elt, list; | |
| 432 { | |
| 433 while (CONSP (list) && ! EQ (XCAR (list), elt)) | |
| 434 list = XCDR (list); | |
| 435 return (CONSP (list)); | |
| 436 } | |
| 437 | |
| 438 static Lisp_Object | |
| 439 xfont_list_family (frame) | |
|
90443
57b847825c30
(xfont_list): If script is specified for a font, return
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
440 Lisp_Object frame; |
| 90400 | 441 { |
| 442 FRAME_PTR f = XFRAME (frame); | |
| 443 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | |
| 444 char **names; | |
| 445 int num_fonts, i; | |
| 446 Lisp_Object list; | |
| 447 char *last_family; | |
| 448 int last_len; | |
| 449 | |
| 450 BLOCK_INPUT; | |
| 451 x_catch_errors (dpyinfo->display); | |
| 452 names = XListFonts (dpyinfo->display, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*", | |
| 453 0x8000, &num_fonts); | |
| 454 if (x_had_errors_p (dpyinfo->display)) | |
| 455 { | |
| 456 /* This error is perhaps due to insufficient memory on X server. | |
| 457 Let's just ignore it. */ | |
| 458 x_clear_errors (dpyinfo->display); | |
| 459 num_fonts = 0; | |
| 460 } | |
| 461 | |
| 462 list = Qnil; | |
| 463 for (i = 0, last_len = 0; i < num_fonts; i++) | |
| 464 { | |
| 465 char *p0 = names[i], *p1; | |
| 466 Lisp_Object family; | |
| 467 | |
| 468 p0++; /* skip the leading '-' */ | |
| 469 while (*p0 && *p0 != '-') p0++; /* skip foundry */ | |
| 470 if (! *p0) | |
| 471 continue; | |
| 472 p1 = ++p0; | |
| 473 while (*p1 && *p1 != '-') p1++; /* find the end of family */ | |
| 474 if (! *p1 || p1 == p0) | |
| 475 continue; | |
| 476 if (last_len == p1 - p0 | |
| 477 && bcmp (last_family, p0, last_len) == 0) | |
| 478 continue; | |
| 479 last_len = p1 - p0; | |
| 480 last_family = p0; | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
481 family = make_unibyte_string (p0, last_len); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
482 if (NILP (Fassoc_string (family, list, Qt))) |
| 90400 | 483 list = Fcons (family, list); |
| 484 } | |
| 485 | |
| 486 XFreeFontNames (names); | |
| 487 x_uncatch_errors (); | |
| 488 UNBLOCK_INPUT; | |
| 489 | |
| 490 return list; | |
| 491 } | |
| 492 | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
493 extern Lisp_Object QCavgwidth; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
494 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
495 static Lisp_Object |
| 90400 | 496 xfont_open (f, entity, pixel_size) |
| 497 FRAME_PTR f; | |
| 498 Lisp_Object entity; | |
| 499 int pixel_size; | |
| 500 { | |
| 501 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | |
| 502 Display *display = dpyinfo->display; | |
| 503 char name[256]; | |
| 504 int len; | |
| 505 unsigned long value; | |
| 506 Lisp_Object registry; | |
| 507 struct charset *encoding, *repertory; | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
508 Lisp_Object font_object, fullname; |
| 90400 | 509 struct font *font; |
| 510 XFontStruct *xfont; | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
511 int i; |
| 90400 | 512 |
| 513 /* At first, check if we know how to encode characters for this | |
| 514 font. */ | |
| 515 registry = AREF (entity, FONT_REGISTRY_INDEX); | |
|
91142
4bcf0716ddf4
* xfont.c (x_font_charset_alist): Moved to font.c and renamed.
Kenichi Handa <handa@m17n.org>
parents:
90698
diff
changeset
|
516 if (font_registry_charsets (registry, &encoding, &repertory) < 0) |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
517 return Qnil; |
| 90400 | 518 |
| 519 if (XINT (AREF (entity, FONT_SIZE_INDEX)) != 0) | |
| 520 pixel_size = XINT (AREF (entity, FONT_SIZE_INDEX)); | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
521 else if (pixel_size == 0) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
522 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
523 if (FRAME_FONT (f)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
524 pixel_size = FRAME_FONT (f)->pixel_size; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
525 else |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
526 pixel_size = 14; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
527 } |
| 90400 | 528 len = font_unparse_xlfd (entity, pixel_size, name, 256); |
| 529 if (len <= 0) | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
530 return Qnil; |
| 90400 | 531 |
| 532 BLOCK_INPUT; | |
| 533 x_catch_errors (display); | |
| 534 xfont = XLoadQueryFont (display, name); | |
| 535 if (x_had_errors_p (display)) | |
| 536 { | |
| 537 /* This error is perhaps due to insufficient memory on X server. | |
| 538 Let's just ignore it. */ | |
| 539 x_clear_errors (display); | |
| 540 xfont = NULL; | |
| 541 } | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
542 fullname = Qnil; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
543 /* Try to get the full name of FONT. */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
544 if (xfont && XGetFontProperty (xfont, XA_FONT, &value)) |
| 90400 | 545 { |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
546 char *p0, *p; |
| 90400 | 547 int dashes = 0; |
| 548 | |
| 549 p0 = p = (char *) XGetAtomName (FRAME_X_DISPLAY (f), (Atom) value);; | |
| 550 /* Count the number of dashes in the "full name". | |
| 551 If it is too few, this isn't really the font's full name, | |
| 552 so don't use it. | |
| 553 In X11R4, the fonts did not come with their canonical names | |
| 554 stored in them. */ | |
| 555 while (*p) | |
| 556 { | |
| 557 if (*p == '-') | |
| 558 dashes++; | |
| 559 p++; | |
| 560 } | |
| 561 | |
| 562 if (dashes >= 13) | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
563 fullname = Fdowncase (make_unibyte_string (p0, p - p0)); |
| 90400 | 564 XFree (p0); |
| 565 } | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
566 x_uncatch_errors (); |
| 90400 | 567 UNBLOCK_INPUT; |
| 568 | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
569 if (! xfont) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
570 return Qnil; |
| 90400 | 571 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
572 font_object = font_make_object (VECSIZE (struct xfont_info)); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
573 ASET (font_object, FONT_TYPE_INDEX, Qx); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
574 if (STRINGP (fullname)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
575 font_parse_xlfd (SDATA (fullname), font_object); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
576 for (i = 1; i < FONT_ENTITY_MAX; i++) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
577 ASET (font_object, i, AREF (entity, i)); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
578 ASET (font_object, FONT_SIZE_INDEX, make_number (pixel_size)); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
579 if (STRINGP (fullname)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
580 ASET (font_object, FONT_NAME_INDEX, fullname); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
581 else |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
582 ASET (font_object, FONT_NAME_INDEX, make_unibyte_string (name, len)); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
583 ASET (font_object, FONT_FULLNAME_INDEX, fullname); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
584 ASET (font_object, FONT_FILE_INDEX, Qnil); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
585 ASET (font_object, FONT_FORMAT_INDEX, Qx); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
586 font = XFONT_OBJECT (font_object); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
587 ((struct xfont_info *) font)->xfont = xfont; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
588 ((struct xfont_info *) font)->display = FRAME_X_DISPLAY (f); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
589 font->pixel_size = pixel_size; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
590 font->driver = &xfont_driver; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
591 font->encoding_charset = encoding->id; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
592 font->repertory_charset = repertory ? repertory->id : -1; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
593 font->ascent = xfont->ascent; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
594 font->descent = xfont->descent; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
595 font->height = font->ascent + font->descent; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
596 font->min_width = xfont->min_bounds.width; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
597 if (xfont->min_bounds.width == xfont->max_bounds.width) |
| 90400 | 598 { |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
599 /* Fixed width font. */ |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
600 font->average_width = font->space_width = xfont->min_bounds.width; |
| 90400 | 601 } |
| 602 else | |
| 603 { | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
604 XCharStruct *pcm; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
605 XChar2b char2b; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
606 Lisp_Object val; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
607 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
608 char2b.byte1 = 0x00, char2b.byte2 = 0x20; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
609 pcm = xfont_get_pcm (xfont, &char2b); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
610 if (pcm) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
611 font->space_width = pcm->width; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
612 else |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
613 font->space_width = 0; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
614 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
615 val = Ffont_get (font_object, QCavgwidth); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
616 if (INTEGERP (val)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
617 font->average_width = XINT (val); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
618 if (font->average_width < 0) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
619 font->average_width = - font->average_width; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
620 if (font->average_width == 0 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
621 && encoding->ascii_compatible_p) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
622 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
623 int width = font->space_width, n = pcm != NULL; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
624 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
625 for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
626 if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
627 width += pcm->width, n++; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
628 font->average_width = width / n; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
629 } |
| 90400 | 630 } |
| 631 | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
632 BLOCK_INPUT; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
633 font->underline_thickness |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
634 = (XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &value) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
635 ? (long) value : 0); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
636 font->underline_position |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
637 = (XGetFontProperty (xfont, XA_UNDERLINE_POSITION, &value) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
638 ? (long) value : -1); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
639 font->baseline_offset |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
640 = (XGetFontProperty (xfont, dpyinfo->Xatom_MULE_BASELINE_OFFSET, &value) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
641 ? (long) value : 0); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
642 font->relative_compose |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
643 = (XGetFontProperty (xfont, dpyinfo->Xatom_MULE_RELATIVE_COMPOSE, &value) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
644 ? (long) value : 0); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
645 font->default_ascent |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
646 = (XGetFontProperty (xfont, dpyinfo->Xatom_MULE_DEFAULT_ASCENT, &value) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
647 ? (long) value : 0); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
648 UNBLOCK_INPUT; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
649 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
650 if (NILP (fullname)) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
651 fullname = AREF (font_object, FONT_NAME_INDEX); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
652 font->vertical_centering |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
653 = (STRINGP (Vvertical_centering_font_regexp) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
654 && (fast_string_match_ignore_case |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
655 (Vvertical_centering_font_regexp, fullname) >= 0)); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
656 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
657 return font_object; |
| 90400 | 658 } |
| 659 | |
| 660 static void | |
| 661 xfont_close (f, font) | |
| 662 FRAME_PTR f; | |
| 663 struct font *font; | |
| 664 { | |
| 665 BLOCK_INPUT; | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
666 XFreeFont (FRAME_X_DISPLAY (f), ((struct xfont_info *) font)->xfont); |
| 90400 | 667 UNBLOCK_INPUT; |
| 668 } | |
| 669 | |
| 670 static int | |
| 671 xfont_prepare_face (f, face) | |
| 672 FRAME_PTR f; | |
| 673 struct face *face; | |
| 674 { | |
| 675 BLOCK_INPUT; | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
676 XSetFont (FRAME_X_DISPLAY (f), face->gc, |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
677 ((struct xfont_info *) face->font)->xfont->fid); |
| 90400 | 678 UNBLOCK_INPUT; |
| 679 | |
| 680 return 0; | |
| 681 } | |
| 682 | |
| 683 static int | |
| 684 xfont_has_char (entity, c) | |
| 685 Lisp_Object entity; | |
| 686 int c; | |
| 687 { | |
| 688 Lisp_Object registry = AREF (entity, FONT_REGISTRY_INDEX); | |
| 689 struct charset *repertory; | |
| 690 | |
|
91142
4bcf0716ddf4
* xfont.c (x_font_charset_alist): Moved to font.c and renamed.
Kenichi Handa <handa@m17n.org>
parents:
90698
diff
changeset
|
691 if (font_registry_charsets (registry, NULL, &repertory) < 0) |
| 90400 | 692 return -1; |
| 693 if (! repertory) | |
| 694 return -1; | |
| 695 return (ENCODE_CHAR (repertory, c) != CHARSET_INVALID_CODE (repertory)); | |
| 696 } | |
| 697 | |
| 698 static unsigned | |
| 699 xfont_encode_char (font, c) | |
| 700 struct font *font; | |
| 701 int c; | |
| 702 { | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
703 XFontStruct *xfont = ((struct xfont_info *) font)->xfont; |
| 90400 | 704 struct charset *charset; |
| 705 unsigned code; | |
| 706 XChar2b char2b; | |
| 707 | |
| 708 charset = CHARSET_FROM_ID (font->encoding_charset); | |
| 709 code = ENCODE_CHAR (charset, c); | |
| 710 if (code == CHARSET_INVALID_CODE (charset)) | |
|
91270
0dab56b22dca
(xfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91245
diff
changeset
|
711 return FONT_INVALID_CODE; |
|
90454
a8b745412821
(xfont_open, xfont_encode_char): Fix typo.
Kenichi Handa <handa@m17n.org>
parents:
90443
diff
changeset
|
712 if (font->repertory_charset >= 0) |
| 90400 | 713 { |
|
90454
a8b745412821
(xfont_open, xfont_encode_char): Fix typo.
Kenichi Handa <handa@m17n.org>
parents:
90443
diff
changeset
|
714 charset = CHARSET_FROM_ID (font->repertory_charset); |
| 90400 | 715 return (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset) |
|
91270
0dab56b22dca
(xfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91245
diff
changeset
|
716 ? code : FONT_INVALID_CODE); |
| 90400 | 717 } |
|
90425
5976e428d68e
(xfont_encode_char): Fix calculation of char2b.
Kenichi Handa <handa@m17n.org>
parents:
90400
diff
changeset
|
718 char2b.byte1 = code >> 8; |
|
5976e428d68e
(xfont_encode_char): Fix calculation of char2b.
Kenichi Handa <handa@m17n.org>
parents:
90400
diff
changeset
|
719 char2b.byte2 = code & 0xFF; |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
720 return (xfont_get_pcm (xfont, &char2b) ? code : FONT_INVALID_CODE); |
| 90400 | 721 } |
| 722 | |
| 723 static int | |
| 724 xfont_text_extents (font, code, nglyphs, metrics) | |
| 725 struct font *font; | |
| 726 unsigned *code; | |
| 727 int nglyphs; | |
| 728 struct font_metrics *metrics; | |
| 729 { | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
730 XFontStruct *xfont = ((struct xfont_info *) font)->xfont; |
| 90400 | 731 int width = 0; |
| 732 int i, x; | |
| 733 | |
| 734 if (metrics) | |
| 735 bzero (metrics, sizeof (struct font_metrics)); | |
| 736 for (i = 0, x = 0; i < nglyphs; i++) | |
| 737 { | |
| 738 XChar2b char2b; | |
| 739 static XCharStruct *pcm; | |
| 740 | |
| 741 if (code[i] >= 0x10000) | |
| 742 continue; | |
| 743 char2b.byte1 = code[i] >> 8, char2b.byte2 = code[i] & 0xFF; | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
744 pcm = xfont_get_pcm (xfont, &char2b); |
| 90400 | 745 if (! pcm) |
| 746 continue; | |
| 747 if (metrics->lbearing > width + pcm->lbearing) | |
| 748 metrics->lbearing = width + pcm->lbearing; | |
| 749 if (metrics->rbearing < width + pcm->rbearing) | |
| 750 metrics->rbearing = width + pcm->rbearing; | |
| 751 if (metrics->ascent < pcm->ascent) | |
| 752 metrics->ascent = pcm->ascent; | |
| 753 if (metrics->descent < pcm->descent) | |
| 754 metrics->descent = pcm->descent; | |
| 755 width += pcm->width; | |
| 756 } | |
| 757 if (metrics) | |
| 758 metrics->width = width; | |
| 759 return width; | |
| 760 } | |
| 761 | |
| 762 static int | |
| 763 xfont_draw (s, from, to, x, y, with_background) | |
| 764 struct glyph_string *s; | |
| 765 int from, to, x, y, with_background; | |
| 766 { | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
767 XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont; |
| 90400 | 768 int len = to - from; |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
769 GC gc = s->gc; |
|
92185
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
770 int i; |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
771 |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
772 if (s->gc != s->face->gc) |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
773 { |
|
91905
6ae79e72fea7
(xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents:
91554
diff
changeset
|
774 BLOCK_INPUT; |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
775 XSetFont (s->display, gc, xfont->fid); |
|
91905
6ae79e72fea7
(xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents:
91554
diff
changeset
|
776 UNBLOCK_INPUT; |
|
90561
73750c4e078a
(xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90545
diff
changeset
|
777 } |
| 90400 | 778 |
| 779 if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0) | |
| 780 { | |
| 781 char *str; | |
| 782 USE_SAFE_ALLOCA; | |
| 783 | |
| 784 SAFE_ALLOCA (str, char *, len); | |
| 785 for (i = 0; i < len ; i++) | |
| 786 str[i] = XCHAR2B_BYTE2 (s->char2b + from + i); | |
|
91905
6ae79e72fea7
(xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents:
91554
diff
changeset
|
787 BLOCK_INPUT; |
| 90400 | 788 if (with_background > 0) |
|
92185
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
789 { |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
790 if (s->padding_p) |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
791 for (i = 0; i < len; i++) |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
792 XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
793 gc, x + i, y, str + i, 1); |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
794 else |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
795 XDrawImageString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
796 gc, x, y, str, len); |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
797 } |
| 90400 | 798 else |
|
92185
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
799 { |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
800 if (s->padding_p) |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
801 for (i = 0; i < len; i++) |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
802 XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
803 gc, x + i, y, str + i, 1); |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
804 else |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
805 XDrawString (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
806 gc, x, y, str, len); |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
807 } |
|
91905
6ae79e72fea7
(xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents:
91554
diff
changeset
|
808 UNBLOCK_INPUT; |
| 90400 | 809 SAFE_FREE (); |
| 810 return s->nchars; | |
| 811 } | |
| 812 | |
|
91905
6ae79e72fea7
(xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents:
91554
diff
changeset
|
813 BLOCK_INPUT; |
| 90400 | 814 if (with_background > 0) |
|
92185
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
815 { |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
816 if (s->padding_p) |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
817 for (i = 0; i < len; i++) |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
818 XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
819 gc, x + i, y, s->char2b + from + i, 1); |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
820 else |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
821 XDrawImageString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
822 gc, x, y, s->char2b + from, len); |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
823 } |
| 90400 | 824 else |
|
92185
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
825 { |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
826 if (s->padding_p) |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
827 for (i = 0; i < len; i++) |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
828 XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
829 gc, x + i, y, s->char2b + from + i, 1); |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
830 else |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
831 XDrawString16 (FRAME_X_DISPLAY (s->f), FRAME_X_WINDOW (s->f), |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
832 gc, x, y, s->char2b + from, len); |
|
1e28008a13e5
(xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91905
diff
changeset
|
833 } |
|
91905
6ae79e72fea7
(xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents:
91554
diff
changeset
|
834 UNBLOCK_INPUT; |
| 90400 | 835 |
| 836 return len; | |
| 837 } | |
| 838 | |
|
94940
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
839 static int |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
840 xfont_check (f, font) |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
841 FRAME_PTR f; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
842 struct font *font; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
843 { |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
844 struct xfont_info *xfont = (struct xfont_info *) font; |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
845 |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
846 return (FRAME_X_DISPLAY (f) == xfont->display ? 0 : -1); |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
847 } |
|
061d44df20b7
Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents:
92185
diff
changeset
|
848 |
| 90400 | 849 |
| 850 void | |
| 851 syms_of_xfont () | |
| 852 { | |
| 853 xfont_driver.type = Qx; | |
| 854 register_font_driver (&xfont_driver, NULL); | |
| 855 } | |
| 90427 | 856 |
| 857 /* arch-tag: 23c5f366-a5ee-44b7-a3b7-90d6da7fd749 | |
| 858 (do not change this comment) */ |
