annotate src/xfont.c @ 102061:cd6c733e7e27

Comment.
author Glenn Morris <rgm@gnu.org>
date Tue, 17 Feb 2009 02:32:34 +0000
parents 97c9e9322753
children b20a4659fd91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 /* xfont.c -- X core font driver.
100951
e038c1a8307c Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100553
diff changeset
2 Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
e038c1a8307c Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100553
diff changeset
3 Copyright (C) 2006, 2007, 2008, 2009
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 National Institute of Advanced Industrial Science and Technology (AIST)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 Registration Number H13PRO009
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 This file is part of GNU Emacs.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94940
diff changeset
9 GNU Emacs is free software: you can redistribute it and/or modify
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94940
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: 94940
diff changeset
12 (at your option) any later version.
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14 GNU Emacs is distributed in the hope that it will be useful,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 GNU General Public License for more details.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94940
diff changeset
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 #include <config.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23 #include <stdio.h>
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
24 #include <stdlib.h>
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 #include <X11/Xlib.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 #include "lisp.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 #include "dispextern.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 #include "xterm.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 #include "frame.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 #include "blockinput.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 #include "character.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 #include "charset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 #include "fontset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 #include "font.h"
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
36 #include "ccl.h"
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 /* X core font driver. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
41 struct xfont_info
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
42 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
43 struct font font;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
44 Display *display;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
45 XFontStruct *xfont;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
46 };
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
47
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 /* Prototypes of support functions. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 extern void x_clear_errors P_ ((Display *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 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
52 static void xfont_find_ccl_program P_ ((struct font *));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54 /* Get metrics of character CHAR2B in XFONT. Value is null if CHAR2B
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55 is not contained in the font. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57 static XCharStruct *
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
58 xfont_get_pcm (xfont, char2b)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 XFontStruct *xfont;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 XChar2b *char2b;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 /* The result metric information. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 XCharStruct *pcm = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64
95180
1520d3ef2a48 (xfont_get_pcm): Change xassert to font_assert.
Kenichi Handa <handa@m17n.org>
parents: 94963
diff changeset
65 font_assert (xfont && char2b);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 if (xfont->per_char != NULL)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71 /* min_char_or_byte2 specifies the linear character index
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 corresponding to the first element of the per_char array,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 max_char_or_byte2 is the index of the last character. A
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 character with non-zero CHAR2B->byte1 is not in the font.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75 A character with byte2 less than min_char_or_byte2 or
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 greater max_char_or_byte2 is not in the font. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 if (char2b->byte1 == 0
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 && char2b->byte2 >= xfont->min_char_or_byte2
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 && char2b->byte2 <= xfont->max_char_or_byte2)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 pcm = xfont->per_char + char2b->byte2 - xfont->min_char_or_byte2;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 /* If either min_byte1 or max_byte1 are nonzero, both
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 min_char_or_byte2 and max_char_or_byte2 are less than
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 256, and the 2-byte character index values corresponding
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 to the per_char array element N (counting from 0) are:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 byte1 = N/D + min_byte1
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 byte2 = N\D + min_char_or_byte2
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 where:
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 D = max_char_or_byte2 - min_char_or_byte2 + 1
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 / = integer division
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 \ = integer modulus */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 if (char2b->byte1 >= xfont->min_byte1
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 && char2b->byte1 <= xfont->max_byte1
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 && char2b->byte2 >= xfont->min_char_or_byte2
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 && char2b->byte2 <= xfont->max_char_or_byte2)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 pcm = (xfont->per_char
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 + ((xfont->max_char_or_byte2 - xfont->min_char_or_byte2 + 1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103 * (char2b->byte1 - xfont->min_byte1))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104 + (char2b->byte2 - xfont->min_char_or_byte2));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
109 /* If the per_char pointer is null, all glyphs between the first
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110 and last character indexes inclusive have the same
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111 information, as given by both min_bounds and max_bounds. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112 if (char2b->byte2 >= xfont->min_char_or_byte2
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113 && char2b->byte2 <= xfont->max_char_or_byte2)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114 pcm = &xfont->max_bounds;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117 return ((pcm == NULL
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 || (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 ? NULL : pcm);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
122 /* 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
123 `encoder' of the structure. */
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
124
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
125 static void
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
126 xfont_find_ccl_program (font)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
127 struct font *font;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
128 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
129 Lisp_Object list, elt;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
130
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
131 elt = Qnil;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
132 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
133 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
134 elt = XCAR (list);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
135 if (CONSP (elt)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
136 && STRINGP (XCAR (elt))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
137 && ((fast_string_match_ignore_case (XCAR (elt),
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
138 font->props[FONT_NAME_INDEX])
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
139 >= 0)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
140 || (fast_string_match_ignore_case (XCAR (elt),
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
141 font->props[FONT_FULLNAME_INDEX])
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
142 >= 0)))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
143 break;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
144 }
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
145
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
146 if (! NILP (list))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
147 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
148 struct ccl_program *ccl
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
149 = (struct ccl_program *) xmalloc (sizeof (struct ccl_program));
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 (setup_ccl_program (ccl, XCDR (elt)) < 0)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
152 xfree (ccl);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
153 else
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
154 font->font_encoder = ccl;
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 }
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
157
91245
26541bdcecd0 (xfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents: 91177
diff changeset
158 static Lisp_Object xfont_get_cache P_ ((FRAME_PTR));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
159 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
160 static Lisp_Object xfont_match P_ ((Lisp_Object, Lisp_Object));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
161 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
162 static Lisp_Object xfont_open P_ ((FRAME_PTR, Lisp_Object, int));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
163 static void xfont_close P_ ((FRAME_PTR, struct font *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
164 static int xfont_prepare_face P_ ((FRAME_PTR, struct face *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
165 static int xfont_has_char P_ ((Lisp_Object, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
166 static unsigned xfont_encode_char P_ ((struct font *, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
167 static int xfont_text_extents P_ ((struct font *, unsigned *, int,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
168 struct font_metrics *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
169 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
170 static int xfont_check P_ ((FRAME_PTR, struct font *));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
171
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
172 struct font_driver xfont_driver =
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
173 {
90698
a31984e21969 (xfont_driver): Initialize ftfont_driver.type by 0.
Kenichi Handa <handa@m17n.org>
parents: 90679
diff changeset
174 0, /* Qx */
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
175 0, /* case insensitive */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
176 xfont_get_cache,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
177 xfont_list,
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
178 xfont_match,
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
179 xfont_list_family,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
180 NULL,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
181 xfont_open,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
182 xfont_close,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
183 xfont_prepare_face,
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
184 NULL,
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
185 xfont_has_char,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
186 xfont_encode_char,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
187 xfont_text_extents,
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
188 xfont_draw,
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
189 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
190 xfont_check
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
191 };
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
192
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
193 extern Lisp_Object QCname;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
194
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
195 static Lisp_Object
91245
26541bdcecd0 (xfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents: 91177
diff changeset
196 xfont_get_cache (f)
26541bdcecd0 (xfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents: 91177
diff changeset
197 FRAME_PTR f;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
198 {
91245
26541bdcecd0 (xfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents: 91177
diff changeset
199 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
200
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
201 return (dpyinfo->name_list_element);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
202 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
203
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
204 extern Lisp_Object Vface_alternative_font_registry_alist;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
205
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
206 static int
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
207 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
208 {
95568
4fec6e274c04 (xfont_list): Don't set registry to iso8859-1 even if it
Kenichi Handa <handa@m17n.org>
parents: 95503
diff changeset
209 return xstrcasecmp (*(const unsigned char **) name1,
4fec6e274c04 (xfont_list): Don't set registry to iso8859-1 even if it
Kenichi Handa <handa@m17n.org>
parents: 95503
diff changeset
210 *(const unsigned char **) name2);
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
211 }
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
212
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
213 /* Decode XLFD as iso-8859-1 into OUTPUT, and return the byte length
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
214 of the decoding result. LEN is the byte length of XLFD, or -1 if
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
215 XLFD is NULL terminated. The caller must assure that OUTPUT is at
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
216 least twice (plus 1) as large as XLFD. */
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
217
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
218 static int
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
219 xfont_decode_coding_xlfd (char *xlfd, int len, char *output)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
220 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
221 char *p0 = xlfd, *p1 = output;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
222 int c;
101943
97c9e9322753 Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents: 100951
diff changeset
223
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
224 while (*p0)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
225 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
226 c = *(unsigned char *) p0++;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
227 p1 += CHAR_STRING (c, p1);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
228 if (--len == 0)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
229 break;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
230 }
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
231 *p1 = 0;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
232 return (p1 - output);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
233 }
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
234
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
235 /* Encode XLFD from UTF-8 to iso-8859-1 destructively, and return the
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
236 resulting byte length. If XLFD contains unencodable character,
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
237 return -1. */
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
238
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
239 static int
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
240 xfont_encode_coding_xlfd (char *xlfd)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
241 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
242 const unsigned char *p0 = (unsigned char *) xlfd;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
243 unsigned char *p1 = (unsigned char *) xlfd;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
244 int len = 0;
101943
97c9e9322753 Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents: 100951
diff changeset
245
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
246 while (*p0)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
247 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
248 int c = STRING_CHAR_ADVANCE (p0);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
249
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
250 if (c >= 0x100)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
251 return -1;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
252 *p1++ = c;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
253 len++;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
254 }
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
255 *p1 = 0;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
256 return len;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
257 }
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
258
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
259 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
260
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
261 static Lisp_Object
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
262 xfont_list_pattern (frame, display, pattern)
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
263 Lisp_Object frame;
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
264 Display *display;
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
265 char *pattern;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
266 {
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
267 Lisp_Object list = Qnil;
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
268 int i, limit, num_fonts;
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
269 char **names;
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
270 /* Large enough to decode the longest XLFD (255 bytes). */
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
271 char buf[512];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
272
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
273 BLOCK_INPUT;
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
274 x_catch_errors (display);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
275
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
276 for (limit = 512; ; limit *= 2)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277 {
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
278 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
279 if (x_had_errors_p (display))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 /* This error is perhaps due to insufficient memory on X
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
282 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
283 x_clear_errors (display);
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
284 num_fonts = 0;
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
285 break;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
286 }
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
287 if (num_fonts < limit)
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
288 break;
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
289 XFreeFontNames (names);
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
290 }
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 (num_fonts > 0)
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
293 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
294 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
295
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
296 for (i = 0; i < num_fonts; i++)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
297 indices[i] = names[i];
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
298 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
299
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
300 for (i = 0; i < num_fonts; i++)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
302 Lisp_Object entity;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
303 int result;
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
304 char *p;
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
305
95222
005a1655f51e * dispextern.h, xfaces.c (xstrcasecmp): Renamed from xstricmp.
Jason Rumney <jasonr@gnu.org>
parents: 95202
diff changeset
306 if (i > 0 && xstrcasecmp (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
307 continue;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
308
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
309 entity = font_make_entity ();
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
310 ASET (entity, FONT_TYPE_INDEX, Qx);
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
311 xfont_decode_coding_xlfd (indices[i], -1, buf);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
312 result = font_parse_xlfd (buf, entity);
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
313 if (result < 0)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
314 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
315 /* 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
316 from XA_FONT property of the font. */
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
317 XFontStruct *font = XLoadQueryFont (display, indices[i]);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
318 unsigned long value;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
319
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
320 if (! font)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
321 continue;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
322 if (XGetFontProperty (font, XA_FONT, &value))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
323 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
324 char *name = (char *) XGetAtomName (display, (Atom) value);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
325 int len = strlen (name);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
326
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
327 /* If DXPC (a Differential X Protocol Compressor)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
328 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
329 string. We must avoid such a name. */
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
330 if (len > 0)
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
331 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
332 xfont_decode_coding_xlfd (indices[i], -1, buf);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
333 result = font_parse_xlfd (buf, entity);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
334 }
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
335 XFree (name);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
336 }
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
337 XFreeFont (display, font);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
338 }
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
339
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
340 if (result == 0
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
341 /* Avoid auto-scaled fonts. */
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
342 && (XINT (AREF (entity, FONT_DPI_INDEX)) == 0
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
343 || XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) > 0))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
344 list = Fcons (entity, list);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
345 }
95227
6df485632f28 (xfont_list_pattern): Free names returned from XListFonts.
Kenichi Handa <handa@m17n.org>
parents: 95222
diff changeset
346 XFreeFontNames (names);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
347 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
348
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
349 x_uncatch_errors ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
350 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
351
95180
1520d3ef2a48 (xfont_get_pcm): Change xassert to font_assert.
Kenichi Handa <handa@m17n.org>
parents: 94963
diff changeset
352 font_add_log ("xfont-list", build_string (pattern), list);
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
353 return list;
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
354 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
355
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
356 static Lisp_Object
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
357 xfont_list (frame, spec)
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
358 Lisp_Object frame, spec;
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
359 {
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
360 FRAME_PTR f = XFRAME (frame);
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
361 Display *display = FRAME_X_DISPLAY_INFO (f)->display;
95180
1520d3ef2a48 (xfont_get_pcm): Change xassert to font_assert.
Kenichi Handa <handa@m17n.org>
parents: 94963
diff changeset
362 Lisp_Object registry, list, val, extra;
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
363 int len;
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
364 /* Large enough to contain the longest XLFD (255 bytes) in UTF-8. */
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
365 char name[512];
101943
97c9e9322753 Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents: 100951
diff changeset
366
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
367 extra = AREF (spec, FONT_EXTRA_INDEX);
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
368 if (CONSP (extra))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
369 {
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
370 val = assq_no_quit (QCotf, extra);
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
371 if (! NILP (val))
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
372 return Qnil;
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
373 val = assq_no_quit (QCscript, extra);
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
374 if (! NILP (val))
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
375 return Qnil;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
376 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
377 if (! NILP (val))
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
378 return Qnil;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
379 }
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
380
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
381 registry = AREF (spec, FONT_REGISTRY_INDEX);
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
382 len = font_unparse_xlfd (spec, 0, name, 512);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
383 if (len < 0 || (len = xfont_encode_coding_xlfd (name)) < 0)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
384 return Qnil;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
385 ASET (spec, FONT_REGISTRY_INDEX, registry);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
386 list = xfont_list_pattern (frame, display, name);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
387 if (NILP (list) && NILP (registry))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
388 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
389 /* Try iso10646-1 */
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
390 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
391
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
392 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
393 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
394 strcpy (r, "iso10646-1");
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
395 list = xfont_list_pattern (frame, display, name);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
396 }
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
397 }
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
398 if (NILP (list) && ! NILP (registry))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
399 {
95503
1699a530f6a3 (xfont_list): Try an alias.
Kenichi Handa <handa@m17n.org>
parents: 95330
diff changeset
400 /* Try alternate registries. */
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
401 Lisp_Object alter;
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
402
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
403 if ((alter = Fassoc (SYMBOL_NAME (registry),
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
404 Vface_alternative_font_registry_alist),
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
405 CONSP (alter)))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
406 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
407 /* Pointer to REGISTRY-ENCODING field. */
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
408 char *r = name + len - SBYTES (SYMBOL_NAME (registry));
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
409
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
410 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
411 if (STRINGP (XCAR (alter))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
412 && ((r - name) + SBYTES (XCAR (alter))) < 256)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
413 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
414 strcpy (r, (char *) SDATA (XCAR (alter)));
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
415 list = xfont_list_pattern (frame, display, name);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
416 if (! NILP (list))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
417 break;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
418 }
90501
2ef165ebcc7d (xfont_query_font): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 90461
diff changeset
419 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
420 }
95503
1699a530f6a3 (xfont_list): Try an alias.
Kenichi Handa <handa@m17n.org>
parents: 95330
diff changeset
421 if (NILP (list))
1699a530f6a3 (xfont_list): Try an alias.
Kenichi Handa <handa@m17n.org>
parents: 95330
diff changeset
422 {
1699a530f6a3 (xfont_list): Try an alias.
Kenichi Handa <handa@m17n.org>
parents: 95330
diff changeset
423 /* Try alias. */
1699a530f6a3 (xfont_list): Try an alias.
Kenichi Handa <handa@m17n.org>
parents: 95330
diff changeset
424 val = assq_no_quit (QCname, AREF (spec, FONT_EXTRA_INDEX));
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
425 if (CONSP (val) && STRINGP (XCDR (val)) && SBYTES (XCDR (val)) < 512)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
426 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
427 bcopy (SDATA (XCDR (val)), name, SBYTES (XCDR (val)) + 1);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
428 if (xfont_encode_coding_xlfd (name) < 0)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
429 return Qnil;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
430 list = xfont_list_pattern (frame, display, name);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
431 }
95503
1699a530f6a3 (xfont_list): Try an alias.
Kenichi Handa <handa@m17n.org>
parents: 95330
diff changeset
432 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
433
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
434 return list;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
435 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
436
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
437 static Lisp_Object
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
438 xfont_match (frame, spec)
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
439 Lisp_Object frame, spec;
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
440 {
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
441 FRAME_PTR f = XFRAME (frame);
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
442 Display *display = FRAME_X_DISPLAY_INFO (f)->display;
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
443 Lisp_Object extra, val, entity;
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
444 char name[512];
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
445 XFontStruct *xfont;
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
446 unsigned long value;
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
447
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
448 extra = AREF (spec, FONT_EXTRA_INDEX);
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
449 val = assq_no_quit (QCname, extra);
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
450 if (! CONSP (val) || ! STRINGP (XCDR (val)))
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
451 {
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
452 if (font_unparse_xlfd (spec, 0, name, 512) < 0)
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
453 return Qnil;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
454 }
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
455 else if (SBYTES (XCDR (val)) < 512)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
456 bcopy (SDATA (XCDR (val)), name, SBYTES (XCDR (val)) + 1);
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
457 else
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
458 return Qnil;
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
459 if (xfont_encode_coding_xlfd (name) < 0)
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
460 return Qnil;
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
461
90569
0af2dbdeaeb3 (xfont_match): Block and unblock input while callin Xlib.
Kenichi Handa <handa@m17n.org>
parents: 90561
diff changeset
462 BLOCK_INPUT;
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
463 entity = Qnil;
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
464 xfont = XLoadQueryFont (display, name);
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
465 if (xfont)
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
466 {
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
467 if (XGetFontProperty (xfont, XA_FONT, &value))
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
468 {
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
469 int len;
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
470 char *s;
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
471
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
472 s = (char *) XGetAtomName (display, (Atom) value);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
473 len = strlen (s);
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
474
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
475 /* If DXPC (a Differential X Protocol Compressor)
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
476 Ver.3.7 is running, XGetAtomName will return null
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
477 string. We must avoid such a name. */
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
478 if (len > 0)
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
479 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
480 entity = font_make_entity ();
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
481 ASET (entity, FONT_TYPE_INDEX, Qx);
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
482 xfont_decode_coding_xlfd (s, -1, name);
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
483 if (font_parse_xlfd (name, entity) < 0)
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
484 entity = Qnil;
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
485 }
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
486 XFree (s);
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
487 }
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
488 XFreeFont (display, xfont);
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
489 }
90569
0af2dbdeaeb3 (xfont_match): Block and unblock input while callin Xlib.
Kenichi Handa <handa@m17n.org>
parents: 90561
diff changeset
490 UNBLOCK_INPUT;
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
491
95180
1520d3ef2a48 (xfont_get_pcm): Change xassert to font_assert.
Kenichi Handa <handa@m17n.org>
parents: 94963
diff changeset
492 font_add_log ("xfont-match", spec, entity);
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
493 return entity;
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
494 }
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
495
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
496 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
497 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
498 Lisp_Object frame;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
499 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
500 FRAME_PTR f = XFRAME (frame);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
501 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
502 char **names;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
503 int num_fonts, i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
504 Lisp_Object list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
505 char *last_family;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
506 int last_len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
507
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
508 BLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
509 x_catch_errors (dpyinfo->display);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
510 names = XListFonts (dpyinfo->display, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
511 0x8000, &num_fonts);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
512 if (x_had_errors_p (dpyinfo->display))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
513 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
514 /* This error is perhaps due to insufficient memory on X server.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
515 Let's just ignore it. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
516 x_clear_errors (dpyinfo->display);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
517 num_fonts = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
518 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
519
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
520 list = Qnil;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
521 for (i = 0, last_len = 0; i < num_fonts; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
522 {
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
523 char *p0 = names[i], *p1, buf[512];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
524 Lisp_Object family;
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
525 int decoded_len;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
526
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
527 p0++; /* skip the leading '-' */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
528 while (*p0 && *p0 != '-') p0++; /* skip foundry */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
529 if (! *p0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
530 continue;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
531 p1 = ++p0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
532 while (*p1 && *p1 != '-') p1++; /* find the end of family */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
533 if (! *p1 || p1 == p0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
534 continue;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
535 if (last_len == p1 - p0
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
536 && bcmp (last_family, p0, last_len) == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
537 continue;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
538 last_len = p1 - p0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
539 last_family = p0;
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
540
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
541 decoded_len = xfont_decode_coding_xlfd (p0, last_len, buf);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
542 family = font_intern_prop (p0, decoded_len, 1);
97327
53bcf54737b2 (xfont_list_family): Return a list of symbols, not
Kenichi Handa <handa@m17n.org>
parents: 96657
diff changeset
543 if (NILP (assq_no_quit (family, list)))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
544 list = Fcons (family, list);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
545 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
546
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
547 XFreeFontNames (names);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
548 x_uncatch_errors ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
549 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
550
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
551 return list;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
552 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
553
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
554 extern Lisp_Object QCavgwidth;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
555
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
556 static Lisp_Object
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
557 xfont_open (f, entity, pixel_size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
558 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
559 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
560 int pixel_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
561 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
562 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
563 Display *display = dpyinfo->display;
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
564 char name[512];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
565 int len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
566 unsigned long value;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
567 Lisp_Object registry;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
568 struct charset *encoding, *repertory;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
569 Lisp_Object font_object, fullname;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
570 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
571 XFontStruct *xfont;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
572 int i;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
573
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
574 /* At first, check if we know how to encode characters for this
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
575 font. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
576 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
577 if (font_registry_charsets (registry, &encoding, &repertory) < 0)
96575
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
578 {
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
579 font_add_log (" x:unknown registry", registry, Qnil);
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
580 return Qnil;
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
581 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
582
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
583 if (XINT (AREF (entity, FONT_SIZE_INDEX)) != 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
584 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
585 else if (pixel_size == 0)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
586 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
587 if (FRAME_FONT (f))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
588 pixel_size = FRAME_FONT (f)->pixel_size;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
589 else
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
590 pixel_size = 14;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
591 }
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
592 len = font_unparse_xlfd (entity, pixel_size, name, 512);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
593 if (len <= 0 || (len = xfont_encode_coding_xlfd (name)) < 0)
96575
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
594 {
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
595 font_add_log (" x:unparse failed", entity, Qnil);
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
596 return Qnil;
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
597 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
598
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
599 BLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
600 x_catch_errors (display);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
601 xfont = XLoadQueryFont (display, name);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
602 if (x_had_errors_p (display))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
603 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
604 /* This error is perhaps due to insufficient memory on X server.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
605 Let's just ignore it. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
606 x_clear_errors (display);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
607 xfont = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
608 }
96657
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
609 else if (! xfont)
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
610 {
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
611 /* Some version of X lists:
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
612 -misc-fixed-medium-r-normal--20-*-75-75-c-100-iso8859-1
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
613 -misc-fixed-medium-r-normal--20-*-100-100-c-100-iso8859-1
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
614 but can open only:
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
615 -misc-fixed-medium-r-normal--20-*-100-100-c-100-iso8859-1
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
616 and
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
617 -misc-fixed-medium-r-normal--20-*-*-*-c-100-iso8859-1
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
618 So, we try again with wildcards in RESX and RESY. */
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
619 Lisp_Object temp;
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
620
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
621 temp = Fcopy_font_spec (entity);
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
622 ASET (temp, FONT_DPI_INDEX, Qnil);
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
623 len = font_unparse_xlfd (temp, pixel_size, name, 512);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
624 if (len <= 0 || (len = xfont_encode_coding_xlfd (name)) < 0)
96657
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
625 {
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
626 font_add_log (" x:unparse failed", temp, Qnil);
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
627 return Qnil;
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
628 }
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
629 xfont = XLoadQueryFont (display, name);
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
630 if (x_had_errors_p (display))
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
631 {
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
632 /* This error is perhaps due to insufficient memory on X server.
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
633 Let's just ignore it. */
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
634 x_clear_errors (display);
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
635 xfont = NULL;
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
636 }
fb9629443416 (xfont_open): Add workaround for X's bug.
Kenichi Handa <handa@m17n.org>
parents: 96575
diff changeset
637 }
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
638 fullname = Qnil;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
639 /* Try to get the full name of FONT. */
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
640 if (xfont && XGetFontProperty (xfont, XA_FONT, &value))
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
641 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
642 char *p0, *p;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
643 int dashes = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
644
101943
97c9e9322753 Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents: 100951
diff changeset
645 p0 = p = (char *) XGetAtomName (FRAME_X_DISPLAY (f), (Atom) value);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
646 /* Count the number of dashes in the "full name".
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
647 If it is too few, this isn't really the font's full name,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
648 so don't use it.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
649 In X11R4, the fonts did not come with their canonical names
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
650 stored in them. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
651 while (*p)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
652 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
653 if (*p == '-')
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
654 dashes++;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
655 p++;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
656 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
657
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
658 if (dashes >= 13)
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
659 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
660 len = xfont_decode_coding_xlfd (p0, -1, name);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
661 fullname = Fdowncase (make_string (name, len));
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
662 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
663 XFree (p0);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
664 }
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
665 x_uncatch_errors ();
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
666 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
667
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
668 if (! xfont)
96575
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
669 {
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
670 font_add_log (" x:open failed", build_string (name), Qnil);
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
671 return Qnil;
2c94c05f0d89 (xfont_open): Log the reason of failure.
Kenichi Handa <handa@m17n.org>
parents: 96570
diff changeset
672 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
673
96560
d87a9f1b9378 (xfont_open): Adjust it for the change of
Kenichi Handa <handa@m17n.org>
parents: 95568
diff changeset
674 font_object = font_make_object (VECSIZE (struct xfont_info),
d87a9f1b9378 (xfont_open): Adjust it for the change of
Kenichi Handa <handa@m17n.org>
parents: 95568
diff changeset
675 entity, pixel_size);
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
676 ASET (font_object, FONT_TYPE_INDEX, Qx);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
677 if (STRINGP (fullname))
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
678 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
679 font_parse_xlfd ((char *) SDATA (fullname), font_object);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
680 ASET (font_object, FONT_NAME_INDEX, fullname);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
681 }
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
682 else
100553
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
683 {
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
684 char buf[512];
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
685
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
686 len = xfont_decode_coding_xlfd (name, -1, buf);
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
687 ASET (font_object, FONT_NAME_INDEX, make_string (buf, len));
e42552b2edda (xfont_decode_coding_xlfd): New function.
Kenichi Handa <handa@m17n.org>
parents: 97327
diff changeset
688 }
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
689 ASET (font_object, FONT_FULLNAME_INDEX, fullname);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
690 ASET (font_object, FONT_FILE_INDEX, Qnil);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
691 ASET (font_object, FONT_FORMAT_INDEX, Qx);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
692 font = XFONT_OBJECT (font_object);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
693 ((struct xfont_info *) font)->xfont = xfont;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
694 ((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
695 font->pixel_size = pixel_size;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
696 font->driver = &xfont_driver;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
697 font->encoding_charset = encoding->id;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
698 font->repertory_charset = repertory ? repertory->id : -1;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
699 font->ascent = xfont->ascent;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
700 font->descent = xfont->descent;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
701 font->height = font->ascent + font->descent;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
702 font->min_width = xfont->min_bounds.width;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
703 if (xfont->min_bounds.width == xfont->max_bounds.width)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
704 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
705 /* Fixed width font. */
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
706 font->average_width = font->space_width = xfont->min_bounds.width;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
707 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
708 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
709 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
710 XCharStruct *pcm;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
711 XChar2b char2b;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
712 Lisp_Object val;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
713
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
714 char2b.byte1 = 0x00, char2b.byte2 = 0x20;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
715 pcm = xfont_get_pcm (xfont, &char2b);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
716 if (pcm)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
717 font->space_width = pcm->width;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
718 else
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
719 font->space_width = 0;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
720
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
721 val = Ffont_get (font_object, QCavgwidth);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
722 if (INTEGERP (val))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
723 font->average_width = XINT (val);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
724 if (font->average_width < 0)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
725 font->average_width = - font->average_width;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
726 if (font->average_width == 0
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
727 && encoding->ascii_compatible_p)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
728 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
729 int width = font->space_width, n = pcm != NULL;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
730
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
731 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
732 if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
733 width += pcm->width, n++;
95330
fe15ab9a9bc7 (xfont_open): Fix calculation of font->average_width.
Kenichi Handa <handa@m17n.org>
parents: 95227
diff changeset
734 if (n > 0)
fe15ab9a9bc7 (xfont_open): Fix calculation of font->average_width.
Kenichi Handa <handa@m17n.org>
parents: 95227
diff changeset
735 font->average_width = width / n;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
736 }
95330
fe15ab9a9bc7 (xfont_open): Fix calculation of font->average_width.
Kenichi Handa <handa@m17n.org>
parents: 95227
diff changeset
737 if (font->average_width == 0)
fe15ab9a9bc7 (xfont_open): Fix calculation of font->average_width.
Kenichi Handa <handa@m17n.org>
parents: 95227
diff changeset
738 /* No easy way other than this to get a reasonable
fe15ab9a9bc7 (xfont_open): Fix calculation of font->average_width.
Kenichi Handa <handa@m17n.org>
parents: 95227
diff changeset
739 average_width. */
fe15ab9a9bc7 (xfont_open): Fix calculation of font->average_width.
Kenichi Handa <handa@m17n.org>
parents: 95227
diff changeset
740 font->average_width
fe15ab9a9bc7 (xfont_open): Fix calculation of font->average_width.
Kenichi Handa <handa@m17n.org>
parents: 95227
diff changeset
741 = (xfont->min_bounds.width + xfont->max_bounds.width) / 2;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
742 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
743
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
744 BLOCK_INPUT;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
745 font->underline_thickness
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
746 = (XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &value)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
747 ? (long) value : 0);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
748 font->underline_position
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
749 = (XGetFontProperty (xfont, XA_UNDERLINE_POSITION, &value)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
750 ? (long) value : -1);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
751 font->baseline_offset
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
752 = (XGetFontProperty (xfont, dpyinfo->Xatom_MULE_BASELINE_OFFSET, &value)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
753 ? (long) value : 0);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
754 font->relative_compose
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
755 = (XGetFontProperty (xfont, dpyinfo->Xatom_MULE_RELATIVE_COMPOSE, &value)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
756 ? (long) value : 0);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
757 font->default_ascent
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
758 = (XGetFontProperty (xfont, dpyinfo->Xatom_MULE_DEFAULT_ASCENT, &value)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
759 ? (long) value : 0);
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
760 UNBLOCK_INPUT;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
761
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
762 if (NILP (fullname))
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
763 fullname = AREF (font_object, FONT_NAME_INDEX);
96566
dec3815c40d7 (xfont_open): Cancel the previous about font->vertical_centering.
Kenichi Handa <handa@m17n.org>
parents: 96560
diff changeset
764 font->vertical_centering
dec3815c40d7 (xfont_open): Cancel the previous about font->vertical_centering.
Kenichi Handa <handa@m17n.org>
parents: 96560
diff changeset
765 = (STRINGP (Vvertical_centering_font_regexp)
dec3815c40d7 (xfont_open): Cancel the previous about font->vertical_centering.
Kenichi Handa <handa@m17n.org>
parents: 96560
diff changeset
766 && (fast_string_match_ignore_case
dec3815c40d7 (xfont_open): Cancel the previous about font->vertical_centering.
Kenichi Handa <handa@m17n.org>
parents: 96560
diff changeset
767 (Vvertical_centering_font_regexp, fullname) >= 0));
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
768
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
769 return font_object;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
770 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
771
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
772 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
773 xfont_close (f, font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
774 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
775 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
776 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
777 BLOCK_INPUT;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
778 XFreeFont (FRAME_X_DISPLAY (f), ((struct xfont_info *) font)->xfont);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
779 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
780 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
781
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
782 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
783 xfont_prepare_face (f, face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
784 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
785 struct face *face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
786 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
787 BLOCK_INPUT;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
788 XSetFont (FRAME_X_DISPLAY (f), face->gc,
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
789 ((struct xfont_info *) face->font)->xfont->fid);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
790 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
791
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
792 return 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
793 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
794
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
795 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
796 xfont_has_char (entity, c)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
797 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
798 int c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
799 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
800 Lisp_Object registry = AREF (entity, FONT_REGISTRY_INDEX);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
801 struct charset *repertory;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
802
91142
4bcf0716ddf4 * xfont.c (x_font_charset_alist): Moved to font.c and renamed.
Kenichi Handa <handa@m17n.org>
parents: 90698
diff changeset
803 if (font_registry_charsets (registry, NULL, &repertory) < 0)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
804 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
805 if (! repertory)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
806 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
807 return (ENCODE_CHAR (repertory, c) != CHARSET_INVALID_CODE (repertory));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
808 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
809
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
810 static unsigned
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
811 xfont_encode_char (font, c)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
812 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
813 int c;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
814 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
815 XFontStruct *xfont = ((struct xfont_info *) font)->xfont;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
816 struct charset *charset;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
817 unsigned code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
818 XChar2b char2b;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
819
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
820 charset = CHARSET_FROM_ID (font->encoding_charset);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
821 code = ENCODE_CHAR (charset, c);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
822 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
823 return FONT_INVALID_CODE;
90454
a8b745412821 (xfont_open, xfont_encode_char): Fix typo.
Kenichi Handa <handa@m17n.org>
parents: 90443
diff changeset
824 if (font->repertory_charset >= 0)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
825 {
90454
a8b745412821 (xfont_open, xfont_encode_char): Fix typo.
Kenichi Handa <handa@m17n.org>
parents: 90443
diff changeset
826 charset = CHARSET_FROM_ID (font->repertory_charset);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
827 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
828 ? code : FONT_INVALID_CODE);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
829 }
90425
5976e428d68e (xfont_encode_char): Fix calculation of char2b.
Kenichi Handa <handa@m17n.org>
parents: 90400
diff changeset
830 char2b.byte1 = code >> 8;
5976e428d68e (xfont_encode_char): Fix calculation of char2b.
Kenichi Handa <handa@m17n.org>
parents: 90400
diff changeset
831 char2b.byte2 = code & 0xFF;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
832 return (xfont_get_pcm (xfont, &char2b) ? code : FONT_INVALID_CODE);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
833 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
834
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
835 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
836 xfont_text_extents (font, code, nglyphs, metrics)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
837 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
838 unsigned *code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
839 int nglyphs;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
840 struct font_metrics *metrics;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
841 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
842 XFontStruct *xfont = ((struct xfont_info *) font)->xfont;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
843 int width = 0;
96570
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
844 int i, first, x;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
845
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
846 if (metrics)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
847 bzero (metrics, sizeof (struct font_metrics));
96570
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
848 for (i = 0, x = 0, first = 1; i < nglyphs; i++)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
849 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
850 XChar2b char2b;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
851 static XCharStruct *pcm;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
852
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
853 if (code[i] >= 0x10000)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
854 continue;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
855 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
856 pcm = xfont_get_pcm (xfont, &char2b);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
857 if (! pcm)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
858 continue;
96570
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
859 if (first)
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
860 {
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
861 if (metrics)
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
862 {
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
863 metrics->lbearing = pcm->lbearing;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
864 metrics->rbearing = pcm->rbearing;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
865 metrics->ascent = pcm->ascent;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
866 metrics->descent = pcm->descent;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
867 }
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
868 first = 0;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
869 }
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
870 else
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
871 {
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
872 if (metrics)
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
873 {
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
874 if (metrics->lbearing > width + pcm->lbearing)
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
875 metrics->lbearing = width + pcm->lbearing;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
876 if (metrics->rbearing < width + pcm->rbearing)
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
877 metrics->rbearing = width + pcm->rbearing;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
878 if (metrics->ascent < pcm->ascent)
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
879 metrics->ascent = pcm->ascent;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
880 if (metrics->descent < pcm->descent)
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
881 metrics->descent = pcm->descent;
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
882 }
12587e64cfe3 (xfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents: 96566
diff changeset
883 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
884 width += pcm->width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
885 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
886 if (metrics)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
887 metrics->width = width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
888 return width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
889 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
890
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
891 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
892 xfont_draw (s, from, to, x, y, with_background)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
893 struct glyph_string *s;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
894 int from, to, x, y, with_background;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
895 {
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
896 XFontStruct *xfont = ((struct xfont_info *) s->font)->xfont;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
897 int len = to - from;
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
898 GC gc = s->gc;
92185
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
899 int i;
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
900
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
901 if (s->gc != s->face->gc)
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
902 {
91905
6ae79e72fea7 (xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents: 91554
diff changeset
903 BLOCK_INPUT;
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
904 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
905 UNBLOCK_INPUT;
90561
73750c4e078a (xfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90545
diff changeset
906 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
907
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
908 if (xfont->min_byte1 == 0 && xfont->max_byte1 == 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
909 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
910 char *str;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
911 USE_SAFE_ALLOCA;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
912
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
913 SAFE_ALLOCA (str, char *, len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
914 for (i = 0; i < len ; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
915 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
916 BLOCK_INPUT;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
917 if (with_background > 0)
92185
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
918 {
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
919 if (s->padding_p)
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
920 for (i = 0; i < len; i++)
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
921 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
922 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
923 else
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
924 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
925 gc, x, y, str, len);
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
926 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
927 else
92185
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
928 {
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
929 if (s->padding_p)
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
930 for (i = 0; i < len; i++)
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
931 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
932 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
933 else
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
934 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
935 gc, x, y, str, len);
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
936 }
91905
6ae79e72fea7 (xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents: 91554
diff changeset
937 UNBLOCK_INPUT;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
938 SAFE_FREE ();
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
939 return s->nchars;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
940 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
941
91905
6ae79e72fea7 (xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents: 91554
diff changeset
942 BLOCK_INPUT;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
943 if (with_background > 0)
92185
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
944 {
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
945 if (s->padding_p)
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
946 for (i = 0; i < len; i++)
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
947 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
948 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
949 else
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
950 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
951 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
952 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
953 else
92185
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
954 {
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
955 if (s->padding_p)
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
956 for (i = 0; i < len; i++)
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
957 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
958 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
959 else
1e28008a13e5 (xfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91905
diff changeset
960 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
961 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
962 }
91905
6ae79e72fea7 (xfont_draw): Use BLOCK_INPUT and UNBLOCK_INPUT.
Kenichi Handa <handa@m17n.org>
parents: 91554
diff changeset
963 UNBLOCK_INPUT;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
964
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
965 return len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
966 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
967
94940
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
968 static int
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
969 xfont_check (f, font)
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
970 FRAME_PTR f;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
971 struct font *font;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
972 {
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
973 struct xfont_info *xfont = (struct xfont_info *) font;
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
974
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
975 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
976 }
061d44df20b7 Include <stdlib.h> and "ccl.h".
Kenichi Handa <handa@m17n.org>
parents: 92185
diff changeset
977
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
978
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
979 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
980 syms_of_xfont ()
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
981 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
982 xfont_driver.type = Qx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
983 register_font_driver (&xfont_driver, NULL);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
984 }
90427
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90425
diff changeset
985
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90425
diff changeset
986 /* arch-tag: 23c5f366-a5ee-44b7-a3b7-90d6da7fd749
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90425
diff changeset
987 (do not change this comment) */