annotate src/fontcolor-xlike-inc.c @ 5197:ce8ffb95bbe3

finish up CHANGES-beta -- all changes thru Apr 9, 2010 -------------------- ChangeLog entries follow: -------------------- ChangeLog addition: 2010-04-09 Ben Wing <ben@xemacs.org> * CHANGES-beta: Update with my changes to the trunk since the release of 21.5.29 in 2009 up through April 9, 2010.
author Ben Wing <ben@xemacs.org>
date Fri, 09 Apr 2010 02:33:11 -0500
parents b65692aa90d8
children c87ec061e8cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
1 /* Common code between X and GTK -- fonts and colors.
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
2 Copyright (C) 1991-5, 1997 Free Software Foundation, Inc.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
5015
d95c102a96d3 cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents: 4981
diff changeset
4 Copyright (C) 1996, 2001, 2002, 2003, 2010 Ben Wing.
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
5
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
6 This file is part of XEmacs.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
7
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
11 later version.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
12
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
16 for more details.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
17
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
22
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
24
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
25 /* Before including this file, you need to define either THIS_IS_X or
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
26 THIS_IS_GTK. */
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
27
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
28 /* See comment at top of console-xlike-inc.h for an explanation of
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
29 how this file works. */
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
30
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
31 /* Pango is ready for prime-time now, as far as I understand it. The GTK
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
32 people should be using that. Oh well. (Aidan Kehoe, Sat Nov 4 12:41:12
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
33 CET 2006) */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
34
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
35 #include "console-xlike-inc.h"
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
36
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
37 #define DEBUG_FONTS1(format, arg) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
38 do { \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
39 if (debug_x_fonts) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
40 debug_out (format, arg); \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
41 } while (0)
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
42
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
43 #define DEBUG_FONTS2(format, arg1, arg2) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
44 do { \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
45 if (debug_x_fonts) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
46 debug_out (format, arg1, arg2); \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
47 } while (0)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
48
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
49 #define DEBUG_FONTS3(format, arg1, arg2, arg3) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
50 do { \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
51 if (debug_x_fonts) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
52 debug_out (format, arg1, arg2, arg3); \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
53 } while (0)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
54
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
55 #define DEBUG_FONTS4(format, arg1, arg2, arg3, arg4) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
56 do { \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
57 if (debug_x_fonts) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
58 debug_out (format, arg1, arg2, arg3, arg4); \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
59 } while (0)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
60
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
61 #define DEBUG_FONTS_LISP1(format, arg) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
62 do { \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
63 if (debug_x_fonts) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
64 debug_out_lisp (format, 1, arg); \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
65 } while (0)
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
66
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
67 #define DEBUG_FONTS_LISP2(format, arg1, arg2) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
68 do { \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
69 if (debug_x_fonts) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
70 debug_out_lisp (format, 2, arg1, arg2); \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
71 } while (0)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
72
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
73 #define DEBUG_FONTS_LISP3(format, arg1, arg2, arg3) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
74 do { \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
75 if (debug_x_fonts) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
76 debug_out_lisp (format, 3, arg1, arg2, arg3); \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
77 } while (0)
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
78
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
79 #define DEBUG_FONTS_LISP4(format, arg1, arg2, arg3, arg4) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
80 do { \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
81 if (debug_x_fonts) \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
82 debug_out_lisp (format, 4, arg1, arg2, arg3, arg4); \
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
83 } while (0)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
84
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
85 #ifdef MULE
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
86
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
87 /* For some code it's reasonable to have only one copy and conditionalize
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
88 at run-time. For other code it isn't. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
89
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
90 static int
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
91 count_hyphens (const Ibyte *str, Bytecount length, Ibyte **last_hyphen)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
92 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
93 int hyphen_count = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
94 const Ibyte *hyphening = str;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
95 const Ibyte *new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
96
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
97 for (hyphen_count = 0;
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
98 NULL != (new_hyphening = (Ibyte *) memchr ((const void *)hyphening, '-', length));
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
99 hyphen_count++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
100 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
101 ++new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
102 length -= new_hyphening - hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
103 hyphening = new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
104 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
105
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
106 if (NULL != last_hyphen)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
107 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
108 *last_hyphen = (Ibyte *)hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
109 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
110
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
111 return hyphen_count;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
112 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
113
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
114 static int
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
115 XFUN (font_spec_matches_charset) (struct device * USED_IF_XFT (d),
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
116 Lisp_Object charset,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
117 const Ibyte *nonreloc, Lisp_Object reloc,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
118 Bytecount offset, Bytecount length,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
119 enum font_specifier_matchspec_stages stage)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
120 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
121 Lisp_Object registries = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
122 long i, registries_len;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
123 const Ibyte *the_nonreloc;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
124 Bytecount the_length;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
125
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
126 the_nonreloc = nonreloc;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
127 the_length = length;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
128
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
129 if (!the_nonreloc)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
130 the_nonreloc = XSTRING_DATA (reloc);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
131 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
132 the_nonreloc += offset;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
133
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
134 #ifdef USE_XFT
5015
d95c102a96d3 cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents: 4981
diff changeset
135 if (stage == STAGE_FINAL)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
136 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
137 Display *dpy = DEVICE_X_DISPLAY (d);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
138 Extbyte *extname;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
139 XftFont *rf;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
140
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
141 if (!NILP (reloc))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
142 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
143 the_nonreloc = XSTRING_DATA (reloc);
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
144 extname = LISP_STRING_TO_EXTERNAL (reloc, Qx_font_name_encoding);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
145 rf = xft_open_font_by_name (dpy, extname);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
146 return 0; /* #### maybe this will compile and run ;) */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
147 /* Jesus, Stephen, what the fuck? */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
148 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
149 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
150 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
151
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
152 /* Hmm, this smells bad. */
4353
4143b78d0df0 Merge an old patch of Ben's, involving font instantiation and charsets.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4124
diff changeset
153 if (NILP (charset))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
154 return 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
155
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
156 /* Hack! Short font names don't have the registry in them,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
157 so we just assume the user knows what they're doing in the
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
158 case of ASCII. For other charsets, you gotta give the
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
159 long form; sorry buster.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
160 #### FMH: this screws fontconfig/Xft?
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
161 STRATEGY: use fontconfig's ability to hack languages and character
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
162 sets (lang and charset properties).
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
163 #### Maybe we can use the fontconfig model to eliminate the difference
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
164 between faces and fonts? No - it looks like that would be an abuse
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
165 (fontconfig doesn't know about colors, although Xft does).
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
166 */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
167 if (EQ (charset, Vcharset_ascii) &&
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
168 (!memchr (the_nonreloc, '*', the_length))
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
169 && (5 > (count_hyphens (the_nonreloc, the_length, NULL))))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
170 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
171 return 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
172 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
173
5015
d95c102a96d3 cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents: 4981
diff changeset
174 if (STAGE_FINAL == stage)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
175 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
176 registries = Qunicode_registries;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
177 }
5015
d95c102a96d3 cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents: 4981
diff changeset
178 else if (STAGE_INITIAL == stage)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
179 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
180 registries = XCHARSET_REGISTRIES (charset);
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
181 if (NILP (registries))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
182 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
183 return 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
184 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
185 }
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
186 else assert (0);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
187
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
188 CHECK_VECTOR (registries);
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
189 registries_len = XVECTOR_LENGTH (registries);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
190
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
191 for (i = 0; i < registries_len; ++i)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
192 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
193 if (!(STRINGP (XVECTOR_DATA (registries)[i]))
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
194 || (XSTRING_LENGTH (XVECTOR_DATA (registries)[i]) > the_length))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
195 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
196 continue;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
197 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
198
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
199 /* Check if the font spec ends in the registry specified. X11 says
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
200 this comparison is case insensitive: XLFD, section 3.11:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
201
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
202 "Alphabetic case distinctions are allowed but are for human
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
203 readability concerns only. Conforming X servers will perform
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
204 matching on font name query or open requests independent of case." */
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
205 if (0 == qxestrcasecmp (XSTRING_DATA (XVECTOR_DATA (registries)[i]),
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
206 the_nonreloc + (the_length -
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
207 XSTRING_LENGTH
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
208 (XVECTOR_DATA (registries)[i]))))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
209 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
210 return 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
211 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
212 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
213 return 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
214 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
215
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
216 static Lisp_Object
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
217 xlistfonts_checking_charset (Lisp_Object device, const Ibyte *xlfd,
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
218 Lisp_Object charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
219 enum font_specifier_matchspec_stages stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
220 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
221 Extbyte **names;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
222 Lisp_Object result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
223 int count = 0, i;
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
224 DECLARE_EISTRING (ei_single_result);
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
225 Extbyte *fontext;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
226
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
227 DEBUG_FONTS2 ("xlistfonts_checking_charset called, XLFD %s stage %s",
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
228 xlfd, stage == STAGE_INITIAL ? "initial" : "final");
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
229 DEBUG_FONTS_LISP1 (" charset %s\n", charset);
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
230 fontext = ITEXT_TO_EXTERNAL (xlfd, Qx_font_name_encoding);
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
231 names = XListFonts (GET_XLIKE_DISPLAY (XDEVICE (device)),
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
232 fontext, MAX_FONT_COUNT, &count);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
233
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
234 for (i = 0; i < count; ++i)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
235 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
236 eireset (ei_single_result);
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
237 eicpy_ext (ei_single_result, names[i], Qx_font_name_encoding);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
238
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
239 if (DEVMETH_OR_GIVEN (XDEVICE (device), font_spec_matches_charset,
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
240 (XDEVICE (device), charset,
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
241 eidata (ei_single_result), Qnil, 0,
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
242 -1, stage), 0))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
243 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
244 result = eimake_string (ei_single_result);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
245 break;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
246 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
247 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
248
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
249 if (names)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
250 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
251 XFreeFontNames (names);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
252 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
253
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
254 DEBUG_FONTS_LISP1 ("xlistfonts_checking_charset returns %s\n", result);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
255 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
256 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
257
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
258 #ifdef USE_XFT
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
259 /* #### debug functions: find a better place for us */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
260 const char *FcResultToString (FcResult r);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
261 const char *
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
262 FcResultToString (FcResult r)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
263 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
264 static char buffer[256];
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
265 switch (r)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
266 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
267 case FcResultMatch:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
268 return "FcResultMatch";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
269 case FcResultNoMatch:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
270 return "FcResultNoMatch";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
271 case FcResultTypeMismatch:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
272 return "FcResultTypeMismatch";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
273 case FcResultNoId:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
274 return "FcResultNoId";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
275 default:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
276 snprintf (buffer, 255, "FcResultUndocumentedValue (%d)", r);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
277 return buffer;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
278 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
279 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
280
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
281 const char *FcTypeOfValueToString (FcValue v);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
282 const char *
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
283 FcTypeOfValueToString (FcValue v)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
284 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
285 static char buffer[256];
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
286 switch (v.type)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
287 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
288 case FcTypeMatrix:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
289 return "FcTypeMatrix";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
290 case FcTypeString:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
291 return "FcTypeString";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
292 case FcTypeVoid:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
293 return "FcTypeVoid";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
294 case FcTypeDouble:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
295 return "FcTypeDouble";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
296 case FcTypeInteger:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
297 return "FcTypeInteger";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
298 case FcTypeBool:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
299 return "FcTypeBool";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
300 case FcTypeCharSet:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
301 return "FcTypeCharSet";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
302 case FcTypeLangSet:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
303 return "FcTypeLangSet";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
304 /* #### There is no union member of this type, but there are void* and
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
305 FcPattern* members, as of fontconfig.h FC_VERSION 10002 */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
306 case FcTypeFTFace:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
307 return "FcTypeFTFace";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
308 default:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
309 snprintf (buffer, 255, "FcTypeUndocumentedType (%d)", v.type);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
310 return buffer;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
311 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
312 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
313
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
314 static FcCharSet *
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
315 mule_to_fc_charset (Lisp_Object cs)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
316 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
317 int ucode, i, j;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
318 FcCharSet *fccs;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
319
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
320 CHECK_CHARSET (cs);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
321 fccs = FcCharSetCreate ();
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
322 /* #### do we also need to deal with 94 vs. 96 charsets?
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
323 ie, how are SP and DEL treated in ASCII? non-graphic should return -1 */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
324 if (1 == XCHARSET_DIMENSION (cs))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
325 /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
326 for (i = 0; i < 96; i++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
327 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
328 ucode = ((int *) XCHARSET_TO_UNICODE_TABLE (cs))[i];
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
329 if (ucode >= 0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
330 /* #### should check for allocation failure */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
331 FcCharSetAddChar (fccs, (FcChar32) ucode);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
332 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
333 else if (2 == XCHARSET_DIMENSION (cs))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
334 /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
335 for (i = 0; i < 96; i++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
336 for (j = 0; j < 96; j++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
337 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
338 ucode = ((int **) XCHARSET_TO_UNICODE_TABLE (cs))[i][j];
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
339 if (ucode >= 0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
340 /* #### should check for allocation failure */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
341 FcCharSetAddChar (fccs, (FcChar32) ucode);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
342 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
343 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
344 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
345 FcCharSetDestroy (fccs);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
346 fccs = NULL;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
347 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
348 return fccs;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
349 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
350
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
351 struct charset_reporter {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
352 Lisp_Object *charset;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
353 /* This is a debug facility, require ASCII. */
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
354 const Ascbyte *language; /* ASCII, please */
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
355 /* Technically this is FcChar8, but fsckin' GCC 4 bitches.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
356 RFC 3066 is a combination of ISO 639 and ISO 3166. */
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
357 const Ascbyte *rfc3066; /* ASCII, please */
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
358 };
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
359
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
360 static struct charset_reporter charset_table[] =
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
361 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
362 /* #### It's my branch, my favorite charsets get checked first!
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
363 That's a joke, Son.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
364 Ie, I don't know what I'm doing, so my charsets first is as good as
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
365 any other arbitrary order. If you have a better idea, speak up! */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
366 { &Vcharset_ascii, "English", "en" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
367 { &Vcharset_japanese_jisx0208, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
368 { &Vcharset_japanese_jisx0212, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
369 { &Vcharset_katakana_jisx0201, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
370 { &Vcharset_latin_jisx0201, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
371 { &Vcharset_japanese_jisx0208_1978, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
372 { &Vcharset_greek_iso8859_7, "Greek", "el" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
373 /* #### all the Chinese need checking
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
374 Damn the blood-sucking ISO anyway. */
4756
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
375 { &Vcharset_chinese_gb2312, "simplified Chinese", "zh-cn" },
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
376 { &Vcharset_korean_ksc5601, "Korean", "ko" },
4756
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
377 { &Vcharset_chinese_cns11643_1, "traditional Chinese", "zh-tw" },
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
378 { &Vcharset_chinese_cns11643_2, "traditional Chinese", "zh-tw" },
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
379 /* #### not obvious how to handle these
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
380 We could (for experimental purposes) make the last element into
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
381 an array of ISO 639 codes, and check for all of them. If a font
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
382 provides some but not others, warn. */
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
383 { &Vcharset_latin_iso8859_1, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
384 { &Vcharset_latin_iso8859_2, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
385 { &Vcharset_latin_iso8859_3, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
386 { &Vcharset_latin_iso8859_4, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
387 { &Vcharset_latin_iso8859_9, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
388 { &Vcharset_latin_iso8859_15, NULL, NULL },
4756
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
389 { &Vcharset_thai_tis620, "Thai", "th" },
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
390 /* We don't have an arabic charset. bidi issues, I guess? */
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
391 /* { &Vcharset_arabic_iso8859_6, "Arabic", "ar" }, */
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
392 { &Vcharset_hebrew_iso8859_8, "Hebrew", "he" },
4756
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
393 /* #### probably close enough for Ukraine? */
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
394 { &Vcharset_cyrillic_iso8859_5, "Russian", "ru" },
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
395 /* #### these probably are not quite right */
4756
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
396 { &Vcharset_chinese_big5_1, "traditional Chinese", "zh-tw" },
5d67242595a8 Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4494
diff changeset
397 { &Vcharset_chinese_big5_2, "traditional Chinese", "zh-tw" },
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
398 { NULL, NULL, NULL }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
399 };
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
400
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
401 /* Choose appropriate font name for debug messages.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
402 Use only in the top half of next function (enforced with #undef). */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
403 #define DECLARE_DEBUG_FONTNAME(__xemacs_name) \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
404 Eistring *__xemacs_name; \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
405 do \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
406 { \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
407 __xemacs_name = debug_xft > 2 ? eistr_fullname \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
408 : debug_xft > 1 ? eistr_longname \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
409 : eistr_shortname; \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
410 } while (0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
411
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
412 static Lisp_Object
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
413 xft_find_charset_font (Lisp_Object font, Lisp_Object charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
414 enum font_specifier_matchspec_stages stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
415 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
416 const Extbyte *patternext;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
417 Lisp_Object result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
418
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
419 /* #### with Xft need to handle second stage here -- sjt
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
420 Hm. Or maybe not. That would be cool. :-) */
5015
d95c102a96d3 cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents: 4981
diff changeset
421 if (stage == STAGE_FINAL)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
422 return Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
423
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
424 /* Fontconfig converts all FreeType names to UTF-8 before passing them
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
425 back to callers---see fcfreetype.c (FcFreeTypeQuery).
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
426 I don't believe this is documented. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
427
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
428 DEBUG_XFT1 (1, "confirming charset for font instance %s\n",
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
429 XSTRING_DATA (font));
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
430
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
431 /* #### this looks like a fair amount of work, but the basic design
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
432 has never been rethought, and it should be
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
433
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
434 what really should happen here is that we use FcFontSort (FcFontList?)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
435 to get a list of matching fonts, then pick the first (best) one that
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
436 gives language or repertoire coverage.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
437 */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
438
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
439 FcInit (); /* No-op if already initialized.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
440 In fontconfig 2.3.2, this cannot return
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
441 failure, but that looks like a bug. We
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
442 check for it with FcGetCurrentConfig(),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
443 which *can* fail. */
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
444 if (!FcConfigGetCurrent())
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
445 stderr_out ("Failed fontconfig initialization\n");
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
446 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
447 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
448 FcPattern *fontxft; /* long-lived, freed at end of this block */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
449 FcResult fcresult;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
450 FcConfig *fcc;
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
451 const Ascbyte *lang = "en";
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
452 FcCharSet *fccs = NULL;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
453 DECLARE_EISTRING (eistr_shortname); /* user-friendly nickname */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
454 DECLARE_EISTRING (eistr_longname); /* omit FC_LANG and FC_CHARSET */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
455 DECLARE_EISTRING (eistr_fullname); /* everything */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
456
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
457 patternext = LISP_STRING_TO_EXTERNAL (font, Qfc_font_name_encoding);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
458 fcc = FcConfigGetCurrent ();
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
459
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
460 /* parse the name, do the substitutions, and match the font */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
461
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
462 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
463 FcPattern *p = FcNameParse ((FcChar8 *) patternext);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
464 PRINT_XFT_PATTERN (3, "FcNameParse'ed name is %s\n", p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
465 /* #### Next two return FcBool, but what does the return mean? */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
466 /* The order is correct according the fontconfig docs. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
467 FcConfigSubstitute (fcc, p, FcMatchPattern);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
468 PRINT_XFT_PATTERN (2, "FcConfigSubstitute'ed name is %s\n", p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
469 FcDefaultSubstitute (p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
470 PRINT_XFT_PATTERN (3, "FcDefaultSubstitute'ed name is %s\n", p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
471 /* #### check fcresult of following match? */
4809
0d3ccd5a2509 Initialize the result variable passed to FcFontMatch. See xemacs-patches
Jerry James <james@xemacs.org>
parents: 4758
diff changeset
472 fcresult = FcResultMatch;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
473 fontxft = FcFontMatch (fcc, p, &fcresult);
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
474 switch (fcresult)
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
475 {
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
476 /* case FcResultOutOfMemory: */
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
477 case FcResultNoMatch:
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
478 case FcResultTypeMismatch:
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
479 case FcResultNoId:
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
480 break;
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
481 case FcResultMatch:
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
482 /* this prints the long fontconfig name */
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
483 PRINT_XFT_PATTERN (1, "FcFontMatch'ed name is %s\n", fontxft);
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
484 break;
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
485 }
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
486 FcPatternDestroy (p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
487 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
488
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
489 /* heuristic to give reasonable-length names for debug reports
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
490
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
491 I considered #ifdef SUPPORT_FULL_FONTCONFIG_NAME etc but that's
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
492 pointless. We're just going to remove this code once the font/
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
493 face refactoring is done, but until then it could be very useful.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
494 */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
495 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
496 FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
497 Extbyte *name;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
498
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
499 /* full name, including language coverage and repertoire */
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
500 name = (Extbyte *) FcNameUnparse (p);
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
501 eicpy_ext (eistr_fullname,
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
502 (name ? name : "NOT FOUND"),
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
503 Qfc_font_name_encoding);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
504 if (name) free (name);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
505
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
506 /* long name, omitting coverage and repertoire, plus a number
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
507 of rarely useful properties */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
508 FcPatternDel (p, FC_CHARSET);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
509 FcPatternDel (p, FC_LANG);
3841
5989b9bbb612 [xemacs-hg @ 2007-02-22 16:19:40 by stephent]
stephent
parents: 3680
diff changeset
510 #ifdef FC_WIDTH
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
511 FcPatternDel (p, FC_WIDTH);
3841
5989b9bbb612 [xemacs-hg @ 2007-02-22 16:19:40 by stephent]
stephent
parents: 3680
diff changeset
512 #endif
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
513 FcPatternDel (p, FC_SPACING);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
514 FcPatternDel (p, FC_HINTING);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
515 FcPatternDel (p, FC_VERTICAL_LAYOUT);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
516 FcPatternDel (p, FC_AUTOHINT);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
517 FcPatternDel (p, FC_GLOBAL_ADVANCE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
518 FcPatternDel (p, FC_INDEX);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
519 FcPatternDel (p, FC_SCALE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
520 FcPatternDel (p, FC_FONTVERSION);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
521 name = (Extbyte *) FcNameUnparse (p);
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
522 eicpy_ext (eistr_longname,
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
523 (name ? name : "NOT FOUND"),
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
524 Qfc_font_name_encoding);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
525 if (name) free (name);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
526
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
527 /* nickname, just family and size, but
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
528 "family" names usually have style, slant, and weight */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
529 FcPatternDel (p, FC_FOUNDRY);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
530 FcPatternDel (p, FC_STYLE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
531 FcPatternDel (p, FC_SLANT);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
532 FcPatternDel (p, FC_WEIGHT);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
533 FcPatternDel (p, FC_PIXEL_SIZE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
534 FcPatternDel (p, FC_OUTLINE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
535 FcPatternDel (p, FC_SCALABLE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
536 FcPatternDel (p, FC_DPI);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
537 name = (Extbyte *) FcNameUnparse (p);
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
538 eicpy_ext (eistr_shortname,
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
539 (name ? name : "NOT FOUND"),
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4756
diff changeset
540 Qfc_font_name_encoding);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
541 if (name) free (name);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
542
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
543 FcPatternDestroy (p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
544 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
545
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
546 /* The language approach may better in the long run, but we can't use
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
547 it based on Mule charsets; fontconfig doesn't provide a way to test
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
548 for unions of languages, etc. That will require support from the
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
549 text module.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
550
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
551 Optimization: cache the generated FcCharSet in the Mule charset.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
552 Don't forget to destroy it if the Mule charset gets deallocated. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
553
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
554 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
555 /* This block possibly should be a function, but it generates
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
556 multiple values. I find the "pass an address to return the
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
557 value in" idiom opaque, so prefer a block. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
558 struct charset_reporter *cr;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
559 for (cr = charset_table;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
560 cr->charset && !EQ (*(cr->charset), charset);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
561 cr++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
562 ;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
563
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
564 if (cr->rfc3066)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
565 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
566 DECLARE_DEBUG_FONTNAME (name);
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
567 CHECKING_LANG (0, eidata (name), cr->language);
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
568 lang = cr->rfc3066;
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
569 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
570 else if (cr->charset)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
571 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
572 /* what the hey, build 'em on the fly */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
573 /* #### in the case of error this could return NULL! */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
574 fccs = mule_to_fc_charset (charset);
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
575 /* #### Bad idea here */
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
576 lang = (const Ascbyte *) XSTRING_DATA (XSYMBOL (XCHARSET_NAME
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
577 (charset))->name);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
578 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
579 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
580 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
581 /* OK, we fell off the end of the table */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
582 warn_when_safe_lispobj (intern ("xft"), intern ("alert"),
4952
19a72041c5ed Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
583 list2 (build_ascstring ("unchecked charset"),
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
584 charset));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
585 /* default to "en"
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
586 #### THIS IS WRONG, WRONG, WRONG!!
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
587 It is why we never fall through to XLFD-checking. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
588 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
589
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
590 ASSERT_ASCTEXT_ASCII (lang);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
591
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
592 if (fccs)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
593 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
594 /* check for character set coverage */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
595 int i = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
596 FcCharSet *v;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
597 FcResult r = FcPatternGetCharSet (fontxft, FC_CHARSET, i, &v);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
598
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
599 if (r == FcResultTypeMismatch)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
600 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
601 DEBUG_XFT0 (0, "Unexpected type return in charset value\n");
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
602 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
603 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
604 else if (r == FcResultMatch && FcCharSetIsSubset (fccs, v))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
605 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
606 /* The full pattern with the bitmap coverage is massively
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
607 unwieldy, but the shorter names are just *wrong*. We
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
608 should have the full thing internally as truename, and
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
609 filter stuff the client doesn't want to see on output.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
610 Should we just store it into the truename right here? */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
611 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
612 DEBUG_XFT2 (0, "Xft font %s supports %s\n",
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
613 eidata (name), lang);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
614 #ifdef RETURN_LONG_FONTCONFIG_NAMES
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
615 result = eimake_string (eistr_fullname);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
616 #else
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
617 result = eimake_string (eistr_longname);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
618 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
619 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
620 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
621 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
622 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
623 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
624 eidata (name), lang);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
625 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
626 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
627
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
628 /* clean up */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
629 FcCharSetDestroy (fccs);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
630 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
631 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
632 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
633 /* check for language coverage */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
634 int i = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
635 FcValue v;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
636 /* the main event */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
637 FcResult r = FcPatternGet (fontxft, FC_LANG, i, &v);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
638
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
639 if (r == FcResultMatch)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
640 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
641 if (v.type != FcTypeLangSet) /* excessive paranoia */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
642 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
643 ASSERT_ASCTEXT_ASCII (FcTypeOfValueToString (v));
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
644 /* Urk! Fall back and punt to core font. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
645 DEBUG_XFT1 (0, "Unexpected type of lang value (%s)\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
646 FcTypeOfValueToString (v));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
647 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
648 }
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
649 else if (FcLangSetHasLang (v.u.l, (FcChar8 *) lang)
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
650 != FcLangDifferentLang)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
651 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
652 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
653 DEBUG_XFT2 (0, "Xft font %s supports %s\n",
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
654 eidata (name), lang);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
655 #ifdef RETURN_LONG_FONTCONFIG_NAMES
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
656 result = eimake_string (eistr_fullname);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
657 #else
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
658 result = eimake_string (eistr_longname);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
659 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
660 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
661 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
662 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
663 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
664 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
665 eidata (name), lang);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
666 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
667 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
668 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
669 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
670 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
671 ASSERT_ASCTEXT_ASCII (FcResultToString (r));
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
672 DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
673 FcResultToString (r));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
674 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
675 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
676 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
677
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
678 /* clean up and maybe return */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
679 FcPatternDestroy (fontxft);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
680 if (!UNBOUNDP (result))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
681 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
682 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
683 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
684 return Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
685 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
686 #undef DECLARE_DEBUG_FONTNAME
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
687
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
688 #endif /* USE_XFT */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
689
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
690 /* find a font spec that matches font spec FONT and also matches
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
691 (the registry of) CHARSET. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
692 static Lisp_Object
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
693 XFUN (find_charset_font) (Lisp_Object device, Lisp_Object font,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
694 Lisp_Object charset,
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
695 enum font_specifier_matchspec_stages stage)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
696 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
697 Lisp_Object result = Qnil, registries = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
698 int j, hyphen_count, registries_len = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
699 Ibyte *hyphening, *new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
700 Bytecount xlfd_length;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
701
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
702 DECLARE_EISTRING (ei_xlfd_without_registry);
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
703 DECLARE_EISTRING (ei_xlfd);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
704
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
705 #ifdef USE_XFT
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
706 result = xft_find_charset_font (font, charset, stage);
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
707 if (!NILP (result))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
708 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
709 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
710 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
711 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
712
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
713 switch (stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
714 {
5015
d95c102a96d3 cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents: 4981
diff changeset
715 case STAGE_INITIAL:
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
716 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
717 if (!(NILP (XCHARSET_REGISTRIES (charset)))
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
718 && VECTORP (XCHARSET_REGISTRIES (charset)))
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
719 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
720 registries_len = XVECTOR_LENGTH (XCHARSET_REGISTRIES (charset));
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
721 registries = XCHARSET_REGISTRIES (charset);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
722 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
723 break;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
724 }
5015
d95c102a96d3 cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents: 4981
diff changeset
725 case STAGE_FINAL:
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
726 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
727 registries_len = 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
728 registries = Qunicode_registries;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
729 break;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
730 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
731 default:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
732 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
733 assert (0);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
734 break;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
735 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
736 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
737
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
738 eicpy_lstr (ei_xlfd, font);
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
739 hyphening = eidata (ei_xlfd);
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
740 xlfd_length = eilen (ei_xlfd);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
741
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
742 /* Count the hyphens in the string, moving new_hyphening to just after the
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
743 last one. */
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
744 hyphen_count = count_hyphens (hyphening, xlfd_length, &new_hyphening);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
745
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
746 if (0 == registries_len || (5 > hyphen_count &&
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
747 !(1 == xlfd_length && '*' == *hyphening)))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
748 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
749 /* No proper XLFD specified, or we can't modify the pattern to change
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
750 the registry and encoding to match what we want, or we have no
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
751 information on the registry needed. */
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
752 result = xlistfonts_checking_charset (device, eidata (ei_xlfd),
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
753 charset, stage);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
754 /* No need to loop through the available registries; return
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
755 immediately. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
756 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
757 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
758 else if (1 == xlfd_length && '*' == *hyphening)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
759 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
760 /* It's a single asterisk. We can add the registry directly to the
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
761 end. */
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
762 eicpy_ch (ei_xlfd_without_registry, '*');
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
763 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
764 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
765 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
766 /* It's a fully-specified XLFD. Work out where the registry and
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
767 encoding are, and initialise ei_xlfd_without_registry to the string
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
768 without them. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
769
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
770 /* count_hyphens has set new_hyphening to just after the last
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
771 hyphen. Move back to just after the hyphen before it. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
772
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
773 for (new_hyphening -= 2; new_hyphening > hyphening
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
774 && '-' != *new_hyphening; --new_hyphening)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
775 ;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
776 ++new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
777
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
778 eicpy_ei (ei_xlfd_without_registry, ei_xlfd);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
779
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
780 /* Manipulate ei_xlfd_without_registry, using the information about
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
781 ei_xlfd, to which it's identical. */
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
782 eidel (ei_xlfd_without_registry, new_hyphening - hyphening, -1,
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
783 eilen (ei_xlfd) - (new_hyphening - hyphening), -1);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
784
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
785 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
786
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
787 /* Now, loop through the registries and encodings defined for this
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
788 charset, doing an XListFonts each time with the pattern modified to
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
789 specify the regisry and encoding. This avoids huge amounts of IPC and
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
790 duplicated searching; now we use the searching the X server was doing
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
791 anyway, where before the X server did its search, transferred huge
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
792 amounts of data, and then we proceeded to do a regexp search on that
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
793 data. */
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
794 for (j = 0; j < registries_len && NILP (result); ++j)
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
795 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
796 eireset (ei_xlfd);
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
797 eicpy_ei (ei_xlfd, ei_xlfd_without_registry);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
798
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
799 eicat_lstr (ei_xlfd, XVECTOR_DATA (registries)[j]);
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
800
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
801 result = xlistfonts_checking_charset (device, eidata (ei_xlfd),
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
802 charset, stage);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
803 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
804
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
805 /* In the event that the charset is ASCII and we haven't matched
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
806 anything up to now, even with a pattern of "*", add "iso8859-1"
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
807 to the charset's registry and try again. Not returning a result
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
808 for ASCII means our frame geometry calculations are
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
809 inconsistent, and that we may crash. */
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
810
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
811 if (1 == xlfd_length && EQ (charset, Vcharset_ascii) && NILP (result)
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
812 && ('*' == eigetch (ei_xlfd_without_registry, 0)))
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
813
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
814 {
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
815 int have_latin1 = 0;
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
816
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
817 /* Set this to, for example, is08859-1 if you want to see the
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
818 error behaviour. */
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
819
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
820 #define FALLBACK_ASCII_REGISTRY "iso8859-1"
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
821
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
822 for (j = 0; j < registries_len; ++j)
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
823 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
824 if (0 == qxestrcasecmp (XSTRING_DATA (XVECTOR_DATA (registries)[j]),
4124
9a633a00c3f2 [xemacs-hg @ 2007-08-17 08:08:05 by crestani]
crestani
parents: 3841
diff changeset
825 (Ibyte *) FALLBACK_ASCII_REGISTRY))
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
826 {
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
827 have_latin1 = 1;
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
828 break;
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
829 }
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
830 }
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
831
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
832 if (!have_latin1)
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
833 {
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
834 Lisp_Object new_registries = make_vector (registries_len + 1, Qnil);
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
835
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
836 XVECTOR_DATA (new_registries)[0]
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
837 = build_ascstring (FALLBACK_ASCII_REGISTRY);
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
838
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
839 memcpy (XVECTOR_DATA (new_registries) + 1,
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
840 XVECTOR_DATA (registries),
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
841 sizeof XVECTOR_DATA (registries)[0] *
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
842 XVECTOR_LENGTH (registries));
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
843
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
844 /* Calling set_charset_registries instead of overwriting the
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
845 value directly, to allow the charset font caches to be
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
846 invalidated and a change to the default face to be
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
847 noted. */
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
848 set_charset_registries (charset, new_registries);
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
849
3680
efca49973324 [xemacs-hg @ 2006-11-15 21:12:13 by aidan]
aidan
parents: 3676
diff changeset
850 warn_when_safe (Qface, Qwarning,
efca49973324 [xemacs-hg @ 2006-11-15 21:12:13 by aidan]
aidan
parents: 3676
diff changeset
851 "Your ASCII charset registries contain nothing "
efca49973324 [xemacs-hg @ 2006-11-15 21:12:13 by aidan]
aidan
parents: 3676
diff changeset
852 "sensible. Adding `" FALLBACK_ASCII_REGISTRY "'.");
efca49973324 [xemacs-hg @ 2006-11-15 21:12:13 by aidan]
aidan
parents: 3676
diff changeset
853
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
854 /* And recurse. */
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
855 result =
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
856 DEVMETH_OR_GIVEN (XDEVICE (device), find_charset_font,
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
857 (device, font, charset, stage),
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
858 result);
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
859 }
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
860 else
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
861 {
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
862 DECLARE_EISTRING (ei_connection_name);
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
863
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
864 /* We preserve a copy of the connection name for the error message
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
865 after the device is deleted. */
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
866 eicpy_lstr (ei_connection_name,
5189
b65692aa90d8 Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents: 5176
diff changeset
867 DEVICE_CONNECTION (XDEVICE (device)));
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
868
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
869 stderr_out ("Cannot find a font for ASCII, deleting device on %s\n",
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
870 eidata (ei_connection_name));
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
871
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
872 io_error_delete_device (device);
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
873
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
874 /* Do a normal warning in the event that we have other, non-X
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
875 frames available. (If we don't, io_error_delete_device will
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
876 have exited.) */
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
877 warn_when_safe
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
878 (Qface, Qerror,
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
879 "Cannot find a font for ASCII, deleting device on %s.\n"
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
880 "\n"
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
881 "Your X server fonts appear to be inconsistent; fix them, or\n"
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
882 "the next frame you create on that DISPLAY will crash this\n"
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
883 "XEmacs. At a minimum, provide one font with an XLFD ending\n"
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
884 "in `" FALLBACK_ASCII_REGISTRY "', so we can work out what size\n"
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
885 "a frame should be. ",
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
886 eidata (ei_connection_name));
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
887 }
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
888
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
889 }
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
890
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
891 /* This function used to return the font spec, in the case where a font
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
892 didn't exist on the X server but it did match the charset. We're not
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
893 doing that any more, because none of the other platform code does, and
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
894 the old behaviour was badly-judged in other respects, so I don't trust
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
895 the original author to have had a good reason for it. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
896
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
897 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
898 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
899
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
900 #endif /* MULE */