annotate src/xfont.c @ 93137:59d389acc0ce

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