annotate src/objects-x.c @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 74fd4e045ea6
children 697ef44129c6
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
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
39 int x_handle_non_fully_specified_fonts;
0
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
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
47 available color if the colormap is full. Original was from FSFmacs,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
48 but rewritten by Jareth Hein <jareth@camelot-soft.com> 97/11/25
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
49 Modified by Lee Kindness <lkindness@csl.co.uk> 31/08/99 to handle previous
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
50 total failure which was due to a read/write colorcell being the nearest
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
51 match - tries the next nearest...
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
53 Return value is 1 for normal success, 2 for nearest color success,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
54 3 for Non-deallocable sucess. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 int
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
56 allocate_nearest_color (Display *display, Colormap colormap, Visual *visual,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 XColor *color_def)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 int status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
61 if (visual->class == DirectColor || visual->class == TrueColor)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 {
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
63 if (XAllocColor (display, colormap, color_def) != 0)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
64 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
65 status = 1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
66 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
67 else
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
68 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
69 /* We're dealing with a TrueColor/DirectColor visual, so play games
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
70 with the RGB values in the XColor struct. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
71 /* #### JH: I'm not sure how a call to XAllocColor can fail in a
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
72 TrueColor or DirectColor visual, so I will just reformat the
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
73 request to match the requirements of the visual, and re-issue
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
74 the request. If this fails for anybody, I wanna know about it
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
75 so I can come up with a better plan */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
77 unsigned long rshift,gshift,bshift,rbits,gbits,bbits,junk;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
78 junk = visual->red_mask;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
79 rshift = 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
80 while ((junk & 0x1) == 0) {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
81 junk = junk >> 1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
82 rshift ++;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
83 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
84 rbits = 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
85 while (junk != 0) {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
86 junk = junk >> 1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
87 rbits++;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
88 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
89 junk = visual->green_mask;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
90 gshift = 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
91 while ((junk & 0x1) == 0) {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
92 junk = junk >> 1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
93 gshift ++;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
94 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
95 gbits = 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
96 while (junk != 0) {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
97 junk = junk >> 1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
98 gbits++;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
99 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
100 junk = visual->blue_mask;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
101 bshift = 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
102 while ((junk & 0x1) == 0) {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
103 junk = junk >> 1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
104 bshift ++;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
105 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
106 bbits = 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
107 while (junk != 0) {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
108 junk = junk >> 1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
109 bbits++;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
110 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
111
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
112 color_def->red = color_def->red >> (16 - rbits);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
113 color_def->green = color_def->green >> (16 - gbits);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
114 color_def->blue = color_def->blue >> (16 - bbits);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
115 if (XAllocColor (display, colormap, color_def) != 0)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
116 status = 1;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
117 else
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
118 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
119 int rd, gr, bl;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
120 /* #### JH: I'm punting here, knowing that doing this will at
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
121 least draw the color correctly. However, unless we convert
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
122 all of the functions that allocate colors (graphics
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
123 libraries, etc) to use this function doing this is very
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
124 likely to cause problems later... */
269
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
125
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
126 if (rbits > 8)
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
127 rd = color_def->red << (rbits - 8);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
128 else
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
129 rd = color_def->red >> (8 - rbits);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
130 if (gbits > 8)
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
131 gr = color_def->green << (gbits - 8);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
132 else
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
133 gr = color_def->green >> (8 - gbits);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
134 if (bbits > 8)
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
135 bl = color_def->blue << (bbits - 8);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
136 else
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
137 bl = color_def->blue >> (8 - bbits);
b2472a1930f2 Import from CVS: tag r20-5b33
cvs
parents: 219
diff changeset
138 color_def->pixel = (rd << rshift) | (gr << gshift) | (bl << bshift);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
139 status = 3;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
143 else
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
144 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
145 XColor *cells = NULL;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
146 /* JH: I can't believe there's no way to go backwards from a
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
147 colormap ID and get its visual and number of entries, but X
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
148 apparently isn't built that way... */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
149 int no_cells = visual->map_entries;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
150 status = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
151
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
152 if (XAllocColor (display, colormap, color_def) != 0)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
153 status = 1;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
154 else while( status != 2 )
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
155 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
156 /* If we got to this point, the colormap is full, so we're
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
157 going to try and get the next closest color. The algorithm used
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
158 is a least-squares matching, which is what X uses for closest
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
159 color matching with StaticColor visuals. */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
160 int nearest;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
161 long nearest_delta, trial_delta;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
162 int x;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
164 if( cells == NULL )
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
165 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
166 cells = alloca_array (XColor, no_cells);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
167 for (x = 0; x < no_cells; x++)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
168 cells[x].pixel = x;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
169
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
170 /* read the current colormap */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
171 XQueryColors (display, colormap, cells, no_cells);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
172 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
173
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
174 nearest = 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
175 /* I'm assuming CSE so I'm not going to condense this. */
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
176 nearest_delta = ((((color_def->red >> 8) - (cells[0].red >> 8))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
177 * ((color_def->red >> 8) - (cells[0].red >> 8)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
178 +
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
179 (((color_def->green >> 8) - (cells[0].green >> 8))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
180 * ((color_def->green >> 8) - (cells[0].green >> 8)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
181 +
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
182 (((color_def->blue >> 8) - (cells[0].blue >> 8))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
183 * ((color_def->blue >> 8) - (cells[0].blue >> 8))));
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
184 for (x = 1; x < no_cells; x++)
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
185 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
186 trial_delta = ((((color_def->red >> 8) - (cells[x].red >> 8))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
187 * ((color_def->red >> 8) - (cells[x].red >> 8)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
188 +
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
189 (((color_def->green >> 8) - (cells[x].green >> 8))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
190 * ((color_def->green >> 8) - (cells[x].green >> 8)))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
191 +
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
192 (((color_def->blue >> 8) - (cells[x].blue >> 8))
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
193 * ((color_def->blue >> 8) - (cells[x].blue >> 8))));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
194
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
195 /* less? Ignore cells marked as previously failing */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
196 if( (trial_delta < nearest_delta) &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
197 (cells[x].pixel != ULONG_MAX) )
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
198 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
199 nearest = x;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
200 nearest_delta = trial_delta;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
201 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
202 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
203 color_def->red = cells[nearest].red;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
204 color_def->green = cells[nearest].green;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
205 color_def->blue = cells[nearest].blue;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
206 if (XAllocColor (display, colormap, color_def) != 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
207 status = 2;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
208 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
209 /* LSK: Either the colour map has changed since
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
210 * we read it, or the colour is allocated
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
211 * read/write... Mark this cmap entry so it's
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
212 * ignored in the next iteration.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
213 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
214 cells[nearest].pixel = ULONG_MAX;
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
215 }
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
216 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 return status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 x_parse_nearest_color (struct device *d, XColor *color, Bufbyte *name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 Bytecount len, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
224 Display *dpy = DEVICE_X_DISPLAY (d);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
225 Colormap cmap = DEVICE_X_COLORMAP (d);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
226 Visual *visual = DEVICE_X_VISUAL (d);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 int result;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
228
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
229 xzero (*color);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
231 const Extbyte *extname;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 Extcount extnamelen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
234 TO_EXTERNAL_FORMAT (DATA, (name, len),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
235 ALLOCA, (extname, extnamelen),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
236 Qbinary);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 result = XParseColor (dpy, cmap, (char *) extname, color);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 if (!result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
241 maybe_signal_simple_error ("Unrecognized color", make_string (name, len),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 Qcolor, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 }
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
245 result = allocate_nearest_color (dpy, cmap, visual, color);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 if (!result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
248 maybe_signal_simple_error ("Couldn't allocate color",
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 make_string (name, len), Qcolor, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
253 return result;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 static int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
257 x_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 Lisp_Object device, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 XColor color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 int result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 result = x_parse_nearest_color (XDEVICE (device), &color,
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
264 XSTRING_DATA (name),
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
265 XSTRING_LENGTH (name),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 if (!result)
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 /* Don't allocate the data until we're sure that we will succeed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 or the finalize method may get fucked. */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
273 c->data = xnew (struct x_color_instance_data);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
274 if (result == 3)
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
275 COLOR_INSTANCE_X_DEALLOC (c) = 0;
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
276 else
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
277 COLOR_INSTANCE_X_DEALLOC (c) = 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 COLOR_INSTANCE_X_COLOR (c) = color;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
283 x_print_color_instance (Lisp_Color_Instance *c,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 char buf[100];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 XColor color = COLOR_INSTANCE_X_COLOR (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 sprintf (buf, " %ld=(%X,%X,%X)",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 color.pixel, color.red, color.green, color.blue);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
295 x_finalize_color_instance (Lisp_Color_Instance *c)
0
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 (c->data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 if (DEVICE_LIVE_P (XDEVICE (c->device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
301 if (COLOR_INSTANCE_X_DEALLOC (c))
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
302 {
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
303 XFreeColors (DEVICE_X_DISPLAY (XDEVICE (c->device)), DEVICE_X_COLORMAP (XDEVICE (c->device)),
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
304 &COLOR_INSTANCE_X_COLOR (c).pixel, 1, 0);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
305 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 xfree (c->data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 c->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 /* Color instances are equal if they resolve to the same color on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 screen (have the same RGB values). I imagine that
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
314 "same RGB values" == "same cell in the colormap." Arguably we should
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
315 be comparing their names or pixel values instead. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 static int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
318 x_color_instance_equal (Lisp_Color_Instance *c1,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
319 Lisp_Color_Instance *c2,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 XColor color1 = COLOR_INSTANCE_X_COLOR (c1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 XColor color2 = COLOR_INSTANCE_X_COLOR (c2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 return ((color1.red == color2.red) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (color1.green == color2.green) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (color1.blue == color2.blue));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 static unsigned long
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
330 x_color_instance_hash (Lisp_Color_Instance *c, int depth)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 XColor color = COLOR_INSTANCE_X_COLOR (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 return HASH3 (color.red, color.green, color.blue);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 static Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
337 x_color_instance_rgb_components (Lisp_Color_Instance *c)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 XColor color = COLOR_INSTANCE_X_COLOR (c);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
340 return (list3 (make_int (color.red),
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 make_int (color.green),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 make_int (color.blue)));
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 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 x_valid_color_name_p (struct device *d, Lisp_Object color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 XColor c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 Display *dpy = DEVICE_X_DISPLAY (d);
219
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
350 Colormap cmap = DEVICE_X_COLORMAP (d);
262b8bb4a523 Import from CVS: tag r20-4b8
cvs
parents: 185
diff changeset
351
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
352 const char *extname;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
353
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
354 TO_EXTERNAL_FORMAT (LISP_STRING, color, C_STRING_ALLOCA, extname, Qctext);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
356 return XParseColor (dpy, cmap, extname, &c);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 /* font instances */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 static int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
365 x_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 Lisp_Object device, Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
368 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 XFontStruct *xf;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
370 const char *extname;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
371
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
372 TO_EXTERNAL_FORMAT (LISP_STRING, f->name, C_STRING_ALLOCA, extname, Qctext);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 xf = XLoadQueryFont (dpy, extname);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
374
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 if (!xf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
377 maybe_signal_simple_error ("Couldn't load font", f->name,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 Qfont, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
381
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 if (!xf->max_bounds.width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 /* yes, this has been known to happen. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 XFreeFont (dpy, xf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 maybe_signal_simple_error ("X font is too small", f->name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 Qfont, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
390
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 /* Don't allocate the data until we're sure that we will succeed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 or the finalize method may get fucked. */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
393 f->data = xnew (struct x_font_instance_data);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 FONT_INSTANCE_X_TRUENAME (f) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 FONT_INSTANCE_X_FONT (f) = xf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 f->ascent = xf->ascent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 f->descent = xf->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 f->height = xf->ascent + xf->descent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
400 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
401 unsigned int def_char = 'n'; /*xf->default_char;*/
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
402 unsigned int byte1, byte2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 once_more:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 byte1 = def_char >> 8;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 byte2 = def_char & 0xFF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 if (xf->per_char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 /* Old versions of the R5 font server have garbage (>63k) as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 def_char. 'n' might not be a valid character. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
412 if (byte1 < xf->min_byte1 ||
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
413 byte1 > xf->max_byte1 ||
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
414 byte2 < xf->min_char_or_byte2 ||
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
415 byte2 > xf->max_char_or_byte2)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 f->width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 f->width = xf->per_char[(byte1 - xf->min_byte1) *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (xf->max_char_or_byte2 -
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 xf->min_char_or_byte2 + 1) +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (byte2 - xf->min_char_or_byte2)].width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 f->width = xf->max_bounds.width;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
425
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 /* 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
427 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
428 0 width too (unlikely) then just use the max width. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 if (f->width == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
431 if (def_char == xf->default_char)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 f->width = xf->max_bounds.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 {
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
435 def_char = xf->default_char;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 goto once_more;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 /* If all characters don't exist then there could potentially be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 0-width characters lurking out there. Not setting this flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 trips an optimization that would make them appear to have width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 to redisplay. This is bad. So we set it if not all characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 have the same width or if not all characters are defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 /* #### This sucks. There is a measurable performance increase
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 when using proportional width fonts if this flag is not set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 Unfortunately so many of the fucking X fonts are not fully
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 defined that we could almost just get rid of this damn flag and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 make it an assertion. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width ||
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
452 (x_handle_non_fully_specified_fonts &&
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 !xf->all_chars_exist));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
459 x_mark_font_instance (Lisp_Font_Instance *f)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
461 mark_object (FONT_INSTANCE_X_TRUENAME (f));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
465 x_print_font_instance (Lisp_Font_Instance *f,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 char buf[200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 sprintf (buf, " 0x%lx", (unsigned long) FONT_INSTANCE_X_FONT (f)->fid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 static void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
475 x_finalize_font_instance (Lisp_Font_Instance *f)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
477
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 if (f->data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 if (DEVICE_LIVE_P (XDEVICE (f->device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 XFreeFont (dpy, FONT_INSTANCE_X_FONT (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 xfree (f->data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 f->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 /* Determining the truename of a font is hard. (Big surprise.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 By "truename" we mean an XLFD-form name which contains no wildcards, yet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 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
495 the (probably wildcarded) name and `XFontStruct' of.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 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
498 that XOpenFont would pick. Apparently this is the case on some servers,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 but not on others. It would seem not to be specified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 The MIT R5 server sometimes appears to be picking the lexicographically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 smallest font which matches the name (thus picking "adobe" fonts before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 "bitstream" fonts even if the bitstream fonts are earlier in the path, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 also picking 100dpi adobe fonts over 75dpi adobe fonts even though the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 75dpi are in the path earlier) but sometimes appears to be doing something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 else entirely (for example, removing the bitsream fonts from the path will
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
507 cause the 75dpi adobe fonts to be used instead of the 100dpi, even though
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 their relative positions in the path (and their names!) have not changed).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 The documentation for XSetFontPath() seems to indicate that the order of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 entries in the font path means something, but it's pretty noncommital about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 it, and the spirit of the law is apparently not being obeyed...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 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
515 truename of the font. However, there are two problems with using this: the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 first is that the X Protocol Document is quite explicit that all properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 are optional, so we can't depend on it being there. The second is that
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
518 it's conceivable that this alleged truename isn't actually accessible as a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 font, due to some difference of opinion between the font designers and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 whoever installed the font on the system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 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
523 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
524 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
525 but that seems pretty remote.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 Late breaking news: I've gotten reports that SunOS 4.1.3U1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 with OpenWound 3.0 has a font whose truename is really
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 "-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 but whose FONT property contains "Courier".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 So we disbelieve the FONT property unless it begins with a dash and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 is more than 30 characters long. X Windows: The defacto substandard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 X Windows: Complex nonsolutions to simple nonproblems. X Windows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 Live the nightmare.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 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
538 out of the other font properties (FOUNDRY, FAMILY_NAME, WEIGHT_NAME, etc).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 This is necessary at least for some versions of OpenWound. But who knows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 what the future will bring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 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
543 (which I think is the most sensible thing) or we find the lexicographically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 least, depending on whether the preprocessor constant `XOPENFONT_SORTS' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 defined. This sucks because the two behaviors are a property of the server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 being used, not the architecture on which emacs has been compiled. Also,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 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
548 does something seemingly random. There is no reliable way to win if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 FONT property isn't present.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 Another possibility which I haven't bothered to implement would be to map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 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
553 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
554 return exactly the same font, it would at least return one whose characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 were the same sizes, which would probably be good enough.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 More late-breaking news: on RS/6000 AIX 3.2.4, the expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 XLoadQueryFont (dpy, "-*-Fixed-Medium-R-*-*-*-130-75-75-*-*-ISO8859-1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 actually returns the font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-80-ISO8859-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 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
562 also not included in the output produced by `xlsfonts' with that pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 So this is yet another example of XListFonts() and XOpenFont() using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 completely different algorithms. This, however, is a goofier example of
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
566 this bug, because in this case, it's not just the search order that is
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 different -- the sets don't even intersect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 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
570 that the various servers are actually doing, please let me know! -- jwz. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 valid_x_font_name_p (Display *dpy, char *name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
575 /* Maybe this should be implemented by calling XLoadFont and trapping
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 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
577 might be more correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 int nnames = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 char **names = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 if (! name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 names = XListFonts (dpy, name, 1, &nnames);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 if (names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 XFreeFontNames (names);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 return (nnames != 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 truename_via_FONT_prop (Display *dpy, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 unsigned long value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 char *result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 if (XGetFontProperty (font, XA_FONT, &value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 result = XGetAtomName (dpy, value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 /* result is now 0, or the string value of the FONT property. */
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 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 /* Verify that result is an XLFD name (roughly...) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 if (result [0] != '-' || strlen (result) < (unsigned int) 30)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 XFree (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 return result; /* this must be freed by caller if non-0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 truename_via_random_props (Display *dpy, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 struct device *d = get_device_from_display (dpy);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 unsigned long value = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 char *foundry, *family, *weight, *slant, *setwidth, *add_style;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 unsigned long pixel, point, res_x, res_y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 char *spacing;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 unsigned long avg_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 char *registry, *encoding;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 char composed_name [2048];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 int ok = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 char *result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 #define get_string(atom,var) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 if (XGetFontProperty (font, (atom), &value)) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 var = XGetAtomName (dpy, value); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 else { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 var = 0; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 goto FAIL; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 #define get_number(atom,var) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 if (!XGetFontProperty (font, (atom), &var) || \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 var > 999) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 goto FAIL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 foundry = family = weight = slant = setwidth = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 add_style = spacing = registry = encoding = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 get_string (DEVICE_XATOM_FOUNDRY (d), foundry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 get_string (DEVICE_XATOM_FAMILY_NAME (d), family);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 get_string (DEVICE_XATOM_WEIGHT_NAME (d), weight);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 get_string (DEVICE_XATOM_SLANT (d), slant);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 get_string (DEVICE_XATOM_SETWIDTH_NAME (d), setwidth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 get_string (DEVICE_XATOM_ADD_STYLE_NAME (d), add_style);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 get_number (DEVICE_XATOM_PIXEL_SIZE (d), pixel);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 get_number (DEVICE_XATOM_POINT_SIZE (d), point);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 get_number (DEVICE_XATOM_RESOLUTION_X (d), res_x);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 get_number (DEVICE_XATOM_RESOLUTION_Y (d), res_y);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 get_string (DEVICE_XATOM_SPACING (d), spacing);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 get_number (DEVICE_XATOM_AVERAGE_WIDTH (d), avg_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 get_string (DEVICE_XATOM_CHARSET_REGISTRY (d), registry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 get_string (DEVICE_XATOM_CHARSET_ENCODING (d), encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 #undef get_number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 #undef get_string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 sprintf (composed_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 "-%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
656 foundry, family, weight, slant, setwidth, add_style, pixel,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 point, res_x, res_y, spacing, avg_width, registry, encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ok = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 FAIL:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 if (ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 int L = strlen (composed_name) + 1;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
664 result = (char *) xmalloc (L);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 strncpy (result, composed_name, L);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 if (foundry) XFree (foundry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 if (family) XFree (family);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 if (weight) XFree (weight);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 if (slant) XFree (slant);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 if (setwidth) XFree (setwidth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 if (add_style) XFree (add_style);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 if (spacing) XFree (spacing);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 if (registry) XFree (registry);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 if (encoding) XFree (encoding);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 /* Unbounded, for sufficiently small values of infinity... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 #define MAX_FONT_COUNT 5000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 static char *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 truename_via_XListFonts (Display *dpy, char *font_name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 char *result = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 char **names;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 int count = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 #ifndef XOPENFONT_SORTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 /* In a sensible world, the first font returned by XListFonts()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 would be the font that XOpenFont() would use. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 names = XListFonts (dpy, font_name, 1, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 if (count) result = names [0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 /* But the world I live in is much more perverse. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 names = XListFonts (dpy, font_name, MAX_FONT_COUNT, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 while (count--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 /* If names[count] is lexicographically less than result, use it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (#### Should we be comparing case-insensitively?) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 if (result == 0 || (strcmp (result, names [count]) < 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 result = names [count];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 if (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 result = xstrdup (result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 if (names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 XFreeFontNames (names);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 return result; /* this must be freed by caller if non-0 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 x_font_truename (Display *dpy, char *name, XFontStruct *font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 char *truename_FONT = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 char *truename_random = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 char *truename = 0;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
722
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 /* The search order is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 - if FONT property exists, and is a valid name, return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 - 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
726 - if we find a matching name with XListFonts, return it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 - if FONT property exists, return it regardless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 - if other props exist, return the resultant name regardless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 - else return 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 truename = truename_FONT = truename_via_FONT_prop (dpy, font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 if (truename && !valid_x_font_name_p (dpy, truename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 truename = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 if (!truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 truename = truename_random = truename_via_random_props (dpy, font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 if (truename && !valid_x_font_name_p (dpy, truename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 truename = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 if (!truename && name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 truename = truename_via_XListFonts (dpy, name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 if (!truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 /* Gag - we weren't able to find a seemingly-valid truename.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 Well, maybe we're on one of those braindead systems where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 XListFonts() and XLoadFont() are in violent disagreement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 If we were able to compute a truename, try using that even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 if evidence suggests that it's not a valid name - because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 maybe it is, really, and that's better than nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 X Windows: You'll envy the dead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 if (truename_FONT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 truename = truename_FONT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 else if (truename_random)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 truename = truename_random;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 /* One or both of these are not being used - free them. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 if (truename_FONT && truename_FONT != truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 XFree (truename_FONT);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 if (truename_random && truename_random != truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 XFree (truename_random);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 if (truename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 Lisp_Object result = build_string (truename);
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 80
diff changeset
767 XFree (truename);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 static Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
775 x_font_instance_truename (Lisp_Font_Instance *f, Error_behavior errb)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 if (NILP (FONT_INSTANCE_X_TRUENAME (f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 Display *dpy = DEVICE_X_DISPLAY (d);
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
782 char *name = (char *) XSTRING_DATA (f->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 FONT_INSTANCE_X_TRUENAME (f) =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 x_font_truename (dpy, name, FONT_INSTANCE_X_FONT (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 if (NILP (FONT_INSTANCE_X_TRUENAME (f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
789 Lisp_Object font_instance;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 XSETFONT_INSTANCE (font_instance, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 371
diff changeset
792 maybe_signal_simple_error ("Couldn't determine font truename",
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 font_instance, Qfont, errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 /* Ok, just this once, return the font name as the truename.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (This is only used by Fequal() right now.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 return f->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 return (FONT_INSTANCE_X_TRUENAME (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 static Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
803 x_font_instance_properties (Lisp_Font_Instance *f)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 struct device *d = XDEVICE (f->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 Lisp_Object result = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 XFontProp *props;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 Display *dpy;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
810
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 dpy = DEVICE_X_DISPLAY (d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 props = FONT_INSTANCE_X_FONT (f)->properties;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 char *name_str = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 char *val_str = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 Lisp_Object name, value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 Atom atom = props [i].name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 name_str = XGetAtomName (dpy, atom);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 name = (name_str ? intern (name_str) : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 if (name_str &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (atom == XA_FONT ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 atom == DEVICE_XATOM_FOUNDRY (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 atom == DEVICE_XATOM_FAMILY_NAME (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 atom == DEVICE_XATOM_WEIGHT_NAME (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 atom == DEVICE_XATOM_SLANT (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 atom == DEVICE_XATOM_SETWIDTH_NAME (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 atom == DEVICE_XATOM_ADD_STYLE_NAME (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 atom == DEVICE_XATOM_SPACING (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 atom == DEVICE_XATOM_CHARSET_REGISTRY (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 atom == DEVICE_XATOM_CHARSET_ENCODING (d) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 !strcmp (name_str, "CHARSET_COLLECTIONS") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 !strcmp (name_str, "FONTNAME_REGISTRY") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 !strcmp (name_str, "CLASSIFICATION") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 !strcmp (name_str, "COPYRIGHT") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 !strcmp (name_str, "DEVICE_FONT_NAME") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 !strcmp (name_str, "FULL_NAME") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 !strcmp (name_str, "MONOSPACED") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 !strcmp (name_str, "QUALITY") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 !strcmp (name_str, "RELATIVE_SET") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 !strcmp (name_str, "RELATIVE_WEIGHT") ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 !strcmp (name_str, "STYLE")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 val_str = XGetAtomName (dpy, props [i].card32);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 value = (val_str ? build_string (val_str) : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 value = make_int (props [i].card32);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 if (name_str) XFree (name_str);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 result = Fcons (Fcons (name, value), result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 x_list_fonts (Lisp_Object pattern, Lisp_Object device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 char **names;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 int count = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 Lisp_Object result = Qnil;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
861 const char *patternext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
863 TO_EXTERNAL_FORMAT (LISP_STRING, pattern,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
864 C_STRING_ALLOCA, patternext,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
865 Qbinary);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
866
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 patternext, MAX_FONT_COUNT, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 while (count--)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
870 result = Fcons (build_ext_string (names [count], Qbinary), result);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 if (names)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 XFreeFontNames (names);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
876 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
877
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
878 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
879 x_font_spec_matches_charset (struct device *d, Lisp_Object charset,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
880 const Bufbyte *nonreloc, Lisp_Object reloc,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
881 Bytecount offset, Bytecount length)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
882 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
883 if (UNBOUNDP (charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
884 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
885 /* Hack! Short font names don't have the registry in them,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
886 so we just assume the user knows what they're doing in the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
887 case of ASCII. For other charsets, you gotta give the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
888 long form; sorry buster.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
889 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
890 if (EQ (charset, Vcharset_ascii))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
891 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
892 const Bufbyte *the_nonreloc = nonreloc;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
893 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
894 Bytecount the_length = length;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
895
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
896 if (!the_nonreloc)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
897 the_nonreloc = XSTRING_DATA (reloc);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
898 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
899 the_nonreloc += offset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
900 if (!memchr (the_nonreloc, '*', the_length))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
901 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
902 for (i = 0;; i++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
903 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
904 const Bufbyte *new_nonreloc = (const Bufbyte *)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
905 memchr (the_nonreloc, '-', the_length);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
906 if (!new_nonreloc)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
907 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
908 new_nonreloc++;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
909 the_length -= new_nonreloc - the_nonreloc;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
910 the_nonreloc = new_nonreloc;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
911 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
912
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
913 /* If it has less than 5 dashes, it's a short font.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
914 Of course, long fonts always have 14 dashes or so, but short
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
915 fonts never have more than 1 or 2 dashes, so this is some
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
916 sort of reasonable heuristic. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
917 if (i < 5)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
918 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
919 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
920 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
921
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
922 return (fast_string_match (XCHARSET_REGISTRY (charset),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
923 nonreloc, reloc, offset, length, 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
924 ERROR_ME, 0) >= 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
925 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
926
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
927 /* find a font spec that matches font spec FONT and also matches
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
928 (the registry of) CHARSET. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
929 static Lisp_Object
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
930 x_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
931 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
932 char **names;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
933 int count = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
934 Lisp_Object result = Qnil;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
935 const char *patternext;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
936 int i;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
937
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
938 TO_EXTERNAL_FORMAT (LISP_STRING, font,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
939 C_STRING_ALLOCA, patternext,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
940 Qbinary);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
941
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
942 names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
943 patternext, MAX_FONT_COUNT, &count);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
944 /* #### This code seems awfully bogus -- mrb */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
945 for (i = 0; i < count; i ++)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
946 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
947 const char *intname;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
948
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
949 TO_INTERNAL_FORMAT (C_STRING, names[i],
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
950 C_STRING_ALLOCA, intname,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
951 Qbinary);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
952 if (x_font_spec_matches_charset (XDEVICE (device), charset,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
953 (Bufbyte *) intname, Qnil, 0, -1))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
954 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
955 result = build_string (intname);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
956 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
957 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
958 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
959
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
960 if (names)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
961 XFreeFontNames (names);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
962
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
963 /* Check for a short font name. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
964 if (NILP (result)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
965 && x_font_spec_matches_charset (XDEVICE (device), charset, 0,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
966 font, 0, -1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
967 return font;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
968
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
969 return result;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
970 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
971
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
972 #endif /* MULE */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
973
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 syms_of_objects_x (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 console_type_create_objects_x (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 /* object methods */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 CONSOLE_HAS_METHOD (x, initialize_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 CONSOLE_HAS_METHOD (x, print_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 CONSOLE_HAS_METHOD (x, finalize_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 CONSOLE_HAS_METHOD (x, color_instance_equal);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 CONSOLE_HAS_METHOD (x, color_instance_hash);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 CONSOLE_HAS_METHOD (x, color_instance_rgb_components);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 CONSOLE_HAS_METHOD (x, valid_color_name_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 CONSOLE_HAS_METHOD (x, initialize_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 CONSOLE_HAS_METHOD (x, mark_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 CONSOLE_HAS_METHOD (x, print_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 CONSOLE_HAS_METHOD (x, finalize_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 CONSOLE_HAS_METHOD (x, font_instance_truename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 CONSOLE_HAS_METHOD (x, font_instance_properties);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 CONSOLE_HAS_METHOD (x, list_fonts);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
1004 #ifdef MULE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
1005 CONSOLE_HAS_METHOD (x, find_charset_font);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
1006 CONSOLE_HAS_METHOD (x, font_spec_matches_charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 14
diff changeset
1007 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 vars_of_objects_x (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1013 DEFVAR_BOOL ("x-handle-non-fully-specified-fonts",
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1014 &x_handle_non_fully_specified_fonts /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 If this is true then fonts which do not have all characters specified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 will be considered to be proportional width even if they are actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 fixed-width. If this is not done then characters which are supposed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 have 0 width may appear to actually have some width.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 Note: While setting this to t guarantees correct output in all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 circumstances, it also causes a noticeable performance hit when using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 fixed-width fonts. Since most people don't use characters which could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 cause problems this is set to nil by default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 */ );
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 269
diff changeset
1025 x_handle_non_fully_specified_fonts = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 Xatoms_of_objects_x (struct device *d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1031 Display *D = DEVICE_X_DISPLAY (d);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 149
diff changeset
1032
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1033 DEVICE_XATOM_FOUNDRY (d) = XInternAtom (D, "FOUNDRY", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1034 DEVICE_XATOM_FAMILY_NAME (d) = XInternAtom (D, "FAMILY_NAME", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1035 DEVICE_XATOM_WEIGHT_NAME (d) = XInternAtom (D, "WEIGHT_NAME", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1036 DEVICE_XATOM_SLANT (d) = XInternAtom (D, "SLANT", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1037 DEVICE_XATOM_SETWIDTH_NAME (d) = XInternAtom (D, "SETWIDTH_NAME", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1038 DEVICE_XATOM_ADD_STYLE_NAME (d) = XInternAtom (D, "ADD_STYLE_NAME", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1039 DEVICE_XATOM_PIXEL_SIZE (d) = XInternAtom (D, "PIXEL_SIZE", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1040 DEVICE_XATOM_POINT_SIZE (d) = XInternAtom (D, "POINT_SIZE", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1041 DEVICE_XATOM_RESOLUTION_X (d) = XInternAtom (D, "RESOLUTION_X", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1042 DEVICE_XATOM_RESOLUTION_Y (d) = XInternAtom (D, "RESOLUTION_Y", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1043 DEVICE_XATOM_SPACING (d) = XInternAtom (D, "SPACING", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1044 DEVICE_XATOM_AVERAGE_WIDTH (d) = XInternAtom (D, "AVERAGE_WIDTH", False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1045 DEVICE_XATOM_CHARSET_REGISTRY(d) = XInternAtom (D, "CHARSET_REGISTRY",False);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 100
diff changeset
1046 DEVICE_XATOM_CHARSET_ENCODING(d) = XInternAtom (D, "CHARSET_ENCODING",False);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 }