annotate src/objects-x.c @ 3433:1e217fa4ad7d

[xemacs-hg @ 2006-05-30 06:21:31 by stephent] Preferred fix for dangling declaration. <8764jo59cu.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Tue, 30 May 2006 06:21:31 +0000
parents ac11131c6de9
children f986ebd9c080
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* X-specific Lisp objects.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 Copyright (C) 1995 Tinker Systems.
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
5 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 Copyright (C) 1995 Sun Microsystems, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 /* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 /* This file Mule-ized by Ben Wing, 7-10-00. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
30
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
34 #include "charset.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
35 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
36 #include "insdel.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
38 #include "console-x-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
39 #include "objects-x-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
41 #ifdef USE_XFT
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3286
diff changeset
42 #include "font-mgr.h"
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
43 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
44
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 int x_handle_non_fully_specified_fonts;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 /* color instances */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
52 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
53 x_parse_nearest_color (struct device *d, XColor *color, Lisp_Object name,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
54 Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 Colormap cmap = DEVICE_X_COLORMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 Visual *visual = DEVICE_X_VISUAL (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 int result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 xzero (*color);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 const Extbyte *extname;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
65 LISP_STRING_TO_EXTERNAL (name, extname, Qx_color_name_encoding);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 result = XParseColor (dpy, cmap, extname, color);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 if (!result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
70 maybe_signal_error (Qgui_error, "Unrecognized color",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
71 name, Qcolor, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
74 result = x_allocate_nearest_color (dpy, cmap, visual, color);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 if (!result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
77 maybe_signal_error (Qgui_error, "Couldn't allocate color",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
78 name, Qcolor, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
86 x_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
87 Lisp_Object device, Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 XColor color;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
90 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
91 XftColor xftColor;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
92 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 int result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
95 result = x_parse_nearest_color (XDEVICE (device), &color, name, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 if (!result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 /* Don't allocate the data until we're sure that we will succeed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 or the finalize method may get fucked. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 c->data = xnew (struct x_color_instance_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 if (result == 3)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 COLOR_INSTANCE_X_DEALLOC (c) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 COLOR_INSTANCE_X_DEALLOC (c) = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 COLOR_INSTANCE_X_COLOR (c) = color;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
108
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
109 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
110 xftColor.pixel = color.pixel;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
111 xftColor.color.red = color.red;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
112 xftColor.color.green = color.green;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
113 xftColor.color.blue = color.blue;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
114 xftColor.color.alpha = 0xffff;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
115
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
116 COLOR_INSTANCE_X_XFTCOLOR (c) = xftColor;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
117 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
118
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
123 x_print_color_instance (Lisp_Color_Instance *c,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
125 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 XColor color = COLOR_INSTANCE_X_COLOR (c);
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
128 write_fmt_string (printcharfun, " %ld=(%X,%X,%X)",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
129 color.pixel, color.red, color.green, color.blue);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
133 x_finalize_color_instance (Lisp_Color_Instance *c)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 if (c->data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 if (DEVICE_LIVE_P (XDEVICE (c->device)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 if (COLOR_INSTANCE_X_DEALLOC (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 XFreeColors (DEVICE_X_DISPLAY (XDEVICE (c->device)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 DEVICE_X_COLORMAP (XDEVICE (c->device)),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 &COLOR_INSTANCE_X_COLOR (c).pixel, 1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 }
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1701
diff changeset
146 xfree (c->data, void *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 c->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 /* Color instances are equal if they resolve to the same color on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 screen (have the same RGB values). I imagine that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 "same RGB values" == "same cell in the colormap." Arguably we should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 be comparing their names or pixel values instead. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
157 x_color_instance_equal (Lisp_Color_Instance *c1,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
158 Lisp_Color_Instance *c2,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
159 int UNUSED (depth))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 XColor color1 = COLOR_INSTANCE_X_COLOR (c1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 XColor color2 = COLOR_INSTANCE_X_COLOR (c2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 return ((color1.red == color2.red) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (color1.green == color2.green) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (color1.blue == color2.blue));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2367
diff changeset
168 static Hashcode
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
169 x_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 XColor color = COLOR_INSTANCE_X_COLOR (c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 return HASH3 (color.red, color.green, color.blue);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 static Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
176 x_color_instance_rgb_components (Lisp_Color_Instance *c)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 XColor color = COLOR_INSTANCE_X_COLOR (c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 return (list3 (make_int (color.red),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 make_int (color.green),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 make_int (color.blue)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 x_valid_color_name_p (struct device *d, Lisp_Object color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 XColor c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 Colormap cmap = DEVICE_X_COLORMAP (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
190 const Extbyte *extname;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
192 LISP_STRING_TO_EXTERNAL (color, extname, Qx_color_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
194 return XParseColor (dpy, cmap, extname, &c);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
197 static Lisp_Object
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
198 x_color_list (void)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
199 {
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
200 return call0 (intern ("x-color-list-internal"));
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
201 }
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
202
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 /* font instances */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
208 #ifdef USE_XFT
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3286
diff changeset
209 /* #### all these #defines should probably move to font-mgr.h */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
210
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
211 /*
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
212 The format of a fontname (as returned by fontconfig) is not well-documented,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
213 But the character repertoire is represented in an ASCII-compatible way. See
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
214 fccharset.c (FcCharSetUnparse). So we can use UTF-8 for long names.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
215
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
216 Currently we have a hack where different versions of the unparsed name are
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
217 used in different contexts fairly arbitrarily. I don't think this is close
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
218 to coherency; even without the charset and lang properties fontconfig names
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
219 are too unwieldy to use. We need to rethink the approach here. I think
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
220 probably Lisp_Font_Instance.name should contain the font name as specified
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
221 to Lisp (almost surely much shorter than shortname, even, and most likely
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
222 wildcarded), while Lisp_Font_Instance.truename should contain the longname.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
223 For now, I'm going to #ifdef the return values defaulting to short. -- sjt
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
224 */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
225
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
226 /* DEBUGGING STUFF */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
227
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
228 /* print message to stderr: one internal-format string argument */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
229 #define DEBUG_XFT0(level,s) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
230 if (debug_xft > level) stderr_out (s)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
231
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
232 /* print message to stderr: one formatted argument */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
233 #define DEBUG_XFT1(level,format,x1) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
234 if (debug_xft > level) stderr_out (format, x1)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
235
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
236 /* print message to stderr: two formatted arguments */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
237 #define DEBUG_XFT2(level,format,x1,x2) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
238 if (debug_xft > level) stderr_out (format, x1, x2)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
239
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
240 /* print message to stderr: three formatted arguments */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
241 #define DEBUG_XFT3(level,format,x1,x2,x3) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
242 if (debug_xft > level) stderr_out (format, x1, x2, x3)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
243
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
244 /* print message to stderr: four formatted arguments */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
245 #define DEBUG_XFT4(level,format,x1,x2,x3,x4) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
246 if (debug_xft > level) stderr_out (format, x1, x2, x3, x4)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
247
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
248 /* print an Xft pattern to stderr
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
249 LEVEL is the debug level (to compare to debug_xft)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
250 FORMAT is a newline-terminated printf format with one %s for the pattern
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
251 and must be internal format (eg, pure ASCII)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
252 PATTERN is an FcPattern *. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
253 #define PRINT_XFT_PATTERN(level,format,pattern) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
254 do { \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
255 DECLARE_EISTRING (eistrpxft_name); \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
256 FcChar8 *name = FcNameUnparse (pattern); \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
257 \
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
258 eicpy_ext(eistrpxft_name, name, Qfc_font_name_encoding); \
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
259 DEBUG_XFT1 (level, format, eidata(eistrpxft_name)); \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
260 free (name); \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
261 } while (0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
262
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
263 /* print a progress message
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
264 LEVEL is the debug level (to compare to debug_xft)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
265 FONT is the Xft font name in UTF-8 (the native encoding of Xft)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
266 LANG is the language being checked for support (must be ASCII). */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
267 #define CHECKING_LANG(level,font,lang) \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
268 do { \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
269 DECLARE_EISTRING (eistrcl_name); \
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
270 eicpy_ext(eistrcl_name, font, Qfc_font_name_encoding); \
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
271 DEBUG_XFT2 (level, "checking if %s handles %s\n", \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
272 eidata(eistrcl_name), lang); \
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
273 } while (0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
274
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
275 #endif /* USE_XFT */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
276
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
278 x_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object UNUSED (name),
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
279 Lisp_Object device, Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
281 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device));
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
282 Extbyte *extname;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
283 XFontStruct *fs = NULL; /* _F_ont _S_truct */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
284 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
285 XftFont *rf = NULL; /* _R_ender _F_ont (X Render extension) */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
286 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
287 #define rf (0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
288 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
290 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
291 DEBUG_XFT1 (2, "attempting to initialize font spec %s\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
292 XSTRING_DATA(f->name));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
293 /* #### serialize (optimize) these later... */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
294 /* #### This function really needs to go away.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
295 The problem is that the fontconfig/Xft functions work much too hard
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
296 to ensure that something is returned; but that something need not be
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
297 at all close to what we asked for. */
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
298 LISP_STRING_TO_EXTERNAL (f->name, extname, Qfc_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
299 rf = xft_open_font_by_name (dpy, extname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
300 #endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
301 LISP_STRING_TO_EXTERNAL (f->name, extname, Qx_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
302 fs = XLoadQueryFont (dpy, extname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
303
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
304 if (!fs && !rf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
306 /* #### should this refer to X and/or Xft? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
307 maybe_signal_error (Qgui_error, "Couldn't load font", f->name,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
308 Qfont, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
3389
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
312 if (rf && fs)
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
313 {
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
314 XFreeFont (dpy, fs);
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
315 fs = NULL; /* we don' need no steenkin' X font */
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
316 }
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
317
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
318 if (fs && !fs->max_bounds.width)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
319 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
320 /* yes, this has been known to happen. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
321 XFreeFont (dpy, fs);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
322 fs = NULL;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
323 maybe_signal_error (Qgui_error, "X font is too small", f->name, Qfont,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
324 errb);
3389
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
325 return 0;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
326 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
327
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
328 /* Now that we're sure that we will succeed, we can allocate data without
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
329 fear that the finalize method may get fucked. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 f->data = xnew (struct x_font_instance_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
332 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
333 FONT_INSTANCE_X_XFTFONT (f) = rf;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
334 if (rf)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
335 /* Have an Xft font, initialize font info from it. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
336 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
337 DEBUG_XFT4 (2, "pre-initial ascent %d descent %d width %d height %d\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
338 f->ascent, f->descent, f->width, f->height);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
340 /* #### This shit is just plain wrong unless we have a character cell
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
341 font. It really hoses us on large repertoire Unicode fonts with
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
342 "double-width" characters. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
343 f->ascent = rf->ascent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
344 f->descent = rf->descent;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
346 /* This is an approximation that AFAIK only gets used to compute
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
347 cell size for estimating window dimensions. The test_string8
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
348 is an ASCII string whose characters should approximate the
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
349 distribution of widths expected in real text. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
350 static const char test_string8[] = "Mmneei";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
351 static const int len = sizeof (test_string8) - 1;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
352 XGlyphInfo glyphinfo;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
353
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
354 XftTextExtents8 (dpy, rf, test_string8, len, &glyphinfo);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
355 /* #### maybe should be glyphinfo.xOff - glyphinfo.x? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
356 f->width = (2*glyphinfo.width + len)/(2*len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
358 f->height = rf->height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
359 f->proportional_p = 1; /* we can't recognize monospaced fonts! */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
360
3389
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
361 /* #### This message appears wa-a-ay too often!
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
362 We probably need to cache truenames or something?
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
363 Even if Xft does it for us, we cons too many font instances. */
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
364 DEBUG_XFT4 (0,
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
365 "initialized metrics ascent %d descent %d width %d height %d\n",
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
366 f->ascent, f->descent, f->width, f->height);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
367 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
368 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
369 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
370 DEBUG_XFT1 (0, "couldn't initialize Xft font %s\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
371 XSTRING_DATA(f->name));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
372 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
373 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
374
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
375 FONT_INSTANCE_X_FONT (f) = fs;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
376 if (fs)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
377 /* Have to use a core font, initialize font info from it. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
378 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
379 f->ascent = fs->ascent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
380 f->descent = fs->descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
381 f->height = fs->ascent + fs->descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
382 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
383 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
384 int def_char = 'n'; /*fs->default_char;*/
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
385 int byte1, byte2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
387 once_more:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
388 byte1 = def_char >> 8;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
389 byte2 = def_char & 0xFF;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
390
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
391 if (fs->per_char)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
392 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
393 /* Old versions of the R5 font server have garbage (>63k) as
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
394 def_char. 'n' might not be a valid character. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
395 if (byte1 < (int) fs->min_byte1 ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
396 byte1 > (int) fs->max_byte1 ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
397 byte2 < (int) fs->min_char_or_byte2 ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
398 byte2 > (int) fs->max_char_or_byte2)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
399 f->width = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
400 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
401 f->width = fs->per_char[(byte1 - fs->min_byte1) *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
402 (fs->max_char_or_byte2 -
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
403 fs->min_char_or_byte2 + 1) +
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
404 (byte2 - fs->min_char_or_byte2)].width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
405 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 else
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
407 f->width = fs->max_bounds.width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
408
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
409 /* Some fonts have a default char whose width is 0. This is no good.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
410 If that's the case, first try 'n' as the default char, and if n has
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
411 0 width too (unlikely) then just use the max width. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
412 if (f->width == 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
414 if (def_char == (int) fs->default_char)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
415 f->width = fs->max_bounds.width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
416 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
417 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
418 def_char = fs->default_char;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
419 goto once_more;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
420 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
423
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
424 /* If all characters don't exist then there could potentially be
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
425 0-width characters lurking out there. Not setting this flag
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
426 trips an optimization that would make them appear to have width
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
427 to redisplay. This is bad. So we set it if not all characters
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
428 have the same width or if not all characters are defined. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
429 /* #### This sucks. There is a measurable performance increase
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
430 when using proportional width fonts if this flag is not set.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
431 Unfortunately so many of the fucking X fonts are not fully
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
432 defined that we could almost just get rid of this damn flag and
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
433 make it an assertion. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
434 f->proportional_p = (fs->min_bounds.width != fs->max_bounds.width ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
435 (x_handle_non_fully_specified_fonts &&
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
436 !fs->all_chars_exist));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
437 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
438
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
439 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
440 if (debug_xft > 0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
441 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
442 int n = 3, d = 5;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
443 /* check for weirdness */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
444 if (n * f->height < d * f->width)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
445 stderr_out ("font %s: width:height is %d:%d, larger than %d:%d\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
446 XSTRING_DATA(f->name), f->width, f->height, n, d);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
447 if (f->height <= 0 || f->width <= 0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
448 stderr_out ("bogus dimensions of font %s: width = %d, height = %d\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
449 XSTRING_DATA(f->name), f->width, f->height);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
450 stderr_out ("initialized font %s\n", XSTRING_DATA(f->name));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
451 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
452 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
453 #undef rf
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
454 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
460 x_print_font_instance (Lisp_Font_Instance *f,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
462 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
464 if (FONT_INSTANCE_X_FONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
465 write_fmt_string (printcharfun, " font id: 0x%lx",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
466 (unsigned long) FONT_INSTANCE_X_FONT (f)->fid);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
467 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
468 /* #### What should we do here? For now, print the address. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
469 if (FONT_INSTANCE_X_XFTFONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
470 write_fmt_string (printcharfun, " xft font: 0x%lx",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
471 (unsigned long) FONT_INSTANCE_X_XFTFONT (f));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
472 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
476 x_finalize_font_instance (Lisp_Font_Instance *f)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
479 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
480 DEBUG_XFT1 (0, "finalizing %s\n", (STRINGP (f->name)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
481 ? (char *) XSTRING_DATA (f->name)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
482 : "(unnamed font)"));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
483 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
484
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 if (f->data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 if (DEVICE_LIVE_P (XDEVICE (f->device)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
491 if (FONT_INSTANCE_X_FONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
492 XFreeFont (dpy, FONT_INSTANCE_X_FONT (f));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
493 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
494 if (FONT_INSTANCE_X_XFTFONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
495 XftFontClose (dpy, FONT_INSTANCE_X_XFTFONT (f));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
496 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 }
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1701
diff changeset
498 xfree (f->data, void *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 f->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 /* Determining the truename of a font is hard. (Big surprise.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
505 This is not true for fontconfig. Each font has a (nearly) canonical
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
506 representation up to permutation of the order of properties. It is
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
507 possible to construct a name which exactly identifies the properties of
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
508 the current font. However, it is theoretically possible that there exists
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
509 another font with a super set of those properties that would happen to get
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
510 selected. -- sjt
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
511
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 By "truename" we mean an XLFD-form name which contains no wildcards, yet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 which resolves to *exactly* the same font as the one which we already have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 the (probably wildcarded) name and `XFontStruct' of.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 One might think that the first font returned by XListFonts would be the one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 that XOpenFont would pick. Apparently this is the case on some servers,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 but not on others. It would seem not to be specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 The MIT R5 server sometimes appears to be picking the lexicographically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 smallest font which matches the name (thus picking "adobe" fonts before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 "bitstream" fonts even if the bitstream fonts are earlier in the path, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 also picking 100dpi adobe fonts over 75dpi adobe fonts even though the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 75dpi are in the path earlier) but sometimes appears to be doing something
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
525 else entirely (for example, removing the bitstream fonts from the path will
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 cause the 75dpi adobe fonts to be used instead of the 100dpi, even though
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 their relative positions in the path (and their names!) have not changed).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 The documentation for XSetFontPath() seems to indicate that the order of
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
530 entries in the font path means something, but it's pretty noncommittal about
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 it, and the spirit of the law is apparently not being obeyed...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 All the fonts I've seen have a property named `FONT' which contains the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 truename of the font. However, there are two problems with using this: the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 first is that the X Protocol Document is quite explicit that all properties
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 are optional, so we can't depend on it being there. The second is that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 it's conceivable that this alleged truename isn't actually accessible as a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 font, due to some difference of opinion between the font designers and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 whoever installed the font on the system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 So, our first attempt is to look for a FONT property, and then verify that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 the name there is a valid name by running XListFonts on it. There's still
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 the potential that this could be true but we could still be being lied to,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 but that seems pretty remote.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 Late breaking news: I've gotten reports that SunOS 4.1.3U1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 with OpenWound 3.0 has a font whose truename is really
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 "-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 but whose FONT property contains "Courier".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 So we disbelieve the FONT property unless it begins with a dash and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 is more than 30 characters long. X Windows: The defacto substandard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 X Windows: Complex nonsolutions to simple nonproblems. X Windows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 Live the nightmare.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 If the FONT property doesn't exist, then we try and construct an XLFD name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 out of the other font properties (FOUNDRY, FAMILY_NAME, WEIGHT_NAME, etc).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 This is necessary at least for some versions of OpenWound. But who knows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 what the future will bring.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 If that doesn't work, then we use XListFonts and either take the first font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (which I think is the most sensible thing) or we find the lexicographically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 least, depending on whether the preprocessor constant `XOPENFONT_SORTS' is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 defined. This sucks because the two behaviors are a property of the server
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 being used, not the architecture on which emacs has been compiled. Also,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 as I described above, sorting isn't ALWAYS what the server does. Really it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 does something seemingly random. There is no reliable way to win if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 FONT property isn't present.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 Another possibility which I haven't bothered to implement would be to map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 over all of the matching fonts and find the first one that has the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 character metrics as the font we already have loaded. Even if this didn't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 return exactly the same font, it would at least return one whose characters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 were the same sizes, which would probably be good enough.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 More late-breaking news: on RS/6000 AIX 3.2.4, the expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 XLoadQueryFont (dpy, "-*-Fixed-Medium-R-*-*-*-130-75-75-*-*-ISO8859-1")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 actually returns the font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-80-ISO8859-1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 which is crazy, because that font doesn't even match that pattern! It is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 also not included in the output produced by `xlsfonts' with that pattern.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 So this is yet another example of XListFonts() and XOpenFont() using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 completely different algorithms. This, however, is a goofier example of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 this bug, because in this case, it's not just the search order that is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 different -- the sets don't even intersect.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 If anyone has any better ideas how to do this, or any insights on what it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 that the various servers are actually doing, please let me know! -- jwz. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
592 valid_x_font_name_p (Display *dpy, Extbyte *name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 /* Maybe this should be implemented by calling XLoadFont and trapping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 the error. That would be a lot of work, and wasteful as hell, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 might be more correct.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 int nnames = 0;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
599 Extbyte **names = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 if (! name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 names = XListFonts (dpy, name, 1, &nnames);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 if (names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 XFreeFontNames (names);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 return (nnames != 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
608 static Extbyte *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 truename_via_FONT_prop (Display *dpy, XFontStruct *font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 unsigned long value = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
612 Extbyte *result = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 if (XGetFontProperty (font, XA_FONT, &value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 result = XGetAtomName (dpy, value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 /* result is now 0, or the string value of the FONT property. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 if (result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 /* Verify that result is an XLFD name (roughly...) */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 578
diff changeset
619 if (result [0] != '-' || strlen (result) < 30)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 XFree (result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 result = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 return result; /* this must be freed by caller if non-0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 static Extbyte *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 truename_via_random_props (Display *dpy, XFontStruct *font)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 struct device *d = get_device_from_display (dpy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 unsigned long value = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 Extbyte *foundry, *family, *weight, *slant, *setwidth, *add_style;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 unsigned long pixel, point, res_x, res_y;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
635 Extbyte *spacing;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 unsigned long avg_width;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
637 Extbyte *registry, *encoding;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638 Extbyte composed_name [2048];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 int ok = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
640 Extbyte *result;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 #define get_string(atom,var) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 if (XGetFontProperty (font, (atom), &value)) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 var = XGetAtomName (dpy, value); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 else { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 var = 0; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 goto FAIL; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 #define get_number(atom,var) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 if (!XGetFontProperty (font, (atom), &var) || \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 var > 999) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 goto FAIL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 foundry = family = weight = slant = setwidth = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 add_style = spacing = registry = encoding = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 get_string (DEVICE_XATOM_FOUNDRY (d), foundry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 get_string (DEVICE_XATOM_FAMILY_NAME (d), family);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 get_string (DEVICE_XATOM_WEIGHT_NAME (d), weight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 get_string (DEVICE_XATOM_SLANT (d), slant);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 get_string (DEVICE_XATOM_SETWIDTH_NAME (d), setwidth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 get_string (DEVICE_XATOM_ADD_STYLE_NAME (d), add_style);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 get_number (DEVICE_XATOM_PIXEL_SIZE (d), pixel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 get_number (DEVICE_XATOM_POINT_SIZE (d), point);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 get_number (DEVICE_XATOM_RESOLUTION_X (d), res_x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 get_number (DEVICE_XATOM_RESOLUTION_Y (d), res_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 get_string (DEVICE_XATOM_SPACING (d), spacing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 get_number (DEVICE_XATOM_AVERAGE_WIDTH (d), avg_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 get_string (DEVICE_XATOM_CHARSET_REGISTRY (d), registry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 get_string (DEVICE_XATOM_CHARSET_ENCODING (d), encoding);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 #undef get_number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 #undef get_string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 sprintf (composed_name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 "-%s-%s-%s-%s-%s-%s-%ld-%ld-%ld-%ld-%s-%ld-%s-%s",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 foundry, family, weight, slant, setwidth, add_style, pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 point, res_x, res_y, spacing, avg_width, registry, encoding);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 ok = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 FAIL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 if (ok)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 int L = strlen (composed_name) + 1;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
683 result = xnew_extbytes (L);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 strncpy (result, composed_name, L);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 result = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 if (foundry) XFree (foundry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 if (family) XFree (family);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 if (weight) XFree (weight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 if (slant) XFree (slant);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 if (setwidth) XFree (setwidth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 if (add_style) XFree (add_style);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 if (spacing) XFree (spacing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 if (registry) XFree (registry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 if (encoding) XFree (encoding);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3169
5bfedec8927e [xemacs-hg @ 2005-12-24 17:33:31 by aidan]
aidan
parents: 3165
diff changeset
702 /* XListFonts doesn't allocate memory unconditionally based on this. (For
5bfedec8927e [xemacs-hg @ 2005-12-24 17:33:31 by aidan]
aidan
parents: 3165
diff changeset
703 XFree86 in 2005, at least. */
5bfedec8927e [xemacs-hg @ 2005-12-24 17:33:31 by aidan]
aidan
parents: 3165
diff changeset
704 #define MAX_FONT_COUNT INT_MAX
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
706 static Extbyte *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
707 truename_via_XListFonts (Display *dpy, Extbyte *font_name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
709 Extbyte *result = 0;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
710 Extbyte **names;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 int count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 #ifndef XOPENFONT_SORTS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 /* In a sensible world, the first font returned by XListFonts()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 would be the font that XOpenFont() would use. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 names = XListFonts (dpy, font_name, 1, &count);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 if (count) result = names [0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 /* But the world I live in is much more perverse. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 names = XListFonts (dpy, font_name, MAX_FONT_COUNT, &count);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
721 /* Find the lexicographic minimum of names[].
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
722 (#### Should we be comparing case-insensitively?) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 while (count--)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
724 /* [[ !!#### Not Mule-friendly ]]
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
725 Doesn't matter, XLFDs are HPC (old) or Latin1 (modern). If they
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
726 aren't, who knows what they are? -- sjt */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 if (result == 0 || (strcmp (result, names [count]) < 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 result = names [count];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 if (result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 result = xstrdup (result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 if (names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 XFreeFontNames (names);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 return result; /* this must be freed by caller if non-0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 static Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
740 x_font_truename (Display *dpy, Extbyte *name, XFontStruct *font)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
742 Extbyte *truename_FONT = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
743 Extbyte *truename_random = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
744 Extbyte *truename = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 /* The search order is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 - if FONT property exists, and is a valid name, return it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 - if the other props exist, and add up to a valid name, return it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 - if we find a matching name with XListFonts, return it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 - if FONT property exists, return it regardless.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 - if other props exist, return the resultant name regardless.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 - else return 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 truename = truename_FONT = truename_via_FONT_prop (dpy, font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 if (truename && !valid_x_font_name_p (dpy, truename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 truename = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 if (!truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 truename = truename_random = truename_via_random_props (dpy, font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 if (truename && !valid_x_font_name_p (dpy, truename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 truename = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 if (!truename && name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 truename = truename_via_XListFonts (dpy, name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 if (!truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 /* Gag - we weren't able to find a seemingly-valid truename.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 Well, maybe we're on one of those braindead systems where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 XListFonts() and XLoadFont() are in violent disagreement.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 If we were able to compute a truename, try using that even
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 if evidence suggests that it's not a valid name - because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 maybe it is, really, and that's better than nothing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 X Windows: You'll envy the dead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 if (truename_FONT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 truename = truename_FONT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 else if (truename_random)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 truename = truename_random;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 /* One or both of these are not being used - free them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 if (truename_FONT && truename_FONT != truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 XFree (truename_FONT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 if (truename_random && truename_random != truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 XFree (truename_random);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 if (truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
789 Lisp_Object result = build_ext_string (truename, Qx_font_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 XFree (truename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 static Lisp_Object
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
798 x_font_instance_truename (Lisp_Font_Instance *f, Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 struct device *d = XDEVICE (f->device);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
801 Display *dpy = DEVICE_X_DISPLAY (d);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
802 Extbyte *nameext;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
803
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
804 /* #### restructure this so that we return a valid truename at the end,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
805 and otherwise only return when we return something desperate that
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
806 doesn't get stored for future use. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
807
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
808 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
809 /* First, try an Xft font. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
810 if (NILP (FONT_INSTANCE_TRUENAME (f)) && FONT_INSTANCE_X_XFTFONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
811 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
812 /* The font is already open, we just unparse. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
813 FcChar8 *res = FcNameUnparse (FONT_INSTANCE_X_XFTFONT (f)->pattern);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
814 if (res)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
815 {
3174
588878f5a654 [xemacs-hg @ 2005-12-24 22:31:47 by aidan]
aidan
parents: 3169
diff changeset
816 FONT_INSTANCE_TRUENAME (f) =
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
817 build_ext_string (res, Qfc_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
818 free (res);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
819 return FONT_INSTANCE_TRUENAME (f);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
820 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
821 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
822 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
823 maybe_signal_error (Qgui_error,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
824 "Couldn't unparse Xft font to truename",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
825 Qnil, Qfont, errb);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
826 /* used to return Qnil here */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
827 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
828 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
829 #endif /* USE_XFT */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
830
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
831 /* OK, fall back to core font. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
832 if (NILP (FONT_INSTANCE_TRUENAME (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
833 && FONT_INSTANCE_X_FONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
834 {
3286
b3ab8c197518 [xemacs-hg @ 2006-03-17 14:30:43 by stephent]
stephent
parents: 3209
diff changeset
835 nameext = NEW_LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
836 FONT_INSTANCE_TRUENAME (f) =
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
837 x_font_truename (dpy, nameext, FONT_INSTANCE_X_FONT (f));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
838 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
840 if (NILP (FONT_INSTANCE_TRUENAME (f)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
842 /* Urk, no luck. Whine about our bad luck and exit. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
843 Lisp_Object font_instance = wrap_font_instance (f);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
844
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
845
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
846 maybe_signal_error (Qgui_error, "Couldn't determine font truename",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
847 font_instance, Qfont, errb);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
848 /* Ok, just this once, return the font name as the truename.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
849 (This is only used by Fequal() right now.) */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
850 return f->name;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
851 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
852
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
853 /* Return what we found. */
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
854 return FONT_INSTANCE_TRUENAME (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 static Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
858 x_font_instance_properties (Lisp_Font_Instance *f)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 Lisp_Object result = Qnil;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
863 Display *dpy = DEVICE_X_DISPLAY (d);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
864 XFontProp *props = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
866 /* #### really should hack Xft fonts, too
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
867 Strategy: fontconfig must have an iterator for this purpose. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
868 if (! FONT_INSTANCE_X_FONT (f)) return result;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
869
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
870 props = FONT_INSTANCE_X_FONT (f)->properties;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 Lisp_Object name, value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 Atom atom = props [i].name;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
875 Ibyte *name_str = 0;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 578
diff changeset
876 Bytecount name_len;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
877 Extbyte *namestrext = XGetAtomName (dpy, atom);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
878
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
879 if (namestrext)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
880 TO_INTERNAL_FORMAT (C_STRING, namestrext,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
881 ALLOCA, (name_str, name_len),
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
882 Qx_atom_name_encoding);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
883
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
884 name = (name_str ? intern_int (name_str) : Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 if (name_str &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 (atom == XA_FONT ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 atom == DEVICE_XATOM_FOUNDRY (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 atom == DEVICE_XATOM_FAMILY_NAME (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 atom == DEVICE_XATOM_WEIGHT_NAME (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 atom == DEVICE_XATOM_SLANT (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 atom == DEVICE_XATOM_SETWIDTH_NAME (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 atom == DEVICE_XATOM_ADD_STYLE_NAME (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 atom == DEVICE_XATOM_SPACING (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 atom == DEVICE_XATOM_CHARSET_REGISTRY (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 atom == DEVICE_XATOM_CHARSET_ENCODING (d) ||
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
896 !qxestrcmp_ascii (name_str, "CHARSET_COLLECTIONS") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
897 !qxestrcmp_ascii (name_str, "FONTNAME_REGISTRY") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
898 !qxestrcmp_ascii (name_str, "CLASSIFICATION") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
899 !qxestrcmp_ascii (name_str, "COPYRIGHT") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
900 !qxestrcmp_ascii (name_str, "DEVICE_FONT_NAME") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
901 !qxestrcmp_ascii (name_str, "FULL_NAME") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
902 !qxestrcmp_ascii (name_str, "MONOSPACED") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
903 !qxestrcmp_ascii (name_str, "QUALITY") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
904 !qxestrcmp_ascii (name_str, "RELATIVE_SET") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
905 !qxestrcmp_ascii (name_str, "RELATIVE_WEIGHT") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
906 !qxestrcmp_ascii (name_str, "STYLE")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
908 Extbyte *val_str = XGetAtomName (dpy, props [i].card32);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
909
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
910 value = (val_str ? build_ext_string (val_str, Qx_atom_name_encoding)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
911 : Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 value = make_int (props [i].card32);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
915 if (namestrext) XFree (namestrext);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 result = Fcons (Fcons (name, value), result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 static Lisp_Object
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
922 x_font_list (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
924 Extbyte **names;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 int count = 0;
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
926 int max_number = MAX_FONT_COUNT;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 Lisp_Object result = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
928 const Extbyte *patternext;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
930 LISP_STRING_TO_EXTERNAL (pattern, patternext, Qx_font_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
932 if (!NILP(maxnumber) && INTP(maxnumber))
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
933 {
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
934 max_number = XINT(maxnumber);
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
935 }
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
936
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)),
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
938 patternext, max_number, &count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 while (count--)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
940 result = Fcons (build_ext_string (names[count], Qx_font_name_encoding),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
941 result);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 if (names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 XFreeFontNames (names);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 static int
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
950 x_font_spec_matches_charset (struct device * USED_IF_XFT (d),
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
951 Lisp_Object charset,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
952 const Ibyte *nonreloc, Lisp_Object reloc,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
953 Bytecount offset, Bytecount length,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
954 int stage)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
956 if (stage)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
957 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
958 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
959 Display *dpy = DEVICE_X_DISPLAY (d);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
960 Extbyte *extname;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
961 XftFont *rf;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
962 const Ibyte *the_nonreloc;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
963
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
964 if (!NILP(reloc))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
965 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
966 the_nonreloc = XSTRING_DATA (reloc);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
967 LISP_STRING_TO_EXTERNAL (reloc, extname, Qx_font_name_encoding);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
968 rf = xft_open_font_by_name (dpy, extname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
969 return 0; /* #### maybe this will compile and run ;) */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
970 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
971 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
972 #else
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
973 return 0;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
974 #endif
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
975
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 if (UNBOUNDP (charset))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 /* Hack! Short font names don't have the registry in them,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 so we just assume the user knows what they're doing in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 case of ASCII. For other charsets, you gotta give the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 long form; sorry buster.
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
982 #### FMH: this screws fontconfig/Xft?
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
983 STRATEGY: use fontconfig's ability to hack languages and character
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
984 sets (lang and charset properties).
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
985 #### Maybe we can use the fontconfig model to eliminate the difference
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
986 between faces and fonts? No - it looks like that would be an abuse
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
987 (fontconfig doesn't know about colors, although Xft does).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 if (EQ (charset, Vcharset_ascii))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
991 const Ibyte *the_nonreloc = nonreloc;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 Bytecount the_length = length;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 if (!the_nonreloc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 the_nonreloc = XSTRING_DATA (reloc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 the_nonreloc += offset;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 if (!memchr (the_nonreloc, '*', the_length))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 for (i = 0;; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1003 const Ibyte *new_nonreloc = (const Ibyte *)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 memchr (the_nonreloc, '-', the_length);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 if (!new_nonreloc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 new_nonreloc++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 the_length -= new_nonreloc - the_nonreloc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 the_nonreloc = new_nonreloc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 /* If it has less than 5 dashes, it's a short font.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 Of course, long fonts always have 14 dashes or so, but short
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 fonts never have more than 1 or 2 dashes, so this is some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 sort of reasonable heuristic. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 if (i < 5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 return (fast_string_match (XCHARSET_REGISTRY (charset),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 nonreloc, reloc, offset, length, 1,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 ERROR_ME, 0) >= 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1026 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1027 /* #### debug functions: find a better place for us */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1028 const char *FcResultToString (FcResult r);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1029 const char *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1030 FcResultToString (FcResult r)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1031 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1032 static char buffer[256];
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1033 switch (r)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1034 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1035 case FcResultMatch:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1036 return "FcResultMatch";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1037 case FcResultNoMatch:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1038 return "FcResultNoMatch";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1039 case FcResultTypeMismatch:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1040 return "FcResultTypeMismatch";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1041 case FcResultNoId:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1042 return "FcResultNoId";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1043 default:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1044 snprintf (buffer, 255, "FcResultUndocumentedValue (%d)", r);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1045 return buffer;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1046 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1047 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1048
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1049 const char *FcTypeOfValueToString (FcValue v);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1050 const char *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1051 FcTypeOfValueToString (FcValue v)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1052 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1053 static char buffer[256];
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1054 switch (v.type)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1055 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1056 case FcTypeMatrix:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1057 return "FcTypeMatrix";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1058 case FcTypeString:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1059 return "FcTypeString";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1060 case FcTypeVoid:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1061 return "FcTypeVoid";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1062 case FcTypeDouble:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1063 return "FcTypeDouble";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1064 case FcTypeInteger:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1065 return "FcTypeInteger";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1066 case FcTypeBool:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1067 return "FcTypeBool";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1068 case FcTypeCharSet:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1069 return "FcTypeCharSet";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1070 case FcTypeLangSet:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1071 return "FcTypeLangSet";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1072 /* #### There is no union member of this type, but there are void* and
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1073 FcPattern* members, as of fontconfig.h FC_VERSION 10002 */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1074 case FcTypeFTFace:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1075 return "FcTypeFTFace";
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1076 default:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1077 snprintf (buffer, 255, "FcTypeUndocumentedType (%d)", v.type);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1078 return buffer;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1079 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1080 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1081
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1082 static FcCharSet *
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1083 mule_to_fc_charset (Lisp_Object cs)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1084 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1085 int ucode, i, j;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1086 FcCharSet *fccs;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1087
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1088 CHECK_CHARSET (cs);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1089 fccs = FcCharSetCreate ();
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1090 /* #### do we also need to deal with 94 vs. 96 charsets?
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1091 ie, how are SP and DEL treated in ASCII? non-graphic should return -1 */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1092 if (1 == XCHARSET_DIMENSION (cs))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1093 /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1094 for (i = 0; i < 96; i++)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1095 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1096 ucode = ((int *) XCHARSET_TO_UNICODE_TABLE (cs))[i];
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1097 if (ucode >= 0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1098 /* #### should check for allocation failure */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1099 FcCharSetAddChar (fccs, (FcChar32) ucode);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1100 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1101 else if (2 == XCHARSET_DIMENSION (cs))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1102 /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1103 for (i = 0; i < 96; i++)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1104 for (j = 0; j < 96; j++)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1105 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1106 ucode = ((int **) XCHARSET_TO_UNICODE_TABLE (cs))[i][j];
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1107 if (ucode >= 0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1108 /* #### should check for allocation failure */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1109 FcCharSetAddChar (fccs, (FcChar32) ucode);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1110 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1111 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1112 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1113 FcCharSetDestroy (fccs);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1114 fccs = NULL;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1115 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1116 return fccs;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1117 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1118
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1119 struct charset_reporter {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1120 Lisp_Object *charset;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1121 /* This is a debug facility, require ASCII. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1122 Extbyte *language; /* ASCII, please */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1123 FcChar8 *rfc3066; /* ASCII, please */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1124 };
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1125
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1126 static struct charset_reporter charset_table[] =
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1127 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1128 /* #### It's my branch, my favorite charsets get checked first!
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1129 That's a joke, Son.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1130 Ie, I don't know what I'm doing, so my charsets first is as good as
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1131 any other arbitrary order. If you have a better idea, speak up! */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1132 { &Vcharset_ascii, "English", "en" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1133 { &Vcharset_japanese_jisx0208, "Japanese", "ja" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1134 { &Vcharset_japanese_jisx0212, "Japanese", "ja" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1135 { &Vcharset_katakana_jisx0201, "Japanese", "ja" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1136 { &Vcharset_latin_jisx0201, "Japanese", "ja" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1137 { &Vcharset_japanese_jisx0208_1978, "Japanese", "ja" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1138 { &Vcharset_greek_iso8859_7, "Greek", "el" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1139 /* #### all the Chinese need checking
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1140 Damn the blood-sucking ISO anyway. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1141 { &Vcharset_chinese_gb2312, "simplified Chinese", "zh-CN" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1142 { &Vcharset_korean_ksc5601, "Korean", "ko" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1143 { &Vcharset_chinese_cns11643_1, "traditional Chinese", "zh-TW" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1144 { &Vcharset_chinese_cns11643_2, "traditional Chinese", "zh-TW" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1145 { &Vcharset_latin_iso8859_1, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1146 { &Vcharset_latin_iso8859_2, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1147 { &Vcharset_latin_iso8859_3, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1148 { &Vcharset_latin_iso8859_4, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1149 { &Vcharset_latin_iso8859_9, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1150 { &Vcharset_latin_iso8859_15, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1151 { &Vcharset_thai_tis620, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1152 { &Vcharset_arabic_iso8859_6, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1153 { &Vcharset_hebrew_iso8859_8, "Hebrew", "he" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1154 { &Vcharset_cyrillic_iso8859_5, NULL, NULL },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1155 /* #### these probably are not quite right */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1156 { &Vcharset_chinese_big5_1, "traditional Chinese", "zh-TW" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1157 { &Vcharset_chinese_big5_2, "traditional Chinese", "zh-TW" },
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1158 { NULL, NULL, NULL }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1159 };
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1160
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1161 /* Choose appropriate font name for debug messages.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1162 Use only in the top half of next function (enforced with #undef). */
3097
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1163 #define DECLARE_DEBUG_FONTNAME(__xemacs_name) \
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1164 Eistring *__xemacs_name; \
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1165 do \
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1166 { \
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1167 __xemacs_name = debug_xft > 2 ? eistr_fullname \
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1168 : debug_xft > 1 ? eistr_longname \
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1169 : eistr_shortname; \
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1170 } while (0)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1171
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1172 #endif /* USE_XFT */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1173
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 /* find a font spec that matches font spec FONT and also matches
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 (the registry of) CHARSET. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 static Lisp_Object
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1177 x_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1178 int stage)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1180 Extbyte **names;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 int count = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1182 const Extbyte *patternext;
3174
588878f5a654 [xemacs-hg @ 2005-12-24 22:31:47 by aidan]
aidan
parents: 3169
diff changeset
1183 Lisp_Object result = Qnil;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1186 /* #### with Xft need to handle second stage here -- sjt
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1187 Hm. Or maybe not. That would be cool. :-) */
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1188 if (stage)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1189 return Qnil;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1190
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1191 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1192 /* Fontconfig converts all FreeType names to UTF-8 before passing them
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1193 back to callers---see fcfreetype.c (FcFreeTypeQuery).
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1194 I don't believe this is documented. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1195
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1196 DEBUG_XFT1 (1, "confirming charset for font instance %s\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1197 XSTRING_DATA(font));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1198
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1199 /* #### this looks like a fair amount of work, but the basic design
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1200 has never been rethought, and it should be
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1201
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1202 what really should happen here is that we use FcFontSort (FcFontList?)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1203 to get a list of matching fonts, then pick the first (best) one that
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1204 gives language or repertoire coverage.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1205 */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1206
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1207 FcInit (); /* No-op if already initialized.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1208 In fontconfig 2.3.2, this cannot return
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1209 failure, but that looks like a bug. We
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1210 check for it with FcGetCurrentConfig(),
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1211 which *can* fail. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1212 if (!FcConfigGetCurrent()) /* #### We should expose FcInit* interfaces
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1213 to LISP and decide when to reinitialize
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1214 intelligently. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1215 stderr_out ("Failed fontconfig initialization\n");
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1216 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1217 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1218 FcPattern *fontxft; /* long-lived, freed at end of this block */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1219 FcResult fcresult;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1220 FcConfig *fcc;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1221 FcChar8 *lang = "en"; /* #### fix this bogus hack! */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1222 FcCharSet *fccs = NULL;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1223 DECLARE_EISTRING (eistr_shortname); /* user-friendly nickname */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1224 DECLARE_EISTRING (eistr_longname); /* omit FC_LANG and FC_CHARSET */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1225 DECLARE_EISTRING (eistr_fullname); /* everything */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1226
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
1227 LISP_STRING_TO_EXTERNAL (font, patternext, Qfc_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1228 fcc = FcConfigGetCurrent ();
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1229
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1230 /* parse the name, do the substitutions, and match the font */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1231
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1232 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1233 FcPattern *p = FcNameParse (patternext);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1234 PRINT_XFT_PATTERN (3, "FcNameParse'ed name is %s\n", p);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1235 /* #### Next two return FcBool, but what does the return mean? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1236 /* The order is correct according the fontconfig docs. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1237 FcConfigSubstitute (fcc, p, FcMatchPattern);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1238 PRINT_XFT_PATTERN (2, "FcConfigSubstitute'ed name is %s\n", p);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1239 FcDefaultSubstitute (p);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1240 PRINT_XFT_PATTERN (3, "FcDefaultSubstitute'ed name is %s\n", p);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1241 /* #### check fcresult of following match? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1242 fontxft = FcFontMatch (fcc, p, &fcresult);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1243 /* this prints the long fontconfig name */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1244 PRINT_XFT_PATTERN (1, "FcFontMatch'ed name is %s\n", fontxft);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1245 FcPatternDestroy (p);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1246 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1247
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1248 /* heuristic to give reasonable-length names for debug reports
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1249
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1250 I considered #ifdef SUPPORT_FULL_FONTCONFIG_NAME etc but that's
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1251 pointless. We're just going to remove this code once the font/
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1252 face refactoring is done, but until then it could be very useful.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1253 */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1254 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1255 FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1256 FcChar8 *name;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1257
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1258 /* full name, including language coverage and repertoire */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1259 name = FcNameUnparse (p);
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
1260 eicpy_ext (eistr_fullname, name, Qfc_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1261 free (name);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1262
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1263 /* long name, omitting coverage and repertoire, plus a number
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1264 of rarely useful properties */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1265 FcPatternDel (p, FC_CHARSET);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1266 FcPatternDel (p, FC_LANG);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1267 FcPatternDel (p, FC_WIDTH);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1268 FcPatternDel (p, FC_SPACING);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1269 FcPatternDel (p, FC_HINTING);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1270 FcPatternDel (p, FC_VERTICAL_LAYOUT);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1271 FcPatternDel (p, FC_AUTOHINT);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1272 FcPatternDel (p, FC_GLOBAL_ADVANCE);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1273 FcPatternDel (p, FC_INDEX);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1274 FcPatternDel (p, FC_SCALE);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1275 FcPatternDel (p, FC_FONTVERSION);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1276 name = FcNameUnparse (p);
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
1277 eicpy_ext (eistr_longname, name, Qfc_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1278 free (name);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1279
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1280 /* nickname, just family and size, but
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1281 "family" names usually have style, slant, and weight */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1282 FcPatternDel (p, FC_FOUNDRY);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1283 FcPatternDel (p, FC_STYLE);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1284 FcPatternDel (p, FC_SLANT);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1285 FcPatternDel (p, FC_WEIGHT);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1286 FcPatternDel (p, FC_PIXEL_SIZE);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1287 FcPatternDel (p, FC_OUTLINE);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1288 FcPatternDel (p, FC_SCALABLE);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1289 FcPatternDel (p, FC_DPI);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1290 name = FcNameUnparse (p);
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
1291 eicpy_ext (eistr_shortname, name, Qfc_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1292 free (name);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1293
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1294 FcPatternDestroy (p);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1295 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1296
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1297 /* The language approach may better in the long run, but we can't use
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1298 it based on Mule charsets; fontconfig doesn't provide a way to test
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1299 for unions of languages, etc. That will require support from the
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1300 text module.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1301
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1302 Optimization: cache the generated FcCharSet in the Mule charset.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1303 Don't forget to destroy it if the Mule charset gets deallocated. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1304
3433
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1305 {
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1306 /* This block possibly should be a function, but it generates
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1307 multiple values. I find the "pass an address to return the
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1308 value in" idiom opaque, so prefer a block. */
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1309 struct charset_reporter *cr;
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1310 for (cr = charset_table;
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1311 cr->charset && !EQ (*(cr->charset), charset);
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1312 cr++)
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1313 ;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1314
3433
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1315 if (cr->rfc3066)
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1316 {
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1317 DECLARE_DEBUG_FONTNAME (name);
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1318 CHECKING_LANG (0, eidata(name), cr->language);
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1319 lang = cr->rfc3066;
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1320 }
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1321 else if (cr->charset)
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1322 {
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1323 /* what the hey, build 'em on the fly */
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1324 /* #### in the case of error this could return NULL! */
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1325 fccs = mule_to_fc_charset (charset);
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1326 lang = XSTRING_DATA (XSYMBOL (XCHARSET_NAME (charset))-> name);
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1327 }
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1328 else
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1329 {
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1330 /* OK, we fell off the end of the table */
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1331 warn_when_safe_lispobj (intern ("xft"), intern ("alert"),
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1332 list2 (build_string ("unchecked charset"),
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1333 charset));
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1334 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1335 /* default to "en"
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1336 #### THIS IS WRONG, WRONG, WRONG!!
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1337 It is why we never fall through to XLFD-checking. */
3433
1e217fa4ad7d [xemacs-hg @ 2006-05-30 06:21:31 by stephent]
stephent
parents: 3423
diff changeset
1338 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1339
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1340 ASSERT_ASCTEXT_ASCII(lang);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1341
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1342 if (fccs)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1343 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1344 /* check for character set coverage */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1345 int i = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1346 FcCharSet *v;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1347 FcResult r = FcPatternGetCharSet (fontxft, FC_CHARSET, i, &v);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1348
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1349 if (r == FcResultTypeMismatch)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1350 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1351 DEBUG_XFT0 (0, "Unexpected type return in charset value\n");
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1352 result = Qnil;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1353 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1354 else if (r == FcResultMatch && FcCharSetIsSubset (fccs, v))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1355 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1356 /* The full pattern with the bitmap coverage is massively
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1357 unwieldy, but the shorter names are's just *wrong*. We
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1358 should have the full thing internally as truename, and
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1359 filter stuff the client doesn't want to see on output.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1360 Should we just store it into the truename right here? */
3097
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1361 DECLARE_DEBUG_FONTNAME (name);
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1362 DEBUG_XFT2 (0, "Xft font %s supports %s\n",
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1363 eidata(name), lang);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1364 #ifdef RETURN_LONG_FONTCONFIG_NAMES
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1365 result = eimake_string(eistr_fullname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1366 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1367 result = eimake_string(eistr_longname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1368 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1369 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1370 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1371 {
3097
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1372 DECLARE_DEBUG_FONTNAME (name);
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1373 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1374 eidata(name), lang);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1375 result = Qnil;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1376 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1377
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1378 /* clean up */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1379 FcCharSetDestroy (fccs);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1380 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1381 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1382 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1383 /* check for language coverage */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1384 int i = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1385 FcValue v;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1386 /* the main event */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1387 FcResult r = FcPatternGet (fontxft, FC_LANG, i, &v);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1388
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1389 if (r == FcResultMatch)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1390 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1391 if (v.type != FcTypeLangSet) /* excessive paranoia */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1392 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1393 ASSERT_ASCTEXT_ASCII(FcTypeOfValueToString(v));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1394 /* Urk! Fall back and punt to core font. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1395 DEBUG_XFT1 (0, "Unexpected type of lang value (%s)\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1396 FcTypeOfValueToString (v));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1397 result = Qnil;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1398 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1399 else if (FcLangSetHasLang (v.u.l, lang) != FcLangDifferentLang)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1400 {
3097
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1401 DECLARE_DEBUG_FONTNAME (name);
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1402 DEBUG_XFT2 (0, "Xft font %s supports %s\n",
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1403 eidata(name), lang);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1404 #ifdef RETURN_LONG_FONTCONFIG_NAMES
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1405 result = eimake_string(eistr_fullname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1406 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1407 result = eimake_string(eistr_longname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1408 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1409 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1410 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1411 {
3097
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1412 DECLARE_DEBUG_FONTNAME (name);
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1413 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1414 eidata(name), lang);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1415 result = Qnil;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1416 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1417 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1418 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1419 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1420 ASSERT_ASCTEXT_ASCII(FcResultToString(r));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1421 DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1422 FcResultToString (r));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1423 result = Qnil;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1424 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1425 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1426
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1427 /* clean up and maybe return */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1428 FcPatternDestroy (fontxft);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1429 if (!UNBOUNDP (result))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1430 return result;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1431 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1432
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1433 DEBUG_XFT1 (0, "shit happens, try X11 charset match for %s\n",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1434 XSTRING_DATA(font));
3097
859a2346db99 [xemacs-hg @ 2005-11-26 18:24:51 by stephent]
stephent
parents: 3094
diff changeset
1435 #undef DECLARE_DEBUG_FONTNAME
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1436 #endif /* USE_XFT */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1437
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1438 LISP_STRING_TO_EXTERNAL (font, patternext, Qx_font_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 patternext, MAX_FONT_COUNT, &count);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
1441 /* #### This code seems awfully bogus -- mrb */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1442 /* #### fontconfig does it better -- sjt */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 for (i = 0; i < count; i ++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
1445 const Ibyte *intname;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1446 Bytecount intlen;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1448 TO_INTERNAL_FORMAT (C_STRING, names[i],
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1449 ALLOCA, (intname, intlen),
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1450 Qx_font_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 if (x_font_spec_matches_charset (XDEVICE (device), charset,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1452 intname, Qnil, 0, -1, 0))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 {
3209
948bd302ca41 [xemacs-hg @ 2006-01-20 17:50:44 by crestani]
crestani
parents: 3174
diff changeset
1454 result = build_ext_string ((const Extbyte *) intname,
948bd302ca41 [xemacs-hg @ 2006-01-20 17:50:44 by crestani]
crestani
parents: 3174
diff changeset
1455 Qx_font_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 if (names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 XFreeFontNames (names);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 /* Check for a short font name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 if (NILP (result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 && x_font_spec_matches_charset (XDEVICE (device), charset, 0,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
1466 font, 0, -1, 0))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 return font;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 #endif /* MULE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 /* initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 syms_of_objects_x (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 console_type_create_objects_x (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 /* object methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 CONSOLE_HAS_METHOD (x, initialize_color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 CONSOLE_HAS_METHOD (x, print_color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 CONSOLE_HAS_METHOD (x, finalize_color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 CONSOLE_HAS_METHOD (x, color_instance_equal);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 CONSOLE_HAS_METHOD (x, color_instance_hash);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 CONSOLE_HAS_METHOD (x, color_instance_rgb_components);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 CONSOLE_HAS_METHOD (x, valid_color_name_p);
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
1496 CONSOLE_HAS_METHOD (x, color_list);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 CONSOLE_HAS_METHOD (x, initialize_font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 CONSOLE_HAS_METHOD (x, print_font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 CONSOLE_HAS_METHOD (x, finalize_font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 CONSOLE_HAS_METHOD (x, font_instance_truename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 CONSOLE_HAS_METHOD (x, font_instance_properties);
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
1503 CONSOLE_HAS_METHOD (x, font_list);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 CONSOLE_HAS_METHOD (x, find_charset_font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 CONSOLE_HAS_METHOD (x, font_spec_matches_charset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 vars_of_objects_x (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 DEFVAR_BOOL ("x-handle-non-fully-specified-fonts",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 &x_handle_non_fully_specified_fonts /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 If this is true then fonts which do not have all characters specified
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 will be considered to be proportional width even if they are actually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 fixed-width. If this is not done then characters which are supposed to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 have 0 width may appear to actually have some width.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 Note: While setting this to t guarantees correct output in all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 circumstances, it also causes a noticeable performance hit when using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 fixed-width fonts. Since most people don't use characters which could
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 cause problems this is set to nil by default.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 x_handle_non_fully_specified_fonts = 0;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1526
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1527 #ifdef USE_XFT
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1528 Fprovide (intern ("xft-fonts"));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
1529 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 Xatoms_of_objects_x (struct device *d)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 Display *D = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 DEVICE_XATOM_FOUNDRY (d) = XInternAtom (D, "FOUNDRY", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 DEVICE_XATOM_FAMILY_NAME (d) = XInternAtom (D, "FAMILY_NAME", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 DEVICE_XATOM_WEIGHT_NAME (d) = XInternAtom (D, "WEIGHT_NAME", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 DEVICE_XATOM_SLANT (d) = XInternAtom (D, "SLANT", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 DEVICE_XATOM_SETWIDTH_NAME (d) = XInternAtom (D, "SETWIDTH_NAME", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 DEVICE_XATOM_ADD_STYLE_NAME (d) = XInternAtom (D, "ADD_STYLE_NAME", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 DEVICE_XATOM_PIXEL_SIZE (d) = XInternAtom (D, "PIXEL_SIZE", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 DEVICE_XATOM_POINT_SIZE (d) = XInternAtom (D, "POINT_SIZE", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 DEVICE_XATOM_RESOLUTION_X (d) = XInternAtom (D, "RESOLUTION_X", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 DEVICE_XATOM_RESOLUTION_Y (d) = XInternAtom (D, "RESOLUTION_Y", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 DEVICE_XATOM_SPACING (d) = XInternAtom (D, "SPACING", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 DEVICE_XATOM_AVERAGE_WIDTH (d) = XInternAtom (D, "AVERAGE_WIDTH", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 DEVICE_XATOM_CHARSET_REGISTRY(d) = XInternAtom (D, "CHARSET_REGISTRY",False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 DEVICE_XATOM_CHARSET_ENCODING(d) = XInternAtom (D, "CHARSET_ENCODING",False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 }