annotate src/objects-x.c @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents 9ee227acff29
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* X-specific Lisp objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1995 Tinker Systems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 Copyright (C) 1995 Sun Microsystems, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 /* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "console-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "objects-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "insdel.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 int handle_nonfull_spec_fonts;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 /* color instances */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 /* Replacement for XAllocColor() that tries to return the nearest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 available color if the colormap is full. From FSF Emacs. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 allocate_nearest_color (Display *display, Colormap screen_colormap,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 XColor *color_def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 int status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 status = XAllocColor (display, screen_colormap, color_def);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 if (!status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 /* If we got to this point, the colormap is full, so we're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 going to try and get the next closest color.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 The algorithm used is a least-squares matching, which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 what X uses for closest color matching with StaticColor visuals. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 XColor *cells;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 int no_cells;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 int nearest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 long nearest_delta, trial_delta;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 int x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 no_cells = XDisplayCells (display, XDefaultScreen (display));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 cells = (XColor *) alloca (sizeof (XColor) * no_cells);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 for (x = 0; x < no_cells; x++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 cells[x].pixel = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 XQueryColors (display, screen_colormap, cells, no_cells);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 nearest = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 /* I'm assuming CSE so I'm not going to condense this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 nearest_delta = ((((color_def->red >> 8) - (cells[0].red >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 * ((color_def->red >> 8) - (cells[0].red >> 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (((color_def->green >> 8) - (cells[0].green >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 * ((color_def->green >> 8) - (cells[0].green >> 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (((color_def->blue >> 8) - (cells[0].blue >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 * ((color_def->blue >> 8) - (cells[0].blue >> 8))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 for (x = 1; x < no_cells; x++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 trial_delta = ((((color_def->red >> 8) - (cells[x].red >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 * ((color_def->red >> 8) - (cells[x].red >> 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (((color_def->green >> 8) - (cells[x].green >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 * ((color_def->green >> 8) - (cells[x].green >> 8)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (((color_def->blue >> 8) - (cells[x].blue >> 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 * ((color_def->blue >> 8) - (cells[x].blue >> 8))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 if (trial_delta < nearest_delta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 nearest = x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 nearest_delta = trial_delta;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 color_def->red = cells[nearest].red;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 color_def->green = cells[nearest].green;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 color_def->blue = cells[nearest].blue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 status = XAllocColor (display, screen_colormap, color_def);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 return status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 x_parse_nearest_color (struct device *d, XColor *color, Bufbyte *name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 Bytecount len, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 Display *dpy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Screen *xs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Colormap cmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 int result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 dpy = DEVICE_X_DISPLAY (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 xs = DefaultScreenOfDisplay (dpy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 cmap = DefaultColormapOfScreen (xs);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 memset (color, 0, sizeof (*color));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 CONST Extbyte *extname;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 Extcount extnamelen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 GET_CHARPTR_EXT_BINARY_DATA_ALLOCA (name, len, extname, extnamelen);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 result = XParseColor (dpy, cmap, (char *) extname, color);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 if (!result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 maybe_signal_simple_error ("unrecognized color", make_string (name, len),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 Qcolor, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 result = allocate_nearest_color (dpy, cmap, color);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 if (!result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 maybe_signal_simple_error ("couldn't allocate color",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 make_string (name, len), Qcolor, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 x_initialize_color_instance (struct Lisp_Color_Instance *c, Lisp_Object name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 Lisp_Object device, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 XColor color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 int result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 result = x_parse_nearest_color (XDEVICE (device), &color,
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
157 XSTRING_DATA (name),
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
158 XSTRING_LENGTH (name),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 if (!result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 /* Don't allocate the data until we're sure that we will succeed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 or the finalize method may get fucked. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 c->data = malloc_type (struct x_color_instance_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 COLOR_INSTANCE_X_COLOR (c) = color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 x_print_color_instance (struct Lisp_Color_Instance *c,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 char buf[100];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 XColor color = COLOR_INSTANCE_X_COLOR (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 sprintf (buf, " %ld=(%X,%X,%X)",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 color.pixel, color.red, color.green, color.blue);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 x_finalize_color_instance (struct Lisp_Color_Instance *c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 if (c->data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 if (DEVICE_LIVE_P (XDEVICE (c->device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (c->device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 XFreeColors (dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 DefaultColormapOfScreen (DefaultScreenOfDisplay (dpy)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 &COLOR_INSTANCE_X_COLOR (c).pixel, 1, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 xfree (c->data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 c->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 /* Color instances are equal if they resolve to the same color on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 screen (have the same RGB values). I imagine that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 "same RGV values" == "same cell in the colormap." Arguably we should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 be comparing their names instead. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 x_color_instance_equal (struct Lisp_Color_Instance *c1,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 struct Lisp_Color_Instance *c2,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 XColor color1 = COLOR_INSTANCE_X_COLOR (c1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 XColor color2 = COLOR_INSTANCE_X_COLOR (c2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 return ((color1.red == color2.red) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (color1.green == color2.green) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (color1.blue == color2.blue));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 x_color_instance_hash (struct Lisp_Color_Instance *c, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 XColor color = COLOR_INSTANCE_X_COLOR (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 return HASH3 (color.red, color.green, color.blue);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 x_color_instance_rgb_components (struct Lisp_Color_Instance *c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 XColor color = COLOR_INSTANCE_X_COLOR (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 return (list3 (make_int (color.red),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 make_int (color.green),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 make_int (color.blue)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 x_valid_color_name_p (struct device *d, Lisp_Object color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 XColor c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 Display *dpy = DEVICE_X_DISPLAY (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 CONST char *extname;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 GET_C_STRING_CTEXT_DATA_ALLOCA (color, extname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 return XParseColor (dpy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 DefaultColormapOfScreen (DefaultScreenOfDisplay (dpy)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 extname, &c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 /* font instances */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 x_initialize_font_instance (struct Lisp_Font_Instance *f, Lisp_Object name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 Lisp_Object device, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 Display *dpy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 XFontStruct *xf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 CONST char *extname;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 dpy = DEVICE_X_DISPLAY (XDEVICE (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 GET_C_STRING_CTEXT_DATA_ALLOCA (f->name, extname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 xf = XLoadQueryFont (dpy, extname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 if (!xf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 maybe_signal_simple_error ("couldn't load font", f->name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 Qfont, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 if (!xf->max_bounds.width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 /* yes, this has been known to happen. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 XFreeFont (dpy, xf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 maybe_signal_simple_error ("X font is too small", f->name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 Qfont, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 /* Don't allocate the data until we're sure that we will succeed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 or the finalize method may get fucked. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 f->data = malloc_type (struct x_font_instance_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 FONT_INSTANCE_X_TRUENAME (f) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 FONT_INSTANCE_X_FONT (f) = xf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 f->ascent = xf->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 f->descent = xf->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 f->height = xf->ascent + xf->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 {
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
290 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
291 unsigned int def_char = 'n'; /*xf->default_char;*/
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 int byte1, byte2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 once_more:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 byte1 = def_char >> 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 byte2 = def_char & 0xFF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 if (xf->per_char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 /* Old versions of the R5 font server have garbage (>63k) as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 def_char. 'n' might not be a valid character. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 if (byte1 < xf->min_byte1 || byte1 > xf->max_byte1 ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 byte2 < xf->min_char_or_byte2 || byte2 > xf->max_char_or_byte2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 f->width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 f->width = xf->per_char[(byte1 - xf->min_byte1) *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (xf->max_char_or_byte2 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 xf->min_char_or_byte2 + 1) +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (byte2 - xf->min_char_or_byte2)].width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 f->width = xf->max_bounds.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 /* Some fonts have a default char whose width is 0. This is no good.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 If that's the case, first try 'n' as the default char, and if n has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 0 width too (unlikely) then just use the max width. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 if (f->width == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 {
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
319 if (def_char == xf->default_char)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 f->width = xf->max_bounds.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 {
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
323 def_char = xf->default_char;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 goto once_more;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 /* If all characters don't exist then there could potentially be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 0-width characters lurking out there. Not setting this flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 trips an optimization that would make them appear to have width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 to redisplay. This is bad. So we set it if not all characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 have the same width or if not all characters are defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 /* #### This sucks. There is a measurable performance increase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 when using proportional width fonts if this flag is not set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 Unfortunately so many of the fucking X fonts are not fully
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 defined that we could almost just get rid of this damn flag and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 make it an assertion. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (handle_nonfull_spec_fonts &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 !xf->all_chars_exist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 x_mark_font_instance (struct Lisp_Font_Instance *f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ((markobj) (FONT_INSTANCE_X_TRUENAME (f)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 x_print_font_instance (struct Lisp_Font_Instance *f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 char buf[200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 sprintf (buf, " 0x%lx", (unsigned long) FONT_INSTANCE_X_FONT (f)->fid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 x_finalize_font_instance (struct Lisp_Font_Instance *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 if (f->data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 if (DEVICE_LIVE_P (XDEVICE (f->device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 XFreeFont (dpy, FONT_INSTANCE_X_FONT (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 xfree (f->data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 f->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 /* Determining the truename of a font is hard. (Big surprise.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 By "truename" we mean an XLFD-form name which contains no wildcards, yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 which resolves to *exactly* the same font as the one which we already have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 the (probably wildcarded) name and `XFontStruct' of.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 One might think that the first font returned by XListFonts would be the one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 that XOpenFont would pick. Apparently this is the case on some servers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 but not on others. It would seem not to be specified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 The MIT R5 server sometimes appears to be picking the lexicographically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 smallest font which matches the name (thus picking "adobe" fonts before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "bitstream" fonts even if the bitstream fonts are earlier in the path, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 also picking 100dpi adobe fonts over 75dpi adobe fonts even though the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 75dpi are in the path earlier) but sometimes appears to be doing something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 else entirely (for example, removing the bitsream fonts from the path will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 cause the 75dpi adobe fonts to be used instead of the100dpi, even though
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 their relative positions in the path (and their names!) have not changed).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 The documentation for XSetFontPath() seems to indicate that the order of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 entries in the font path means something, but it's pretty noncommital about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 it, and the spirit of the law is apparently not being obeyed...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 All the fonts I've seen have a property named `FONT' which contains the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 truename of the font. However, there are two problems with using this: the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 first is that the X Protocol Document is quite explicit that all properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 are optional, so we can't depend on it being there. The second is that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 it's concievable that this alleged truename isn't actually accessible as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 font, due to some difference of opinion between the font designers and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 whoever installed the font on the system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 So, our first attempt is to look for a FONT property, and then verify that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 the name there is a valid name by running XListFonts on it. There's still
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 the potential that this could be true but we could still be being lied to,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 but that seems pretty remote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 Late breaking news: I've gotten reports that SunOS 4.1.3U1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 with OpenWound 3.0 has a font whose truename is really
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 "-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 but whose FONT property contains "Courier".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 So we disbelieve the FONT property unless it begins with a dash and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 is more than 30 characters long. X Windows: The defacto substandard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 X Windows: Complex nonsolutions to simple nonproblems. X Windows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 Live the nightmare.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 If the FONT property doesn't exist, then we try and construct an XLFD name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 out of the other font properties (FOUNDRY, FAMILY_NAME, WEIGHT_NAME, etc).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 This is necessary at least for some versions of OpenWound. But who knows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 what the future will bring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 If that doesn't work, then we use XListFonts and either take the first font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (which I think is the most sensible thing) or we find the lexicographically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 least, depending on whether the preprocessor constant `XOPENFONT_SORTS' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 defined. This sucks because the two behaviors are a property of the server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 being used, not the architecture on which emacs has been compiled. Also,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 as I described above, sorting isn't ALWAYS what the server does. Really it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 does something seemingly random. There is no reliable way to win if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 FONT property isn't present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 Another possibility which I haven't bothered to implement would be to map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 over all of the matching fonts and find the first one that has the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 character metrics as the font we already have loaded. Even if this didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 return exactly the same font, it would at least return one whose characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 were the same sizes, which would probably be good enough.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 More late-breaking news: on RS/6000 AIX 3.2.4, the expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 XLoadQueryFont (dpy, "-*-Fixed-Medium-R-*-*-*-130-75-75-*-*-ISO8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 actually returns the font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-80-ISO8859-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 which is crazy, because that font doesn't even match that pattern! It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 also not included in the output produced by `xlsfonts' with that pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 So this is yet another example of XListFonts() and XOpenFont() using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 completely different algorithms. This, however, is a goofier example of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 this bug, because in this case, it's not just the search order that is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 different -- the sets don't even intersect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 If anyone has any better ideas how to do this, or any insights on what it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 that the various servers are actually doing, please let me know! -- jwz. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 valid_x_font_name_p (Display *dpy, char *name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 /* Maybe this should be implemented by callign XLoadFont and trapping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 the error. That would be a lot of work, and wasteful as hell, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 might be more correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 int nnames = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 char **names = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 if (! name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 names = XListFonts (dpy, name, 1, &nnames);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 if (names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 XFreeFontNames (names);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 return (nnames != 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 truename_via_FONT_prop (Display *dpy, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 unsigned long value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 char *result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 if (XGetFontProperty (font, XA_FONT, &value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 result = XGetAtomName (dpy, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 /* result is now 0, or the string value of the FONT property. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 if (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 /* Verify that result is an XLFD name (roughly...) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 if (result [0] != '-' || strlen (result) < (unsigned int) 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 XFree (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 return result; /* this must be freed by caller if non-0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 truename_via_random_props (Display *dpy, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 struct device *d = get_device_from_display (dpy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 unsigned long value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 char *foundry, *family, *weight, *slant, *setwidth, *add_style;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 unsigned long pixel, point, res_x, res_y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 char *spacing;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 unsigned long avg_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 char *registry, *encoding;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 char composed_name [2048];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 int ok = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 char *result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 #define get_string(atom,var) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 if (XGetFontProperty (font, (atom), &value)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 var = XGetAtomName (dpy, value); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 else { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 var = 0; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 goto FAIL; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 #define get_number(atom,var) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 if (!XGetFontProperty (font, (atom), &var) || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 var > 999) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 goto FAIL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 foundry = family = weight = slant = setwidth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 add_style = spacing = registry = encoding = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 get_string (DEVICE_XATOM_FOUNDRY (d), foundry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 get_string (DEVICE_XATOM_FAMILY_NAME (d), family);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 get_string (DEVICE_XATOM_WEIGHT_NAME (d), weight);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 get_string (DEVICE_XATOM_SLANT (d), slant);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 get_string (DEVICE_XATOM_SETWIDTH_NAME (d), setwidth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 get_string (DEVICE_XATOM_ADD_STYLE_NAME (d), add_style);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 get_number (DEVICE_XATOM_PIXEL_SIZE (d), pixel);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 get_number (DEVICE_XATOM_POINT_SIZE (d), point);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 get_number (DEVICE_XATOM_RESOLUTION_X (d), res_x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 get_number (DEVICE_XATOM_RESOLUTION_Y (d), res_y);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 get_string (DEVICE_XATOM_SPACING (d), spacing);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 get_number (DEVICE_XATOM_AVERAGE_WIDTH (d), avg_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 get_string (DEVICE_XATOM_CHARSET_REGISTRY (d), registry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 get_string (DEVICE_XATOM_CHARSET_ENCODING (d), encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 #undef get_number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 #undef get_string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 sprintf (composed_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 "-%s-%s-%s-%s-%s-%s-%ld-%ld-%ld-%ld-%s-%ld-%s-%s",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 foundry, family, weight, slant, setwidth, add_style, pixel,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 point, res_x, res_y, spacing, avg_width, registry, encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ok = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 FAIL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 if (ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 int L = strlen (composed_name) + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 result = xmalloc (L);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 strncpy (result, composed_name, L);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 if (foundry) XFree (foundry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 if (family) XFree (family);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 if (weight) XFree (weight);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 if (slant) XFree (slant);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 if (setwidth) XFree (setwidth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 if (add_style) XFree (add_style);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 if (spacing) XFree (spacing);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 if (registry) XFree (registry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 if (encoding) XFree (encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 /* Unbounded, for sufficiently small values of infinity... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 #define MAX_FONT_COUNT 5000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 truename_via_XListFonts (Display *dpy, char *font_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 char *result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 char **names;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 int count = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 #ifndef XOPENFONT_SORTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 /* In a sensible world, the first font returned by XListFonts()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 would be the font that XOpenFont() would use. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 names = XListFonts (dpy, font_name, 1, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 if (count) result = names [0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 /* But the world I live in is much more perverse. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 names = XListFonts (dpy, font_name, MAX_FONT_COUNT, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 while (count--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 /* If names[count] is lexicographically less than result, use it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (#### Should we be comparing case-insensitively?) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 if (result == 0 || (strcmp (result, names [count]) < 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 result = names [count];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 if (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 result = xstrdup (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 if (names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 XFreeFontNames (names);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 return result; /* this must be freed by caller if non-0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 x_font_truename (Display *dpy, char *name, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 char *truename_FONT = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 char *truename_random = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 char *truename = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 /* The search order is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 - if FONT property exists, and is a valid name, return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 - if the other props exist, and add up to a valid name, return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 - if we find a matching name with XListFonts, return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 - if FONT property exists, return it regardless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 - if other props exist, return the resultant name regardless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 - else return 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 truename = truename_FONT = truename_via_FONT_prop (dpy, font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 if (truename && !valid_x_font_name_p (dpy, truename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 truename = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 if (!truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 truename = truename_random = truename_via_random_props (dpy, font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 if (truename && !valid_x_font_name_p (dpy, truename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 truename = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 if (!truename && name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 truename = truename_via_XListFonts (dpy, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 if (!truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 /* Gag - we weren't able to find a seemingly-valid truename.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 Well, maybe we're on one of those braindead systems where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 XListFonts() and XLoadFont() are in violent disagreement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 If we were able to compute a truename, try using that even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 if evidence suggests that it's not a valid name - because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 maybe it is, really, and that's better than nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 X Windows: You'll envy the dead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 if (truename_FONT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 truename = truename_FONT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 else if (truename_random)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 truename = truename_random;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 /* One or both of these are not being used - free them. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 if (truename_FONT && truename_FONT != truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 XFree (truename_FONT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 if (truename_random && truename_random != truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 XFree (truename_random);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 if (truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 Lisp_Object result = build_string (truename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 xfree (truename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 x_font_instance_truename (struct Lisp_Font_Instance *f, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 if (NILP (FONT_INSTANCE_X_TRUENAME (f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 Display *dpy = DEVICE_X_DISPLAY (d);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
671 char *name = (char *) XSTRING_DATA (f->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 FONT_INSTANCE_X_TRUENAME (f) =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 x_font_truename (dpy, name, FONT_INSTANCE_X_FONT (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 if (NILP (FONT_INSTANCE_X_TRUENAME (f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 Lisp_Object font_instance = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 XSETFONT_INSTANCE (font_instance, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 maybe_signal_simple_error ("couldn't determine font truename",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 font_instance, Qfont, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 /* Ok, just this once, return the font name as the truename.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (This is only used by Fequal() right now.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 return f->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 return (FONT_INSTANCE_X_TRUENAME (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 x_font_instance_properties (struct Lisp_Font_Instance *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 Lisp_Object result = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 XFontProp *props;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 Display *dpy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 dpy = DEVICE_X_DISPLAY (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 props = FONT_INSTANCE_X_FONT (f)->properties;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 char *name_str = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 char *val_str = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 Lisp_Object name, value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 Atom atom = props [i].name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 name_str = XGetAtomName (dpy, atom);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 name = (name_str ? intern (name_str) : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 if (name_str &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (atom == XA_FONT ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 atom == DEVICE_XATOM_FOUNDRY (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 atom == DEVICE_XATOM_FAMILY_NAME (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 atom == DEVICE_XATOM_WEIGHT_NAME (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 atom == DEVICE_XATOM_SLANT (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 atom == DEVICE_XATOM_SETWIDTH_NAME (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 atom == DEVICE_XATOM_ADD_STYLE_NAME (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 atom == DEVICE_XATOM_SPACING (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 atom == DEVICE_XATOM_CHARSET_REGISTRY (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 atom == DEVICE_XATOM_CHARSET_ENCODING (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 !strcmp (name_str, "CHARSET_COLLECTIONS") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 !strcmp (name_str, "FONTNAME_REGISTRY") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 !strcmp (name_str, "CLASSIFICATION") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 !strcmp (name_str, "COPYRIGHT") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 !strcmp (name_str, "DEVICE_FONT_NAME") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 !strcmp (name_str, "FULL_NAME") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 !strcmp (name_str, "MONOSPACED") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 !strcmp (name_str, "QUALITY") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 !strcmp (name_str, "RELATIVE_SET") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 !strcmp (name_str, "RELATIVE_WEIGHT") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 !strcmp (name_str, "STYLE")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 val_str = XGetAtomName (dpy, props [i].card32);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 value = (val_str ? build_string (val_str) : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 value = make_int (props [i].card32);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 if (name_str) XFree (name_str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 result = Fcons (Fcons (name, value), result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 x_list_fonts (Lisp_Object pattern, Lisp_Object device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 char **names;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 int count = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 Lisp_Object result = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 CONST char *patternext;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 GET_C_STRING_BINARY_DATA_ALLOCA (pattern, patternext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 patternext, MAX_FONT_COUNT, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 while (count--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 result = Fcons (build_ext_string (names [count], FORMAT_BINARY), result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 if (names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 XFreeFontNames (names);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 syms_of_objects_x (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 console_type_create_objects_x (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 /* object methods */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 CONSOLE_HAS_METHOD (x, initialize_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 CONSOLE_HAS_METHOD (x, print_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 CONSOLE_HAS_METHOD (x, finalize_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 CONSOLE_HAS_METHOD (x, color_instance_equal);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 CONSOLE_HAS_METHOD (x, color_instance_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 CONSOLE_HAS_METHOD (x, color_instance_rgb_components);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 CONSOLE_HAS_METHOD (x, valid_color_name_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 CONSOLE_HAS_METHOD (x, initialize_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 CONSOLE_HAS_METHOD (x, mark_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 CONSOLE_HAS_METHOD (x, print_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 CONSOLE_HAS_METHOD (x, finalize_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 CONSOLE_HAS_METHOD (x, font_instance_truename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 CONSOLE_HAS_METHOD (x, font_instance_properties);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 CONSOLE_HAS_METHOD (x, list_fonts);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 vars_of_objects_x (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 DEFVAR_BOOL ("x-handle-non-fully-specified-fonts",&handle_nonfull_spec_fonts /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 If this is true then fonts which do not have all characters specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 will be considered to be proportional width even if they are actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 fixed-width. If this is not done then characters which are supposed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 have 0 width may appear to actually have some width.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 Note: While setting this to t guarantees correct output in all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 circumstances, it also causes a noticeable performance hit when using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 fixed-width fonts. Since most people don't use characters which could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 cause problems this is set to nil by default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 handle_nonfull_spec_fonts = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 Xatoms_of_objects_x (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 #define ATOM(x) XInternAtom (DEVICE_X_DISPLAY (d), (x), False)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
816 #define ATOMIZE(x) DEVICE_XATOM_##x (d) = ATOM(#x)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
817 ATOMIZE (FOUNDRY);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
818 ATOMIZE (FAMILY_NAME);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
819 ATOMIZE (WEIGHT_NAME);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
820 ATOMIZE (SLANT);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
821 ATOMIZE (SETWIDTH_NAME);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
822 ATOMIZE (ADD_STYLE_NAME);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
823 ATOMIZE (PIXEL_SIZE);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
824 ATOMIZE (POINT_SIZE);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
825 ATOMIZE (RESOLUTION_X);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
826 ATOMIZE (RESOLUTION_Y);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
827 ATOMIZE (SPACING);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
828 ATOMIZE (AVERAGE_WIDTH);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
829 ATOMIZE (CHARSET_REGISTRY);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
830 ATOMIZE (CHARSET_ENCODING);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 }