annotate src/font-mgr.h @ 3666:3214dca89755

[xemacs-hg @ 2006-11-07 15:58:21 by stephent] Revert inadvertant commits to unicode.el, font-mgr.h, and lread.c.
author stephent
date Tue, 07 Nov 2006 15:58:24 +0000
parents 5724b7632db3
children fd1f0c73d4df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1 /* Lisp font data structures for X and Xft.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
2
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
3 Copyright (C) 2003 Eric Knauel and Matthias Neubauer
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
4 Copyright (C) 2005 Eric Knauel
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
5 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
6
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
7 Authors: Eric Knauel <knauel@informatik.uni-tuebingen.de>
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
8 Matthias Neubauer <neubauer@informatik.uni-freiburg.de>
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
9 Stephen J. Turnbull <stephen@xemacs.org>
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
10 Created: 27 Oct 2003
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
11 Updated: 05 Mar 2005 by Stephen J. Turnbull
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
12
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
13 This file is part of XEmacs.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
14
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
15 XEmacs is free software; you can redistribute it and/or modify it
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
16 under the terms of the GNU General Public License as published by the
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
17 Free Software Foundation; either version 2, or (at your option) any
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
18 later version.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
19
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
20 XEmacs is distributed in the hope that it will be useful, but WITHOUT
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
22 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
23 for more details.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
24
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
25 You should have received a copy of the GNU General Public License
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
26 along with XEmacs; see the file COPYING. If not, write to
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
27 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
28 Boston, MA 02111-1307, USA. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
29
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
30 /* Synched up with: Not in GNU Emacs. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
31
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
32 /* This module provides the Lisp interface to fonts in X11, including Xft,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
33 but (at least at first) not GTK+ or Qt.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
34
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
35 It should be renamed to fonts-x.h.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
36
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
37 Sealevel code should be in ../lwlib/lwlib-fonts.h or
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
38 ../lwlib/lwlib-colors.h.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
39 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
40
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
41
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
42 #ifndef INCLUDED_font_mgr_h_
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
43 #define INCLUDED_font_mgr_h_
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
44
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
45 #include "../lwlib/lwlib-fonts.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
46 #include "../lwlib/lwlib-colors.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
47
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
48 extern Fixnum debug_xft;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
49
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
50 /* Standard for fontconfig. Use a macro to show we're not guessing. */
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
51 #define Qfc_font_name_encoding Qutf_8
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
52
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
53 #define XE_XLFD_MAKE_LISP_STRING(s) (make_string(s, strlen(s)))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
54
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
55 struct fc_pattern
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
56 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
57 struct LCRECORD_HEADER header;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
58 FcPattern *fcpatPtr;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
59 };
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
60
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
61 typedef struct fc_pattern fc_pattern;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
62
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
63 DECLARE_LRECORD(fc_pattern, struct fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
64 #define XFCPATTERN(x) XRECORD (x, fc_pattern, struct fc_pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
65 #define wrap_fcpattern(p) wrap_record (p, fc_pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
66 #define FCPATTERNP(x) RECORDP (x, fc_pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
67 #define CHECK_FCPATTERN(x) CHECK_RECORD (x, fc_pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
68 #define CONCHECK_FCPATTERN(x) CONCHECK_RECORD (x, fc_pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
69 #define XFCPATTERN_PTR(x) (XFCPATTERN(x)->fcpatPtr)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
70
3666
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
71 #ifdef USE_XFT
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
72 /*
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
73 The format of a fontname (as returned by fontconfig) is not well-documented,
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
74 But the character repertoire is represented in an ASCII-compatible way. See
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
75 fccharset.c (FcCharSetUnparse). So we can use UTF-8 for long names.
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
76
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
77 Currently we have a hack where different versions of the unparsed name are
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
78 used in different contexts fairly arbitrarily. I don't think this is close
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
79 to coherency; even without the charset and lang properties fontconfig names
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
80 are too unwieldy to use. We need to rethink the approach here. I think
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
81 probably Lisp_Font_Instance.name should contain the font name as specified
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
82 to Lisp (almost surely much shorter than shortname, even, and most likely
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
83 wildcarded), while Lisp_Font_Instance.truename should contain the longname.
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
84 For now, I'm going to #ifdef the return values defaulting to short. -- sjt
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
85 */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
86
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
87 /* DEBUGGING STUFF */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
88
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
89 /* print message to stderr: one internal-format string argument */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
90 #define DEBUG_XFT0(level,s) \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
91 if (debug_xft > level) stderr_out (s)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
92
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
93 /* print message to stderr: one formatted argument */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
94 #define DEBUG_XFT1(level,format,x1) \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
95 if (debug_xft > level) stderr_out (format, x1)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
96
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
97 /* print message to stderr: two formatted arguments */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
98 #define DEBUG_XFT2(level,format,x1,x2) \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
99 if (debug_xft > level) stderr_out (format, x1, x2)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
100
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
101 /* print message to stderr: three formatted arguments */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
102 #define DEBUG_XFT3(level,format,x1,x2,x3) \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
103 if (debug_xft > level) stderr_out (format, x1, x2, x3)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
104
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
105 /* print message to stderr: four formatted arguments */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
106 #define DEBUG_XFT4(level,format,x1,x2,x3,x4) \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
107 if (debug_xft > level) stderr_out (format, x1, x2, x3, x4)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
108
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
109 /* print an Xft pattern to stderr
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
110 LEVEL is the debug level (to compare to debug_xft)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
111 FORMAT is a newline-terminated printf format with one %s for the pattern
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
112 and must be internal format (eg, pure ASCII)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
113 PATTERN is an FcPattern *. */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
114 #define PRINT_XFT_PATTERN(level,format,pattern) \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
115 do { \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
116 DECLARE_EISTRING (eistrpxft_name); \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
117 FcChar8 *name = FcNameUnparse (pattern); \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
118 \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
119 eicpy_ext(eistrpxft_name, name, Qfc_font_name_encoding); \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
120 DEBUG_XFT1 (level, format, eidata(eistrpxft_name)); \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
121 free (name); \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
122 } while (0)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
123
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
124 /* print a progress message
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
125 LEVEL is the debug level (to compare to debug_xft)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
126 FONT is the Xft font name in UTF-8 (the native encoding of Xft)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
127 LANG is the language being checked for support (must be ASCII). */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
128 #define CHECKING_LANG(level,font,lang) \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
129 do { \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
130 DECLARE_EISTRING (eistrcl_name); \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
131 eicpy_ext(eistrcl_name, font, Qfc_font_name_encoding); \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
132 DEBUG_XFT2 (level, "checking if %s handles %s\n", \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
133 eidata(eistrcl_name), lang); \
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
134 } while (0)
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
135
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
136 #else /* USE_XFT */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
137
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
138 #endif /* USE_XFT */
3214dca89755 [xemacs-hg @ 2006-11-07 15:58:21 by stephent]
stephent
parents: 3665
diff changeset
139
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
140 #endif /* INCLUDED_font_mgr_h_ */