annotate src/fontcolor-x.c @ 5189:b65692aa90d8

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