annotate src/objects-x.c @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
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,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 string_data (XSTRING (name)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 string_length (XSTRING (name)),
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 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 unsigned int def_char = xf->default_char;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 int byte1, byte2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 once_more:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 byte1 = def_char >> 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 byte2 = def_char & 0xFF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 if (xf->per_char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 /* Old versions of the R5 font server have garbage (>63k) as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 def_char. 'n' might not be a valid character. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 if (byte1 < xf->min_byte1 || byte1 > xf->max_byte1 ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 byte2 < xf->min_char_or_byte2 || byte2 > xf->max_char_or_byte2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 f->width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 f->width = xf->per_char[(byte1 - xf->min_byte1) *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (xf->max_char_or_byte2 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 xf->min_char_or_byte2 + 1) +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (byte2 - xf->min_char_or_byte2)].width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 f->width = xf->max_bounds.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 /* 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
314 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
315 0 width too (unlikely) then just use the max width. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 if (f->width == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 if (def_char == 'n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 f->width = xf->max_bounds.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 def_char = 'n';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 goto once_more;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 }
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 /* If all characters don't exist then there could potentially be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 0-width characters lurking out there. Not setting this flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 trips an optimization that would make them appear to have width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 to redisplay. This is bad. So we set it if not all characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 have the same width or if not all characters are defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 /* #### This sucks. There is a measurable performance increase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 when using proportional width fonts if this flag is not set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 Unfortunately so many of the fucking X fonts are not fully
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 defined that we could almost just get rid of this damn flag and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 make it an assertion. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (handle_nonfull_spec_fonts &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 !xf->all_chars_exist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 x_mark_font_instance (struct Lisp_Font_Instance *f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 ((markobj) (FONT_INSTANCE_X_TRUENAME (f)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 x_print_font_instance (struct Lisp_Font_Instance *f,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 char buf[200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 sprintf (buf, " 0x%lx", (unsigned long) FONT_INSTANCE_X_FONT (f)->fid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 x_finalize_font_instance (struct Lisp_Font_Instance *f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 if (f->data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 if (DEVICE_LIVE_P (XDEVICE (f->device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 XFreeFont (dpy, FONT_INSTANCE_X_FONT (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 xfree (f->data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 f->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 }
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 /* Determining the truename of a font is hard. (Big surprise.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 By "truename" we mean an XLFD-form name which contains no wildcards, yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 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
383 the (probably wildcarded) name and `XFontStruct' of.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 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
386 that XOpenFont would pick. Apparently this is the case on some servers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 but not on others. It would seem not to be specified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 The MIT R5 server sometimes appears to be picking the lexicographically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 smallest font which matches the name (thus picking "adobe" fonts before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "bitstream" fonts even if the bitstream fonts are earlier in the path, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 also picking 100dpi adobe fonts over 75dpi adobe fonts even though the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 75dpi are in the path earlier) but sometimes appears to be doing something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 else entirely (for example, removing the bitsream fonts from the path will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 cause the 75dpi adobe fonts to be used instead of the100dpi, even though
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 their relative positions in the path (and their names!) have not changed).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 The documentation for XSetFontPath() seems to indicate that the order of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 entries in the font path means something, but it's pretty noncommital about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 it, and the spirit of the law is apparently not being obeyed...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 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
403 truename of the font. However, there are two problems with using this: the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 first is that the X Protocol Document is quite explicit that all properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 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
406 it's concievable that this alleged truename isn't actually accessible as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 font, due to some difference of opinion between the font designers and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 whoever installed the font on the system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 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
411 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
412 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
413 but that seems pretty remote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 Late breaking news: I've gotten reports that SunOS 4.1.3U1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 with OpenWound 3.0 has a font whose truename is really
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 but whose FONT property contains "Courier".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 So we disbelieve the FONT property unless it begins with a dash and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 is more than 30 characters long. X Windows: The defacto substandard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 X Windows: Complex nonsolutions to simple nonproblems. X Windows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 Live the nightmare.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 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
426 out of the other font properties (FOUNDRY, FAMILY_NAME, WEIGHT_NAME, etc).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 This is necessary at least for some versions of OpenWound. But who knows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 what the future will bring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 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
431 (which I think is the most sensible thing) or we find the lexicographically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 least, depending on whether the preprocessor constant `XOPENFONT_SORTS' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 defined. This sucks because the two behaviors are a property of the server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 being used, not the architecture on which emacs has been compiled. Also,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 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
436 does something seemingly random. There is no reliable way to win if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 FONT property isn't present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Another possibility which I haven't bothered to implement would be to map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 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
441 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
442 return exactly the same font, it would at least return one whose characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 were the same sizes, which would probably be good enough.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 More late-breaking news: on RS/6000 AIX 3.2.4, the expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 XLoadQueryFont (dpy, "-*-Fixed-Medium-R-*-*-*-130-75-75-*-*-ISO8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 actually returns the font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-80-ISO8859-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 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
450 also not included in the output produced by `xlsfonts' with that pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 So this is yet another example of XListFonts() and XOpenFont() using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 completely different algorithms. This, however, is a goofier example of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 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
455 different -- the sets don't even intersect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 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
458 that the various servers are actually doing, please let me know! -- jwz. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 valid_x_font_name_p (Display *dpy, char *name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 /* Maybe this should be implemented by callign XLoadFont and trapping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 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
465 might be more correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 int nnames = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 char **names = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 if (! name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 names = XListFonts (dpy, name, 1, &nnames);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 if (names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 XFreeFontNames (names);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 return (nnames != 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 truename_via_FONT_prop (Display *dpy, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 unsigned long value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 char *result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 if (XGetFontProperty (font, XA_FONT, &value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 result = XGetAtomName (dpy, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 /* result is now 0, or the string value of the FONT property. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 if (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 /* Verify that result is an XLFD name (roughly...) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 if (result [0] != '-' || strlen (result) < (unsigned int) 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 XFree (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 return result; /* this must be freed by caller if non-0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 truename_via_random_props (Display *dpy, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 struct device *d = get_device_from_display (dpy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 unsigned long value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 char *foundry, *family, *weight, *slant, *setwidth, *add_style;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 unsigned long pixel, point, res_x, res_y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 char *spacing;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 unsigned long avg_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 char *registry, *encoding;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 char composed_name [2048];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 int ok = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 char *result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 #define get_string(atom,var) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 if (XGetFontProperty (font, (atom), &value)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 var = XGetAtomName (dpy, value); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 else { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 var = 0; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 goto FAIL; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 #define get_number(atom,var) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 if (!XGetFontProperty (font, (atom), &var) || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 var > 999) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 goto FAIL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 foundry = family = weight = slant = setwidth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 add_style = spacing = registry = encoding = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 get_string (DEVICE_XATOM_FOUNDRY (d), foundry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 get_string (DEVICE_XATOM_FAMILY_NAME (d), family);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 get_string (DEVICE_XATOM_WEIGHT_NAME (d), weight);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 get_string (DEVICE_XATOM_SLANT (d), slant);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 get_string (DEVICE_XATOM_SETWIDTH_NAME (d), setwidth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 get_string (DEVICE_XATOM_ADD_STYLE_NAME (d), add_style);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 get_number (DEVICE_XATOM_PIXEL_SIZE (d), pixel);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 get_number (DEVICE_XATOM_POINT_SIZE (d), point);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 get_number (DEVICE_XATOM_RESOLUTION_X (d), res_x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 get_number (DEVICE_XATOM_RESOLUTION_Y (d), res_y);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 get_string (DEVICE_XATOM_SPACING (d), spacing);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 get_number (DEVICE_XATOM_AVERAGE_WIDTH (d), avg_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 get_string (DEVICE_XATOM_CHARSET_REGISTRY (d), registry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 get_string (DEVICE_XATOM_CHARSET_ENCODING (d), encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 #undef get_number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 #undef get_string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 sprintf (composed_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 "-%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
544 foundry, family, weight, slant, setwidth, add_style, pixel,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 point, res_x, res_y, spacing, avg_width, registry, encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ok = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 FAIL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 if (ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 int L = strlen (composed_name) + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 result = xmalloc (L);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 strncpy (result, composed_name, L);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 if (foundry) XFree (foundry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 if (family) XFree (family);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 if (weight) XFree (weight);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 if (slant) XFree (slant);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 if (setwidth) XFree (setwidth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 if (add_style) XFree (add_style);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 if (spacing) XFree (spacing);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 if (registry) XFree (registry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 if (encoding) XFree (encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 /* Unbounded, for sufficiently small values of infinity... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 #define MAX_FONT_COUNT 5000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 truename_via_XListFonts (Display *dpy, char *font_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 char *result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 char **names;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 int count = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 #ifndef XOPENFONT_SORTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 /* In a sensible world, the first font returned by XListFonts()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 would be the font that XOpenFont() would use. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 names = XListFonts (dpy, font_name, 1, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 if (count) result = names [0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 /* But the world I live in is much more perverse. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 names = XListFonts (dpy, font_name, MAX_FONT_COUNT, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 while (count--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 /* If names[count] is lexicographically less than result, use it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (#### Should we be comparing case-insensitively?) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 if (result == 0 || (strcmp (result, names [count]) < 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 result = names [count];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 if (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 result = xstrdup (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 if (names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 XFreeFontNames (names);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 return result; /* this must be freed by caller if non-0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 x_font_truename (Display *dpy, char *name, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 char *truename_FONT = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 char *truename_random = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 char *truename = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 /* The search order is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 - if FONT property exists, and is a valid name, return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 - 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
614 - if we find a matching name with XListFonts, return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 - if FONT property exists, return it regardless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 - if other props exist, return the resultant name regardless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 - else return 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 truename = truename_FONT = truename_via_FONT_prop (dpy, font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 if (truename && !valid_x_font_name_p (dpy, truename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 truename = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 if (!truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 truename = truename_random = truename_via_random_props (dpy, font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 if (truename && !valid_x_font_name_p (dpy, truename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 truename = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 if (!truename && name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 truename = truename_via_XListFonts (dpy, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 if (!truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 /* Gag - we weren't able to find a seemingly-valid truename.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 Well, maybe we're on one of those braindead systems where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 XListFonts() and XLoadFont() are in violent disagreement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 If we were able to compute a truename, try using that even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 if evidence suggests that it's not a valid name - because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 maybe it is, really, and that's better than nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 X Windows: You'll envy the dead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 if (truename_FONT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 truename = truename_FONT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 else if (truename_random)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 truename = truename_random;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 /* One or both of these are not being used - free them. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 if (truename_FONT && truename_FONT != truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 XFree (truename_FONT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 if (truename_random && truename_random != truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 XFree (truename_random);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 if (truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 Lisp_Object result = build_string (truename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 xfree (truename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 x_font_instance_truename (struct Lisp_Font_Instance *f, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 if (NILP (FONT_INSTANCE_X_TRUENAME (f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 Display *dpy = DEVICE_X_DISPLAY (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 char *name =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (char *) string_data (XSTRING (f->name));
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 Xatoms_of_objects_x (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 #define ATOM(x) XInternAtom (DEVICE_X_DISPLAY (d), (x), False)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 DEVICE_XATOM_FOUNDRY (d) = ATOM ("FOUNDRY");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 DEVICE_XATOM_FAMILY_NAME (d) = ATOM ("FAMILY_NAME");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 DEVICE_XATOM_WEIGHT_NAME (d) = ATOM ("WEIGHT_NAME");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 DEVICE_XATOM_SLANT (d) = ATOM ("SLANT");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 DEVICE_XATOM_SETWIDTH_NAME (d) = ATOM ("SETWIDTH_NAME");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 DEVICE_XATOM_ADD_STYLE_NAME (d) = ATOM ("ADD_STYLE_NAME");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 DEVICE_XATOM_PIXEL_SIZE (d) = ATOM ("PIXEL_SIZE");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 DEVICE_XATOM_POINT_SIZE (d) = ATOM ("POINT_SIZE");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 DEVICE_XATOM_RESOLUTION_X (d) = ATOM ("RESOLUTION_X");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 DEVICE_XATOM_RESOLUTION_Y (d) = ATOM ("RESOLUTION_Y");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 DEVICE_XATOM_SPACING (d) = ATOM ("SPACING");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 DEVICE_XATOM_AVERAGE_WIDTH (d) = ATOM ("AVERAGE_WIDTH");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 DEVICE_XATOM_CHARSET_REGISTRY (d) = ATOM ("CHARSET_REGISTRY");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 DEVICE_XATOM_CHARSET_ENCODING (d) = ATOM ("CHARSET_ENCODING");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 }