annotate src/fontcolor-x.c @ 5936:574f0cded429 cygwin

try to replace all nnnL or nnnUL constants with EMACS_[U]INT
author Henry Thompson <ht@markup.co.uk>
date Sun, 13 Dec 2015 13:22:58 +0000
parents 6928877dbc26
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
1 /* X-specific fonts and colors.
428
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.
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
5 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004, 2010 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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5189
diff changeset
10 XEmacs is free software: you can redistribute it and/or modify it
428
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5189
diff changeset
12 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5189
diff changeset
13 option) any later version.
428
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5189
diff changeset
21 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
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 /* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
27 /* This file Mule-ized by Ben Wing, 7-10-00. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
28
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
32 #include "charset.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
33 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
34 #include "insdel.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
36 #include "console-x-impl.h"
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
37 #include "fontcolor-x-impl.h"
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
38 #include "elhash.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
40 #ifdef HAVE_XFT
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents: 3286
diff changeset
41 #include "font-mgr.h"
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
42 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
43
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 int x_handle_non_fully_specified_fonts;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
46 #ifdef DEBUG_XEMACS
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
47 Fixnum debug_x_fonts;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
48 #endif /* DEBUG_XEMACS */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
49
428
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 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 /* color instances */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
55 static int
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
56 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
57 Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 Colormap cmap = DEVICE_X_COLORMAP (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 Visual *visual = DEVICE_X_VISUAL (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 int result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 xzero (*color);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 const Extbyte *extname;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4969
diff changeset
68 extname = LISP_STRING_TO_EXTERNAL (name, Qx_color_name_encoding);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 result = XParseColor (dpy, cmap, extname, color);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 if (!result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
73 maybe_signal_error (Qgui_error, "Unrecognized color",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
74 name, Qcolor, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
77 result = x_allocate_nearest_color (dpy, cmap, visual, color);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 if (!result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 444
diff changeset
80 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
81 name, Qcolor, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 return 0;
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 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
89 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
90 Lisp_Object device, Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 XColor color;
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
93 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
94 XftColor xftColor;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
95 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 int result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
98 result = x_parse_nearest_color (XDEVICE (device), &color, name, errb);
428
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 if (!result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 /* 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
104 or the finalize method may get fucked. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 c->data = xnew (struct x_color_instance_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 if (result == 3)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 COLOR_INSTANCE_X_DEALLOC (c) = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 COLOR_INSTANCE_X_DEALLOC (c) = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 COLOR_INSTANCE_X_COLOR (c) = color;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
111
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
112 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
113 xftColor.pixel = color.pixel;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
114 xftColor.color.red = color.red;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
115 xftColor.color.green = color.green;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
116 xftColor.color.blue = color.blue;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
117 xftColor.color.alpha = 0xffff;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
118
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
119 COLOR_INSTANCE_X_XFTCOLOR (c) = xftColor;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
120 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
121
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
126 x_print_color_instance (Lisp_Color_Instance *c,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
128 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 XColor color = COLOR_INSTANCE_X_COLOR (c);
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
131 write_fmt_string (printcharfun, " %ld=(%X,%X,%X)",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
132 color.pixel, color.red, color.green, color.blue);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 }
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 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
136 x_finalize_color_instance (Lisp_Color_Instance *c)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 if (c->data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 if (DEVICE_LIVE_P (XDEVICE (c->device)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 if (COLOR_INSTANCE_X_DEALLOC (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 XFreeColors (DEVICE_X_DISPLAY (XDEVICE (c->device)),
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 DEVICE_X_COLORMAP (XDEVICE (c->device)),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 &COLOR_INSTANCE_X_COLOR (c).pixel, 1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 }
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4969
diff changeset
149 xfree (c->data);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 c->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 /* 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
155 screen (have the same RGB values). I imagine that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 "same RGB values" == "same cell in the colormap." Arguably we should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 be comparing their names or pixel values instead. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 static int
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
160 x_color_instance_equal (Lisp_Color_Instance *c1,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
161 Lisp_Color_Instance *c2,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
162 int UNUSED (depth))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 XColor color1 = COLOR_INSTANCE_X_COLOR (c1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 XColor color2 = COLOR_INSTANCE_X_COLOR (c2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 return ((color1.red == color2.red) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (color1.green == color2.green) &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (color1.blue == color2.blue));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2367
diff changeset
171 static Hashcode
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
172 x_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth))
428
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 XColor color = COLOR_INSTANCE_X_COLOR (c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 return HASH3 (color.red, color.green, color.blue);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 }
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 static Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
179 x_color_instance_rgb_components (Lisp_Color_Instance *c)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 XColor color = COLOR_INSTANCE_X_COLOR (c);
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
182 return (list3 (make_fixnum (color.red),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
183 make_fixnum (color.green),
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
184 make_fixnum (color.blue)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 }
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 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 x_valid_color_name_p (struct device *d, Lisp_Object color)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 XColor c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 Display *dpy = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 Colormap cmap = DEVICE_X_COLORMAP (d);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
193 const Extbyte *extname;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4969
diff changeset
195 extname = LISP_STRING_TO_EXTERNAL (color, Qx_color_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
197 return XParseColor (dpy, cmap, extname, &c);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
200 static Lisp_Object
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
201 x_color_list (void)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
202 {
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
203 return call0 (intern ("x-color-list-internal"));
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
204 }
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
205
428
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 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 /* font instances */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
211
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
213 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
214 Lisp_Object device, Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
216 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device));
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
217 Extbyte *extname;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
218 XFontStruct *fs = NULL; /* _F_ont _S_truct */
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
219 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
220 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
221 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
222 #define rf (0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
223 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
225 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
226 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
227 XSTRING_DATA(f->name));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
228 /* #### serialize (optimize) these later... */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
229 /* #### This function really needs to go away.
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
230 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
231 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
232 at all close to what we asked for. */
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4969
diff changeset
233 extname = LISP_STRING_TO_EXTERNAL (f->name, Qfc_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
234 rf = xft_open_font_by_name (dpy, extname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
235 #endif
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4969
diff changeset
236 extname = LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
237 /* With XFree86 4.0's fonts, XListFonts returns an entry for
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
238 -isas-fangsong ti-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0 but
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
239 an XLoadQueryFont on the corresponding XLFD returns NULL.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
240
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
241 XListFonts is not trustworthy (of course, this is news to exactly
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
242 no-one used to reading XEmacs source.) */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
243 fs = XLoadQueryFont (dpy, extname);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
244
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
245 if (!fs && !rf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
247 /* #### should this refer to X and/or Xft? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
248 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
249 Qfont, errb);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3389
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
253 if (rf && fs)
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
254 {
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
255 XFreeFont (dpy, fs);
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
256 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
257 }
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
258
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
259 if (fs && !fs->max_bounds.width)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
260 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
261 /* yes, this has been known to happen. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
262 XFreeFont (dpy, fs);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
263 fs = NULL;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
264 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
265 errb);
3389
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
266 return 0;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
267 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
268
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
269 /* 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
270 fear that the finalize method may get fucked. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 f->data = xnew (struct x_font_instance_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
273 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
274 FONT_INSTANCE_X_XFTFONT (f) = rf;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
275 if (rf)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
276 /* 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
277 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
278 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
279 f->ascent, f->descent, f->width, f->height);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
281 /* #### 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
282 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
283 "double-width" characters. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
284 f->ascent = rf->ascent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
285 f->descent = rf->descent;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
287 /* 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
288 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
289 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
290 distribution of widths expected in real text. */
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3433
diff changeset
291 static const FcChar8 test_string8[] = "Mmneei";
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
292 static const int len = sizeof (test_string8) - 1;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
293 XGlyphInfo glyphinfo;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
294
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
295 XftTextExtents8 (dpy, rf, test_string8, len, &glyphinfo);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
296 /* #### maybe should be glyphinfo.xOff - glyphinfo.x? */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
297 f->width = (2*glyphinfo.width + len)/(2*len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
299 f->height = rf->height;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
300 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
301
3389
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
302 /* #### This message appears wa-a-ay too often!
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
303 We probably need to cache truenames or something?
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
304 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
305 DEBUG_XFT4 (0,
77b0b03fbc47 [xemacs-hg @ 2006-05-09 10:40:07 by stephent]
stephent
parents: 3360
diff changeset
306 "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
307 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
308 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
309 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
310 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
311 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
312 XSTRING_DATA(f->name));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
313 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
314 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
315
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
316 FONT_INSTANCE_X_FONT (f) = fs;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
317 if (fs)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
318 /* 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
319 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
320 f->ascent = fs->ascent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
321 f->descent = fs->descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
322 f->height = fs->ascent + fs->descent;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
323 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
324 /* 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
325 int def_char = 'n'; /*fs->default_char;*/
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
326 int byte1, byte2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
328 once_more:
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
329 byte1 = def_char >> 8;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
330 byte2 = def_char & 0xFF;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
331
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
332 if (fs->per_char)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
333 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
334 /* 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
335 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
336 if (byte1 < (int) fs->min_byte1 ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
337 byte1 > (int) fs->max_byte1 ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
338 byte2 < (int) fs->min_char_or_byte2 ||
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
339 byte2 > (int) fs->max_char_or_byte2)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
340 f->width = 0;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
341 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
342 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
343 (fs->max_char_or_byte2 -
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
344 fs->min_char_or_byte2 + 1) +
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
345 (byte2 - fs->min_char_or_byte2)].width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
346 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 else
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
348 f->width = fs->max_bounds.width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
349
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
350 /* 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
351 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
352 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
353 if (f->width == 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
355 if (def_char == (int) fs->default_char)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
356 f->width = fs->max_bounds.width;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
357 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
358 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
359 def_char = fs->default_char;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
360 goto once_more;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
361 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
364
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
365 /* 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
366 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
367 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
368 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
369 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
370 /* #### This sucks. There is a measurable performance increase
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
371 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
372 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
373 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
374 make it an assertion. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
375 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
376 (x_handle_non_fully_specified_fonts &&
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
377 !fs->all_chars_exist));
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
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
380 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
381 if (debug_xft > 0)
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 int n = 3, d = 5;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
384 /* check for weirdness */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
385 if (n * f->height < d * f->width)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
386 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
387 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
388 if (f->height <= 0 || f->width <= 0)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
389 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
390 XSTRING_DATA(f->name), f->width, f->height);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
391 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
392 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
393 #else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
394 #undef rf
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
395 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
401 x_print_font_instance (Lisp_Font_Instance *f,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1726
diff changeset
403 int UNUSED (escapeflag))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 {
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
405 /* We should print information here about initial vs. final stages; we
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
406 can't rely on the device charset stage cache for that,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
407 unfortunately. */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
408 if (FONT_INSTANCE_X_FONT (f))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
409 write_fmt_string (printcharfun, " font id: 0x%lx,",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
410 (unsigned long) FONT_INSTANCE_X_FONT (f)->fid);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
411
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
412 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
413 /* #### 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
414 if (FONT_INSTANCE_X_XFTFONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
415 write_fmt_string (printcharfun, " xft font: 0x%lx",
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
416 (unsigned long) FONT_INSTANCE_X_XFTFONT (f));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
417 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 static void
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
421 x_finalize_font_instance (Lisp_Font_Instance *f)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
424 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
425 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
426 ? (char *) XSTRING_DATA (f->name)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
427 : "(unnamed font)"));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
428 #endif
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
429
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 if (f->data)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 if (DEVICE_LIVE_P (XDEVICE (f->device)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
436 if (FONT_INSTANCE_X_FONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
437 XFreeFont (dpy, FONT_INSTANCE_X_FONT (f));
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
438 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
439 if (FONT_INSTANCE_X_XFTFONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
440 XftFontClose (dpy, FONT_INSTANCE_X_XFTFONT (f));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
441 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 }
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4969
diff changeset
443 xfree (f->data);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 f->data = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 /* Determining the truename of a font is hard. (Big surprise.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
450 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
451 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
452 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
453 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
454 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
455 selected. -- sjt
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
456
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 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
458 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
459 the (probably wildcarded) name and `XFontStruct' of.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 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
462 that XOpenFont would pick. Apparently this is the case on some servers,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 but not on others. It would seem not to be specified.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 The MIT R5 server sometimes appears to be picking the lexicographically
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 smallest font which matches the name (thus picking "adobe" fonts before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 "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
468 also picking 100dpi adobe fonts over 75dpi adobe fonts even though the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 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
470 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
471 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
472 their relative positions in the path (and their names!) have not changed).
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 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
475 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
476 it, and the spirit of the law is apparently not being obeyed...
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 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
479 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
480 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
481 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
482 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
483 font, due to some difference of opinion between the font designers and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 whoever installed the font on the system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 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
487 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
488 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
489 but that seems pretty remote.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 Late breaking news: I've gotten reports that SunOS 4.1.3U1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 with OpenWound 3.0 has a font whose truename is really
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 "-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
494 but whose FONT property contains "Courier".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 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
497 is more than 30 characters long. X Windows: The defacto substandard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 X Windows: Complex nonsolutions to simple nonproblems. X Windows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 Live the nightmare.
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 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
502 out of the other font properties (FOUNDRY, FAMILY_NAME, WEIGHT_NAME, etc).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 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
504 what the future will bring.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 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
507 (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
508 least, depending on whether the preprocessor constant `XOPENFONT_SORTS' is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 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
510 being used, not the architecture on which emacs has been compiled. Also,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 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
512 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
513 FONT property isn't present.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 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
516 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
517 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
518 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
519 were the same sizes, which would probably be good enough.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 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
522 XLoadQueryFont (dpy, "-*-Fixed-Medium-R-*-*-*-130-75-75-*-*-ISO8859-1")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 actually returns the font
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 -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
525 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
526 also not included in the output produced by `xlsfonts' with that pattern.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 So this is yet another example of XListFonts() and XOpenFont() using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 completely different algorithms. This, however, is a goofier example of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 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
531 different -- the sets don't even intersect.
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 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
534 that the various servers are actually doing, please let me know! -- jwz. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 static int
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
537 valid_x_font_name_p (Display *dpy, Extbyte *name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 /* Maybe this should be implemented by calling XLoadFont and trapping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 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
541 might be more correct.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 int nnames = 0;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
544 Extbyte **names = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 if (! name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 names = XListFonts (dpy, name, 1, &nnames);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 if (names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 XFreeFontNames (names);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 return (nnames != 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
553 static Extbyte *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 truename_via_FONT_prop (Display *dpy, XFontStruct *font)
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 unsigned long value = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
557 Extbyte *result = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 if (XGetFontProperty (font, XA_FONT, &value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 result = XGetAtomName (dpy, value);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 /* result is now 0, or the string value of the FONT property. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 if (result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 /* 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
564 if (result [0] != '-' || strlen (result) < 30)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 XFree (result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 result = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 }
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 return result; /* this must be freed by caller if non-0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 static Extbyte *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 truename_via_random_props (Display *dpy, XFontStruct *font)
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 struct device *d = get_device_from_display (dpy);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 unsigned long value = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
578 Extbyte *foundry, *family, *weight, *slant, *setwidth, *add_style;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 unsigned long pixel, point, res_x, res_y;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 Extbyte *spacing;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 unsigned long avg_width;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
582 Extbyte *registry, *encoding;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
583 Extbyte composed_name [2048];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 int ok = 0;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
585 Extbyte *result;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 #define get_string(atom,var) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 if (XGetFontProperty (font, (atom), &value)) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 var = XGetAtomName (dpy, value); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 else { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 var = 0; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 goto FAIL; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 #define get_number(atom,var) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 if (!XGetFontProperty (font, (atom), &var) || \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 var > 999) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 goto FAIL;
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 foundry = family = weight = slant = setwidth = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 add_style = spacing = registry = encoding = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 get_string (DEVICE_XATOM_FOUNDRY (d), foundry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 get_string (DEVICE_XATOM_FAMILY_NAME (d), family);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 get_string (DEVICE_XATOM_WEIGHT_NAME (d), weight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 get_string (DEVICE_XATOM_SLANT (d), slant);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 get_string (DEVICE_XATOM_SETWIDTH_NAME (d), setwidth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 get_string (DEVICE_XATOM_ADD_STYLE_NAME (d), add_style);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 get_number (DEVICE_XATOM_PIXEL_SIZE (d), pixel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 get_number (DEVICE_XATOM_POINT_SIZE (d), point);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 get_number (DEVICE_XATOM_RESOLUTION_X (d), res_x);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 get_number (DEVICE_XATOM_RESOLUTION_Y (d), res_y);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 get_string (DEVICE_XATOM_SPACING (d), spacing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 get_number (DEVICE_XATOM_AVERAGE_WIDTH (d), avg_width);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 get_string (DEVICE_XATOM_CHARSET_REGISTRY (d), registry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 get_string (DEVICE_XATOM_CHARSET_ENCODING (d), encoding);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 #undef get_number
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 #undef get_string
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 sprintf (composed_name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 "-%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
620 foundry, family, weight, slant, setwidth, add_style, pixel,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 point, res_x, res_y, spacing, avg_width, registry, encoding);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 ok = 1;
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 FAIL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 if (ok)
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 int L = strlen (composed_name) + 1;
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
628 result = xnew_extbytes (L);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 strncpy (result, composed_name, L);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 result = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 if (foundry) XFree (foundry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 if (family) XFree (family);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 if (weight) XFree (weight);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 if (slant) XFree (slant);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 if (setwidth) XFree (setwidth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 if (add_style) XFree (add_style);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 if (spacing) XFree (spacing);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 if (registry) XFree (registry);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 if (encoding) XFree (encoding);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
3169
5bfedec8927e [xemacs-hg @ 2005-12-24 17:33:31 by aidan]
aidan
parents: 3165
diff changeset
647 /* 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
648 XFree86 in 2005, at least. */
5bfedec8927e [xemacs-hg @ 2005-12-24 17:33:31 by aidan]
aidan
parents: 3165
diff changeset
649 #define MAX_FONT_COUNT INT_MAX
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
651 static Extbyte *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
652 truename_via_XListFonts (Display *dpy, Extbyte *font_name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
654 Extbyte *result = 0;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
655 Extbyte **names;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 int count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 #ifndef XOPENFONT_SORTS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 /* In a sensible world, the first font returned by XListFonts()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 would be the font that XOpenFont() would use. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 names = XListFonts (dpy, font_name, 1, &count);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 if (count) result = names [0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 /* But the world I live in is much more perverse. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 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
666 /* Find the lexicographic minimum of names[].
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
667 (#### Should we be comparing case-insensitively?) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 while (count--)
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
669 /* [[ !!#### Not Mule-friendly ]]
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
670 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
671 aren't, who knows what they are? -- sjt */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 if (result == 0 || (strcmp (result, names [count]) < 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 result = names [count];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 if (result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 result = xstrdup (result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 if (names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 XFreeFontNames (names);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 return result; /* this must be freed by caller if non-0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 static Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 x_font_truename (Display *dpy, Extbyte *name, XFontStruct *font)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
687 Extbyte *truename_FONT = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
688 Extbyte *truename_random = 0;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
689 Extbyte *truename = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 /* The search order is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 - if FONT property exists, and is a valid name, return it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 - 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
694 - if we find a matching name with XListFonts, return it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 - if FONT property exists, return it regardless.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 - if other props exist, return the resultant name regardless.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 - else return 0.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 truename = truename_FONT = truename_via_FONT_prop (dpy, font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 if (truename && !valid_x_font_name_p (dpy, truename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 truename = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 if (!truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 truename = truename_random = truename_via_random_props (dpy, font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 if (truename && !valid_x_font_name_p (dpy, truename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 truename = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 if (!truename && name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 truename = truename_via_XListFonts (dpy, name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 if (!truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 /* Gag - we weren't able to find a seemingly-valid truename.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 Well, maybe we're on one of those braindead systems where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 XListFonts() and XLoadFont() are in violent disagreement.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 If we were able to compute a truename, try using that even
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 if evidence suggests that it's not a valid name - because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 maybe it is, really, and that's better than nothing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 X Windows: You'll envy the dead.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 if (truename_FONT)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 truename = truename_FONT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 else if (truename_random)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 truename = truename_random;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 /* One or both of these are not being used - free them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 if (truename_FONT && truename_FONT != truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 XFree (truename_FONT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 if (truename_random && truename_random != truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 XFree (truename_random);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 if (truename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 {
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
734 Lisp_Object result = build_extstring (truename, Qx_font_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 XFree (truename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 return result;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 static Lisp_Object
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
743 x_font_instance_truename (Lisp_Font_Instance *f, Error_Behavior errb)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 struct device *d = XDEVICE (f->device);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
746 Display *dpy = DEVICE_X_DISPLAY (d);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
747 Extbyte *nameext;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
748
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
749 /* #### 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
750 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
751 doesn't get stored for future use. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
752
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
753 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
754 /* First, try an Xft font. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
755 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
756 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
757 /* The font is already open, we just unparse. */
5818
15b0715c204d Avoid passing patterns to with charset property to FcNameUnparse.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5581
diff changeset
758 FcPattern* pattern = FONT_INSTANCE_X_XFTFONT (f)->pattern;
15b0715c204d Avoid passing patterns to with charset property to FcNameUnparse.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5581
diff changeset
759 FcChar8 *res;
15b0715c204d Avoid passing patterns to with charset property to FcNameUnparse.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5581
diff changeset
760 if (!pattern)
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 3659
diff changeset
761 {
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 3659
diff changeset
762 maybe_signal_error (Qgui_error,
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 3659
diff changeset
763 "Xft font present but lacks pattern",
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 3659
diff changeset
764 wrap_font_instance(f), Qfont, errb);
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 3659
diff changeset
765 }
5824
6928877dbc26 Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents: 5818
diff changeset
766 {
6928877dbc26 Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents: 5818
diff changeset
767 FcPattern* temp = FcPatternDuplicate (pattern);
6928877dbc26 Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents: 5818
diff changeset
768 FcPatternDel (temp, FC_CHARSET); /* FcNameUnparse may choke */
6928877dbc26 Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents: 5818
diff changeset
769 res = FcNameUnparse (temp);
6928877dbc26 Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents: 5818
diff changeset
770 FcPatternDestroy (temp);
6928877dbc26 Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents: 5818
diff changeset
771 }
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
772 if (res)
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
773 {
3174
588878f5a654 [xemacs-hg @ 2005-12-24 22:31:47 by aidan]
aidan
parents: 3169
diff changeset
774 FONT_INSTANCE_TRUENAME (f) =
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
775 build_extstring ((Extbyte *) res, Qfc_font_name_encoding);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
776 free (res);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
777 return FONT_INSTANCE_TRUENAME (f);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
778 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
779 else
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
780 {
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
781 maybe_signal_error (Qgui_error,
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
782 "Couldn't unparse Xft font to truename",
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 3659
diff changeset
783 wrap_font_instance(f), Qfont, errb);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
784 /* used to return Qnil here */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
785 }
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
786 }
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
787 #endif /* HAVE_XFT */
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
788
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
789 /* OK, fall back to core font. */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
790 if (NILP (FONT_INSTANCE_TRUENAME (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
791 && FONT_INSTANCE_X_FONT (f))
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
792 {
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4969
diff changeset
793 nameext = 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
794 FONT_INSTANCE_TRUENAME (f) =
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
795 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
796 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
798 if (NILP (FONT_INSTANCE_TRUENAME (f)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 {
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
800 /* 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
801 Lisp_Object font_instance = wrap_font_instance (f);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
802
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 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
805 font_instance, Qfont, errb);
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
806 /* 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
807 (This is only used by Fequal() right now.) */
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
808 return f->name;
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
809 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
810
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
811 /* Return what we found. */
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
812 return FONT_INSTANCE_TRUENAME (f);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 static Lisp_Object
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
816 x_font_instance_properties (Lisp_Font_Instance *f)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 struct device *d = XDEVICE (f->device);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 Lisp_Object result = Qnil;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
821 Display *dpy = DEVICE_X_DISPLAY (d);
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
822 XFontProp *props = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
824 /* #### really should hack Xft fonts, too
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
825 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
826 if (! FONT_INSTANCE_X_FONT (f)) return result;
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 props = FONT_INSTANCE_X_FONT (f)->properties;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 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
830 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 Lisp_Object name, value;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 Atom atom = props [i].name;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
833 Ibyte *name_str = 0;
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 578
diff changeset
834 Bytecount name_len;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
835 Extbyte *namestrext = XGetAtomName (dpy, atom);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
836
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
837 if (namestrext)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
838 TO_INTERNAL_FORMAT (C_STRING, namestrext,
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
839 ALLOCA, (name_str, name_len),
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
840 Qx_atom_name_encoding);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
841
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
842 name = (name_str ? intern_istring (name_str) : Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 if (name_str &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 (atom == XA_FONT ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 atom == DEVICE_XATOM_FOUNDRY (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 atom == DEVICE_XATOM_FAMILY_NAME (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 atom == DEVICE_XATOM_WEIGHT_NAME (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 atom == DEVICE_XATOM_SLANT (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 atom == DEVICE_XATOM_SETWIDTH_NAME (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 atom == DEVICE_XATOM_ADD_STYLE_NAME (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 atom == DEVICE_XATOM_SPACING (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 atom == DEVICE_XATOM_CHARSET_REGISTRY (d) ||
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 atom == DEVICE_XATOM_CHARSET_ENCODING (d) ||
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
854 !qxestrcmp_ascii (name_str, "CHARSET_COLLECTIONS") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
855 !qxestrcmp_ascii (name_str, "FONTNAME_REGISTRY") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
856 !qxestrcmp_ascii (name_str, "CLASSIFICATION") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
857 !qxestrcmp_ascii (name_str, "COPYRIGHT") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
858 !qxestrcmp_ascii (name_str, "DEVICE_FONT_NAME") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
859 !qxestrcmp_ascii (name_str, "FULL_NAME") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
860 !qxestrcmp_ascii (name_str, "MONOSPACED") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
861 !qxestrcmp_ascii (name_str, "QUALITY") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
862 !qxestrcmp_ascii (name_str, "RELATIVE_SET") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
863 !qxestrcmp_ascii (name_str, "RELATIVE_WEIGHT") ||
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
864 !qxestrcmp_ascii (name_str, "STYLE")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
866 Extbyte *val_str = XGetAtomName (dpy, props [i].card32);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
867
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
868 value = (val_str ? build_extstring (val_str, Qx_atom_name_encoding)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
869 : Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 else
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
872 value = make_fixnum (props [i].card32);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
873 if (namestrext) XFree (namestrext);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 result = Fcons (Fcons (name, value), result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 static Lisp_Object
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
880 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
881 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
882 Extbyte **names;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 int count = 0;
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
884 int max_number = MAX_FONT_COUNT;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 Lisp_Object result = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
886 const Extbyte *patternext;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4969
diff changeset
888 patternext = LISP_STRING_TO_EXTERNAL (pattern, Qx_font_name_encoding);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
890 if (!NILP(maxnumber) && FIXNUMP(maxnumber))
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
891 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
892 max_number = XFIXNUM(maxnumber);
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
893 }
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
894
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)),
1701
a1e328407366 [xemacs-hg @ 2003-09-20 01:14:24 by youngs]
youngs
parents: 1204
diff changeset
896 patternext, max_number, &count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 while (count--)
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
898 result = Fcons (build_extstring (names[count], Qx_font_name_encoding),
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
899 result);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 if (names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 XFreeFontNames (names);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
905 /* Include the charset support, shared, for the moment, with GTK. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
906 #define THIS_IS_X
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
907 #include "fontcolor-xlike-inc.c"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 /************************************************************************/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 /* initialization */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 void
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
915 syms_of_fontcolor_x (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 {
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 void
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
920 console_type_create_fontcolor_x (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 /* object methods */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 CONSOLE_HAS_METHOD (x, initialize_color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 CONSOLE_HAS_METHOD (x, print_color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 CONSOLE_HAS_METHOD (x, finalize_color_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 CONSOLE_HAS_METHOD (x, color_instance_equal);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 CONSOLE_HAS_METHOD (x, color_instance_hash);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 CONSOLE_HAS_METHOD (x, color_instance_rgb_components);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 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
931 CONSOLE_HAS_METHOD (x, color_list);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 CONSOLE_HAS_METHOD (x, initialize_font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 CONSOLE_HAS_METHOD (x, print_font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 CONSOLE_HAS_METHOD (x, finalize_font_instance);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 CONSOLE_HAS_METHOD (x, font_instance_truename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 CONSOLE_HAS_METHOD (x, font_instance_properties);
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
938 CONSOLE_HAS_METHOD (x, font_list);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 #ifdef MULE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 CONSOLE_HAS_METHOD (x, find_charset_font);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 CONSOLE_HAS_METHOD (x, font_spec_matches_charset);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 void
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
946 vars_of_fontcolor_x (void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 {
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
948 #ifdef DEBUG_XEMACS
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
949 DEFVAR_INT ("debug-x-fonts", &debug_x_fonts /*
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
950 If non-zero, display debug information about X fonts
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
951 */ );
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
952 debug_x_fonts = 0;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
953 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3469
diff changeset
954
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 DEFVAR_BOOL ("x-handle-non-fully-specified-fonts",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 &x_handle_non_fully_specified_fonts /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 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
958 will be considered to be proportional width even if they are actually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 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
960 have 0 width may appear to actually have some width.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 Note: While setting this to t guarantees correct output in all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 circumstances, it also causes a noticeable performance hit when using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 fixed-width fonts. Since most people don't use characters which could
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 cause problems this is set to nil by default.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 x_handle_non_fully_specified_fonts = 0;
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
968
4916
a6c778975d7d split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents: 4757
diff changeset
969 #ifdef HAVE_XFT
3094
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
970 Fprovide (intern ("xft-fonts"));
ad2f4ae9895b [xemacs-hg @ 2005-11-26 11:45:47 by stephent]
stephent
parents: 2527
diff changeset
971 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 void
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
975 Xatoms_of_fontcolor_x (struct device *d)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 Display *D = DEVICE_X_DISPLAY (d);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 DEVICE_XATOM_FOUNDRY (d) = XInternAtom (D, "FOUNDRY", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 DEVICE_XATOM_FAMILY_NAME (d) = XInternAtom (D, "FAMILY_NAME", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 DEVICE_XATOM_WEIGHT_NAME (d) = XInternAtom (D, "WEIGHT_NAME", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 DEVICE_XATOM_SLANT (d) = XInternAtom (D, "SLANT", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 DEVICE_XATOM_SETWIDTH_NAME (d) = XInternAtom (D, "SETWIDTH_NAME", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 DEVICE_XATOM_ADD_STYLE_NAME (d) = XInternAtom (D, "ADD_STYLE_NAME", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 DEVICE_XATOM_PIXEL_SIZE (d) = XInternAtom (D, "PIXEL_SIZE", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 DEVICE_XATOM_POINT_SIZE (d) = XInternAtom (D, "POINT_SIZE", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 DEVICE_XATOM_RESOLUTION_X (d) = XInternAtom (D, "RESOLUTION_X", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 DEVICE_XATOM_RESOLUTION_Y (d) = XInternAtom (D, "RESOLUTION_Y", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 DEVICE_XATOM_SPACING (d) = XInternAtom (D, "SPACING", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 DEVICE_XATOM_AVERAGE_WIDTH (d) = XInternAtom (D, "AVERAGE_WIDTH", False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 DEVICE_XATOM_CHARSET_REGISTRY(d) = XInternAtom (D, "CHARSET_REGISTRY",False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 DEVICE_XATOM_CHARSET_ENCODING(d) = XInternAtom (D, "CHARSET_ENCODING",False);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 }