annotate src/objects-xlike-inc.c @ 3659:98af8a976fc3

[xemacs-hg @ 2006-11-05 22:31:31 by aidan] Support specifying fonts for particular character sets in Mule; support translation to ISO 10646-1 for Mule character sets without an otherwise matching font; move to a vector of X11-charset-X11-registry instead of a regex for the charset-registry property.
author aidan
date Sun, 05 Nov 2006 22:31:46 +0000
parents
children 3ef0aaf3dc34
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
1 /* Shared object code between X and GTK -- include file.
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.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
4 Copyright (C) 1996, 2001, 2002, 2003 Ben Wing.
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
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
25 /* 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
26 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
27 CET 2006) */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
28
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
29 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
30
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
31 #ifdef DEBUG_XEMACS
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
32 # define DEBUG_OBJECTS(FORMAT, ...) \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
33 do { if (debug_x_objects) stderr_out(FORMAT, __VA_ARGS__); } while (0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
34 #else /* DEBUG_XEMACS */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
35 # define DEBUG_OBJECTS(format, ...)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
36 #endif /* DEBUG_XEMACS */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
37
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
38 #elif defined(__GNUC__)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
39
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
40 #ifdef DEBUG_XEMACS
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
41 # define DEBUG_OBJECTS(format, args...) \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
42 do { if (debug_x_objects) stderr_out(format, args ); } while (0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
43 #else /* DEBUG_XEMACS */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
44 # define DEBUG_OBJECTS(format, args...)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
45 #endif /* DEBUG_XEMACS */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
46
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
47 #else /* defined(__STDC_VERSION__) [...] */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
48 # define DEBUG_OBJECTS (void)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
49 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
50
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
51 #ifdef MULE
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
52
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
53 /* 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
54 at run-time. For other code it isn't. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
55
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
56 static int
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
57 count_hyphens(const Ibyte *str, Bytecount length, Ibyte **last_hyphen)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
58 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
59 int hyphen_count = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
60 const Ibyte *hyphening = str;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
61 const Ibyte *new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
62
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
63 for (hyphen_count = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
64 NULL != (new_hyphening = memchr((const void *)hyphening, '-', length));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
65 hyphen_count++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
66 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
67 ++new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
68 length -= new_hyphening - hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
69 hyphening = new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
70 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
71
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
72 if (NULL != last_hyphen)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
73 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
74 *last_hyphen = (Ibyte *)hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
75 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
76
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
77 return hyphen_count;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
78 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
79
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
80 static int
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
81 #ifdef THIS_IS_GTK
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
82 gtk_font_spec_matches_charset (struct device * USED_IF_XFT (d),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
83 Lisp_Object charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
84 const Ibyte *nonreloc, Lisp_Object reloc,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
85 Bytecount offset, Bytecount length,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
86 enum font_specifier_matchspec_stages stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
87 #else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
88 x_font_spec_matches_charset (struct device * USED_IF_XFT (d),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
89 Lisp_Object charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
90 const Ibyte *nonreloc, Lisp_Object reloc,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
91 Bytecount offset, Bytecount length,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
92 enum font_specifier_matchspec_stages stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
93 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
94 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
95 Lisp_Object registries = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
96 long i, registries_len;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
97 const Ibyte *the_nonreloc;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
98 Bytecount the_length;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
99
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
100 the_nonreloc = nonreloc;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
101 the_length = length;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
102
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
103 if (!the_nonreloc)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
104 the_nonreloc = XSTRING_DATA (reloc);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
105 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
106 the_nonreloc += offset;
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 #ifdef USE_XFT
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
109 if (stage)
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 Display *dpy = DEVICE_X_DISPLAY (d);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
112 Extbyte *extname;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
113 XftFont *rf;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
114 const Ibyte *the_nonreloc;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
115
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
116 if (!NILP(reloc))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
117 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
118 the_nonreloc = XSTRING_DATA (reloc);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
119 LISP_STRING_TO_EXTERNAL (reloc, extname, Qx_font_name_encoding);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
120 rf = xft_open_font_by_name (dpy, extname);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
121 return 0; /* #### maybe this will compile and run ;) */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
122 /* Jesus, Stephen, what the fuck? */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
123 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
124 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
125 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
126
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
127 /* Hmm, this smells bad. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
128 if (UNBOUNDP (charset))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
129 return 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
130
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
131 /* 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
132 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
133 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
134 long form; sorry buster.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
135 #### FMH: this screws fontconfig/Xft?
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
136 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
137 sets (lang and charset properties).
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
138 #### 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
139 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
140 (fontconfig doesn't know about colors, although Xft does).
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
141 */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
142 if (EQ (charset, Vcharset_ascii) &&
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
143 (!memchr (the_nonreloc, '*', the_length))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
144 && (5 > (count_hyphens(the_nonreloc, the_length, NULL))))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
145 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
146 return 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
147 }
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 if (final == stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
150 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
151 registries = Qunicode_registries;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
152 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
153 else if (initial == stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
154 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
155 registries = XCHARSET_REGISTRIES (charset);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
156 if (NILP(registries))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
157 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
158 return 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
159 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
160 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
161 else assert(0);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
162
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
163 CHECK_VECTOR (registries);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
164 registries_len = XVECTOR_LENGTH(registries);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
165
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
166 for (i = 0; i < registries_len; ++i)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
167 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
168 if (!(STRINGP(XVECTOR_DATA(registries)[i]))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
169 || (XSTRING_LENGTH(XVECTOR_DATA(registries)[i]) > the_length))
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 continue;
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
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
174 /* 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
175 this comparison is case insensitive: XLFD, section 3.11:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
176
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
177 "Alphabetic case distinctions are allowed but are for human
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
178 readability concerns only. Conforming X servers will perform
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
179 matching on font name query or open requests independent of case." */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
180 if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[i]),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
181 the_nonreloc + (the_length -
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
182 XSTRING_LENGTH
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
183 (XVECTOR_DATA(registries)[i]))))
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 return 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
186 }
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 return 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
189 }
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 static Lisp_Object
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
192 xlistfonts_checking_charset (Lisp_Object device, const Extbyte *xlfd,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
193 Lisp_Object charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
194 enum font_specifier_matchspec_stages stage)
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 Extbyte **names;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
197 Lisp_Object result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
198 int count = 0, i;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
199 DECLARE_EISTRING(ei_single_result);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
200
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
201 names = XListFonts (
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
202 #ifdef THIS_IS_GTK
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
203 GDK_DISPLAY (),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
204 #else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
205 DEVICE_X_DISPLAY (XDEVICE (device)),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
206 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
207 xlfd, MAX_FONT_COUNT, &count);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
208
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
209 for (i = 0; i < count; ++i)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
210 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
211 eireset(ei_single_result);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
212 eicpy_ext(ei_single_result, names[i], Qx_font_name_encoding);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
213
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
214 if (DEVMETH_OR_GIVEN(XDEVICE (device), font_spec_matches_charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
215 (XDEVICE (device), charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
216 eidata(ei_single_result), Qnil, 0,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
217 -1, stage), 0))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
218 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
219 result = eimake_string(ei_single_result);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
220 DEBUG_OBJECTS ("in xlistfonts_checking_charset, returning %s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
221 eidata(ei_single_result));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
222 break;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
223 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
224 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
225
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
226 if (names)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
227 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
228 XFreeFontNames (names);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
229 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
230
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
231 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
232 }
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 #ifdef USE_XFT
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
235 /* #### debug functions: find a better place for us */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
236 const char *FcResultToString (FcResult r);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
237 const char *
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
238 FcResultToString (FcResult r)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
239 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
240 static char buffer[256];
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
241 switch (r)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
242 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
243 case FcResultMatch:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
244 return "FcResultMatch";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
245 case FcResultNoMatch:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
246 return "FcResultNoMatch";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
247 case FcResultTypeMismatch:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
248 return "FcResultTypeMismatch";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
249 case FcResultNoId:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
250 return "FcResultNoId";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
251 default:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
252 snprintf (buffer, 255, "FcResultUndocumentedValue (%d)", r);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
253 return buffer;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
254 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
255 }
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 const char *FcTypeOfValueToString (FcValue v);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
258 const char *
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
259 FcTypeOfValueToString (FcValue v)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
260 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
261 static char buffer[256];
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
262 switch (v.type)
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 case FcTypeMatrix:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
265 return "FcTypeMatrix";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
266 case FcTypeString:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
267 return "FcTypeString";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
268 case FcTypeVoid:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
269 return "FcTypeVoid";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
270 case FcTypeDouble:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
271 return "FcTypeDouble";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
272 case FcTypeInteger:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
273 return "FcTypeInteger";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
274 case FcTypeBool:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
275 return "FcTypeBool";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
276 case FcTypeCharSet:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
277 return "FcTypeCharSet";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
278 case FcTypeLangSet:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
279 return "FcTypeLangSet";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
280 /* #### 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
281 FcPattern* members, as of fontconfig.h FC_VERSION 10002 */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
282 case FcTypeFTFace:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
283 return "FcTypeFTFace";
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
284 default:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
285 snprintf (buffer, 255, "FcTypeUndocumentedType (%d)", v.type);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
286 return buffer;
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 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
289
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
290 static FcCharSet *
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
291 mule_to_fc_charset (Lisp_Object cs)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
292 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
293 int ucode, i, j;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
294 FcCharSet *fccs;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
295
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
296 CHECK_CHARSET (cs);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
297 fccs = FcCharSetCreate ();
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
298 /* #### 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
299 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
300 if (1 == XCHARSET_DIMENSION (cs))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
301 /* 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
302 for (i = 0; i < 96; i++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
303 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
304 ucode = ((int *) XCHARSET_TO_UNICODE_TABLE (cs))[i];
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
305 if (ucode >= 0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
306 /* #### should check for allocation failure */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
307 FcCharSetAddChar (fccs, (FcChar32) ucode);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
308 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
309 else if (2 == XCHARSET_DIMENSION (cs))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
310 /* 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
311 for (i = 0; i < 96; i++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
312 for (j = 0; j < 96; j++)
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 ucode = ((int **) XCHARSET_TO_UNICODE_TABLE (cs))[i][j];
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
315 if (ucode >= 0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
316 /* #### should check for allocation failure */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
317 FcCharSetAddChar (fccs, (FcChar32) ucode);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
318 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
319 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
320 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
321 FcCharSetDestroy (fccs);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
322 fccs = NULL;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
323 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
324 return fccs;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
325 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
326
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
327 struct charset_reporter {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
328 Lisp_Object *charset;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
329 /* This is a debug facility, require ASCII. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
330 Extbyte *language; /* ASCII, please */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
331 /* Technically this is FcChar8, but fsckin' GCC 4 bitches. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
332 Extbyte *rfc3066; /* ASCII, please */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
333 };
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
334
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
335 static struct charset_reporter charset_table[] =
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
336 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
337 /* #### 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
338 That's a joke, Son.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
339 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
340 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
341 { &Vcharset_ascii, "English", "en" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
342 { &Vcharset_japanese_jisx0208, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
343 { &Vcharset_japanese_jisx0212, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
344 { &Vcharset_katakana_jisx0201, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
345 { &Vcharset_latin_jisx0201, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
346 { &Vcharset_japanese_jisx0208_1978, "Japanese", "ja" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
347 { &Vcharset_greek_iso8859_7, "Greek", "el" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
348 /* #### all the Chinese need checking
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
349 Damn the blood-sucking ISO anyway. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
350 { &Vcharset_chinese_gb2312, "simplified Chinese", "zh-CN" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
351 { &Vcharset_korean_ksc5601, "Korean", "ko" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
352 { &Vcharset_chinese_cns11643_1, "traditional Chinese", "zh-TW" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
353 { &Vcharset_chinese_cns11643_2, "traditional Chinese", "zh-TW" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
354 { &Vcharset_latin_iso8859_1, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
355 { &Vcharset_latin_iso8859_2, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
356 { &Vcharset_latin_iso8859_3, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
357 { &Vcharset_latin_iso8859_4, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
358 { &Vcharset_latin_iso8859_9, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
359 { &Vcharset_latin_iso8859_15, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
360 { &Vcharset_thai_tis620, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
361 { &Vcharset_arabic_iso8859_6, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
362 { &Vcharset_hebrew_iso8859_8, "Hebrew", "he" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
363 { &Vcharset_cyrillic_iso8859_5, NULL, NULL },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
364 /* #### these probably are not quite right */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
365 { &Vcharset_chinese_big5_1, "traditional Chinese", "zh-TW" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
366 { &Vcharset_chinese_big5_2, "traditional Chinese", "zh-TW" },
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
367 { NULL, NULL, NULL }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
368 };
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
369
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
370 /* Choose appropriate font name for debug messages.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
371 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
372 #define DECLARE_DEBUG_FONTNAME(__xemacs_name) \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
373 Eistring *__xemacs_name; \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
374 do \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
375 { \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
376 __xemacs_name = debug_xft > 2 ? eistr_fullname \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
377 : debug_xft > 1 ? eistr_longname \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
378 : eistr_shortname; \
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
379 } while (0)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
380
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
381 static Lisp_Object
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
382 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
383 enum font_specifier_matchspec_stages stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
384 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
385 const Extbyte *patternext;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
386 Lisp_Object result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
387
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
388 /* #### with Xft need to handle second stage here -- sjt
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
389 Hm. Or maybe not. That would be cool. :-) */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
390 if (stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
391 return Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
392
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
393 /* 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
394 back to callers---see fcfreetype.c (FcFreeTypeQuery).
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
395 I don't believe this is documented. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
396
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
397 DEBUG_XFT1 (1, "confirming charset for font instance %s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
398 XSTRING_DATA(font));
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 /* #### 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
401 has never been rethought, and it should be
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
402
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
403 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
404 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
405 gives language or repertoire coverage.
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
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
408 FcInit (); /* No-op if already initialized.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
409 In fontconfig 2.3.2, this cannot return
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
410 failure, but that looks like a bug. We
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
411 check for it with FcGetCurrentConfig(),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
412 which *can* fail. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
413 if (!FcConfigGetCurrent()) /* #### We should expose FcInit* interfaces
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
414 to LISP and decide when to reinitialize
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
415 intelligently. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
416 stderr_out ("Failed fontconfig initialization\n");
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
417 else
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 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
420 FcResult fcresult;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
421 FcConfig *fcc;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
422 FcChar8 *lang = (FcChar8 *) "en"; /* #### fix this bogus hack! */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
423 FcCharSet *fccs = NULL;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
424 DECLARE_EISTRING (eistr_shortname); /* user-friendly nickname */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
425 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
426 DECLARE_EISTRING (eistr_fullname); /* everything */
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 LISP_STRING_TO_EXTERNAL (font, patternext, Qfc_font_name_encoding);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
429 fcc = FcConfigGetCurrent ();
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 /* 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
432
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 FcPattern *p = FcNameParse ((FcChar8 *) patternext);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
435 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
436 /* #### 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
437 /* The order is correct according the fontconfig docs. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
438 FcConfigSubstitute (fcc, p, FcMatchPattern);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
439 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
440 FcDefaultSubstitute (p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
441 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
442 /* #### check fcresult of following match? */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
443 fontxft = FcFontMatch (fcc, p, &fcresult);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
444 /* this prints the long fontconfig name */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
445 PRINT_XFT_PATTERN (1, "FcFontMatch'ed name is %s\n", fontxft);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
446 FcPatternDestroy (p);
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
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
449 /* heuristic to give reasonable-length names for debug reports
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
450
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
451 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
452 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
453 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
454 */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
455 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
456 FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
457 FcChar8 *name;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
458
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
459 /* full name, including language coverage and repertoire */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
460 name = FcNameUnparse (p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
461 eicpy_ext (eistr_fullname, (Extbyte *) name, Qfc_font_name_encoding);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
462 free (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
463
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
464 /* long name, omitting coverage and repertoire, plus a number
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
465 of rarely useful properties */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
466 FcPatternDel (p, FC_CHARSET);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
467 FcPatternDel (p, FC_LANG);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
468 FcPatternDel (p, FC_WIDTH);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
469 FcPatternDel (p, FC_SPACING);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
470 FcPatternDel (p, FC_HINTING);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
471 FcPatternDel (p, FC_VERTICAL_LAYOUT);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
472 FcPatternDel (p, FC_AUTOHINT);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
473 FcPatternDel (p, FC_GLOBAL_ADVANCE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
474 FcPatternDel (p, FC_INDEX);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
475 FcPatternDel (p, FC_SCALE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
476 FcPatternDel (p, FC_FONTVERSION);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
477 name = FcNameUnparse (p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
478 eicpy_ext (eistr_longname, (Extbyte *) name, Qfc_font_name_encoding);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
479 free (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
480
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
481 /* nickname, just family and size, but
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
482 "family" names usually have style, slant, and weight */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
483 FcPatternDel (p, FC_FOUNDRY);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
484 FcPatternDel (p, FC_STYLE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
485 FcPatternDel (p, FC_SLANT);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
486 FcPatternDel (p, FC_WEIGHT);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
487 FcPatternDel (p, FC_PIXEL_SIZE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
488 FcPatternDel (p, FC_OUTLINE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
489 FcPatternDel (p, FC_SCALABLE);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
490 FcPatternDel (p, FC_DPI);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
491 name = FcNameUnparse (p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
492 eicpy_ext (eistr_shortname, (Extbyte *) name, Qfc_font_name_encoding);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
493 free (name);
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 FcPatternDestroy (p);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
496 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
497
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
498 /* 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
499 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
500 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
501 text module.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
502
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
503 Optimization: cache the generated FcCharSet in the Mule charset.
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
504 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
505
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
506 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
507 /* 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
508 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
509 value in" idiom opaque, so prefer a block. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
510 struct charset_reporter *cr;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
511 for (cr = charset_table;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
512 cr->charset && !EQ (*(cr->charset), charset);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
513 cr++)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
514 ;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
515
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
516 if (cr->rfc3066)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
517 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
518 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
519 CHECKING_LANG (0, eidata(name), cr->language);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
520 lang = (FcChar8 *) cr->rfc3066;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
521 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
522 else if (cr->charset)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
523 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
524 /* what the hey, build 'em on the fly */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
525 /* #### in the case of error this could return NULL! */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
526 fccs = mule_to_fc_charset (charset);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
527 lang = (FcChar8 *) XSTRING_DATA (XSYMBOL
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
528 (XCHARSET_NAME (charset))-> name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
529 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
530 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
531 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
532 /* OK, we fell off the end of the table */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
533 warn_when_safe_lispobj (intern ("xft"), intern ("alert"),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
534 list2 (build_string ("unchecked charset"),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
535 charset));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
536 /* default to "en"
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
537 #### THIS IS WRONG, WRONG, WRONG!!
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
538 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
539 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
540
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
541 ASSERT_ASCTEXT_ASCII((Extbyte *) lang);
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 if (fccs)
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 /* check for character set coverage */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
546 int i = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
547 FcCharSet *v;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
548 FcResult r = FcPatternGetCharSet (fontxft, FC_CHARSET, i, &v);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
549
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
550 if (r == FcResultTypeMismatch)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
551 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
552 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
553 result = Qnil;
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 else if (r == FcResultMatch && FcCharSetIsSubset (fccs, v))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
556 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
557 /* The full pattern with the bitmap coverage is massively
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
558 unwieldy, but the shorter names are just *wrong*. We
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
559 should have the full thing internally as truename, and
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
560 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
561 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
562 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
563 DEBUG_XFT2 (0, "Xft font %s supports %s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
564 eidata(name), lang);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
565 #ifdef RETURN_LONG_FONTCONFIG_NAMES
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
566 result = eimake_string(eistr_fullname);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
567 #else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
568 result = eimake_string(eistr_longname);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
569 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
570 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
571 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
572 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
573 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
574 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
575 eidata(name), lang);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
576 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
577 }
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 /* clean up */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
580 FcCharSetDestroy (fccs);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
581 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
582 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
583 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
584 /* check for language coverage */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
585 int i = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
586 FcValue v;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
587 /* the main event */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
588 FcResult r = FcPatternGet (fontxft, FC_LANG, i, &v);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
589
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
590 if (r == FcResultMatch)
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 (v.type != FcTypeLangSet) /* excessive paranoia */
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 ASSERT_ASCTEXT_ASCII(FcTypeOfValueToString(v));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
595 /* Urk! Fall back and punt to core font. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
596 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
597 FcTypeOfValueToString (v));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
598 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
599 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
600 else if (FcLangSetHasLang (v.u.l, lang) != FcLangDifferentLang)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
601 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
602 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
603 DEBUG_XFT2 (0, "Xft font %s supports %s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
604 eidata(name), lang);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
605 #ifdef RETURN_LONG_FONTCONFIG_NAMES
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
606 result = eimake_string(eistr_fullname);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
607 #else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
608 result = eimake_string(eistr_longname);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
609 #endif
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
610 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
611 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
612 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
613 DECLARE_DEBUG_FONTNAME (name);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
614 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
615 eidata(name), lang);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
616 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
617 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
618 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
619 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
620 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
621 ASSERT_ASCTEXT_ASCII(FcResultToString(r));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
622 DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
623 FcResultToString (r));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
624 result = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
625 }
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 and maybe return */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
629 FcPatternDestroy (fontxft);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
630 if (!UNBOUNDP (result))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
631 return result;
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 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
634 return Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
635 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
636 #undef DECLARE_DEBUG_FONTNAME
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
637
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
638 #endif /* USE_XFT */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
639
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
640 /* 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
641 (the registry of) CHARSET. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
642 static Lisp_Object
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
643 #ifdef THIS_IS_GTK
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
644 gtk_find_charset_font (Lisp_Object device, Lisp_Object font,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
645 Lisp_Object charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
646 enum font_specifier_matchspec_stages stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
647 #else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
648 x_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
649 enum font_specifier_matchspec_stages stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
650 #endif
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 Lisp_Object result = Qnil, registries = Qnil;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
653 int j, hyphen_count, registries_len = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
654 Ibyte *hyphening, *new_hyphening;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
655 Bytecount xlfd_length;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
656
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
657 DECLARE_EISTRING(ei_xlfd_without_registry);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
658 DECLARE_EISTRING(ei_xlfd);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
660 #ifdef USE_XFT
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
661 result = xft_find_charset_font(font, charset, stage);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
662 if (!NILP(result))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
663 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
664 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
665 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
666 #endif
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 switch (stage)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
669 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
670 case initial:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
671 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
672 if (!(NILP(XCHARSET_REGISTRIES(charset)))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
673 && VECTORP(XCHARSET_REGISTRIES(charset)))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
674 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
675 registries_len = XVECTOR_LENGTH(XCHARSET_REGISTRIES(charset));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
676 registries = XCHARSET_REGISTRIES(charset);
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 break;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
679 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
680 case final:
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
681 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
682 registries_len = 1;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
683 registries = Qunicode_registries;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
684 break;
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 default:
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 assert(0);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
689 break;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
690 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
691 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
692
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
693 eicpy_lstr(ei_xlfd, font);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
694 hyphening = eidata(ei_xlfd);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
695 xlfd_length = eilen(ei_xlfd);
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 /* 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
698 last one. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
699 hyphen_count = count_hyphens(hyphening, xlfd_length, &new_hyphening);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
700
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
701 if (0 == registries_len || (5 > hyphen_count &&
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
702 !(1 == xlfd_length && '*' == *hyphening)))
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
703 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
704 /* 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
705 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
706 information on the registry needed. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
707 eito_external(ei_xlfd, Qx_font_name_encoding);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
708 DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
709 eidata(ei_xlfd));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
710 result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
711 charset, stage);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
712 /* No need to loop through the available registries; return
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
713 immediately. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
714 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
715 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
716 else if (1 == xlfd_length && '*' == *hyphening)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
717 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
718 /* 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
719 end. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
720 eicpy_ch(ei_xlfd_without_registry, '*');
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
721 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
722 else
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
723 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
724 /* 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
725 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
726 without them. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
727
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
728 /* 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
729 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
730
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
731 for (new_hyphening -= 2; new_hyphening > hyphening
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
732 && '-' != *new_hyphening; --new_hyphening)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
733 ;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
734 ++new_hyphening;
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 eicpy_ei(ei_xlfd_without_registry, ei_xlfd);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
737
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
738 /* Manipulate ei_xlfd_without_registry, using the information about
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
739 ei_xlfd, to which it's identical. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
740 eidel(ei_xlfd_without_registry, new_hyphening - hyphening, -1,
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
741 eilen(ei_xlfd) - (new_hyphening - hyphening), -1);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
742
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
743 }
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
744
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
745 /* 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
746 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
747 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
748 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
749 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
750 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
751 data. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
752 for (j = 0; j < registries_len && NILP(result); ++j)
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
753 {
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
754 eireset(ei_xlfd);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
755 eicpy_ei(ei_xlfd, ei_xlfd_without_registry);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
756
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
757 eicat_lstr(ei_xlfd, XVECTOR_DATA(registries)[j]);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
758
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
759 eito_external(ei_xlfd, Qx_font_name_encoding);
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
760
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
761 DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n",
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
762 eidata(ei_xlfd));
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
763 result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd),
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
764 charset, stage);
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
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
767 /* 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
768 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
769 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
770 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
771 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
772
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
773 return result;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents:
diff changeset
774 }
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 #endif /* MULE */