annotate src/font-mgr.c @ 3372:182c0df289b7

[xemacs-hg @ 2006-05-01 18:17:20 by stephent] Nuke spurious debugging output. <87zmi1628i.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Mon, 01 May 2006 18:17:23 +0000
parents 316fddbf58e2
children f986ebd9c080
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 handling implementation for X with 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 Sealevel code should be in ../lwlib/lwlib-fonts.c or
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
36 ../lwlib/lwlib-colors.c.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
37 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
38
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
39 #include <config.h>
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
40 #include "lisp.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
41 #include "device.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
42 #include "device-impl.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
43 #include "console-x-impl.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
44 #include "objects-x.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
45 #include "objects-x-impl.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
46 #include "hash.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
47 #include "font-mgr.h"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
48
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
49 /* #### TO DO ####
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
50 . The "x-xft-*" and "x_xft_*" nomenclature is mostly redundant, especially
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
51 if we separate X fonts from Xft fonts, and use fontconfig more generally.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
52 . We should support the most recent Xft first, old Xft libraries later.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
53 . We may (think about it) wish to use fontconfig generally, even if we're
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
54 not using Xft. Either way, names that are really from fontconfig should
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
55 use the Fc* namespace.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
56 . Mule-ize this file.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
57 . Separate X Font Struct ops from Xft Font ops; give precedence to Xft but
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
58 allow fallback to X.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
59 . Push decisions about font choice, defaults, fallbacks to Lisp; if we
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
60 really need efficiency, can reimplement in C later.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
61 . Implement symbols interned in this file in the Q* namespace.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
62 . Implement FcMatrix (Lisp vector).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
63 . Implement FcCharSets (Lisp chartable? For implementation hints, see
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
64 FcCharSetFirstPage and FcCharSetNextPage).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
65 . Implement FcConfigs.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
66 DONE
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
67 . Fontconfig fontnames are encoded in UTF-8.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
68 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
69
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
70 Lisp_Object Qfont_mgr;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
71 Lisp_Object Qfc_patternp;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
72 Lisp_Object Qfc_fontsetp;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
73 /* Lisp_Object Qfc_result_match; */ /* FcResultMatch */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
74 Lisp_Object Qfc_result_type_mismatch; /* FcResultTypeMismatch */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
75 Lisp_Object Qfc_result_no_match; /* FcResultNoMatch */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
76 Lisp_Object Qfc_result_no_id; /* FcResultNoId */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
77 Lisp_Object Qfc_internal_error;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
78 Lisp_Object Vxlfd_font_name_regexp; /* #### Really needed? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
79 Lisp_Object Vxft_version;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
80 /* Lisp_Object Vfc_version; */ /* #### Should have this, too! */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
81 Fixnum debug_xft; /* Set to 1 enables lots of obnoxious messages.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
82 Setting it to 2 or 3 enables even more. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
83
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
84 /****************************************************************
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
85 * FcPattern objects *
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
86 ****************************************************************/
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
87
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
88 static void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
89 finalize_fc_pattern (void *header, int UNUSED (for_disksave))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
90 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
91 struct fc_pattern *p = (struct fc_pattern *) header;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
92 if (p->fcpatPtr)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
93 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
94 FcPatternDestroy (p->fcpatPtr);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
95 p->fcpatPtr = 0;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
96 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
97 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
98
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
99 static const struct memory_description fcpattern_description [] = {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
100 /* #### nothing here, is this right?? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
101 { XD_END }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
102 };
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
103
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
104 DEFINE_LRECORD_IMPLEMENTATION("fc-pattern", fc_pattern,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
105 0, 0, 0, finalize_fc_pattern, 0, 0,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
106 fcpattern_description,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
107 struct fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
108
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
109 /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
110 * Helper Functions
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
111 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
112 static Lisp_Object make_xlfd_font_regexp (void);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
113 static void string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
114
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
115 /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
116 extract the C representation of the Lisp string STR and convert it
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
117 to the encoding used by the Fontconfig API for property and font
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
118 names. I suppose that Qnative is the right encoding, the manual
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
119 doesn't say much about this topic. This functions assumes that STR
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
120 is a Lisp string.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
121 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
122 #define extract_fcapi_string(str) \
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
123 ((FcChar8 *) NEW_LISP_STRING_TO_EXTERNAL ((str), Qfc_font_name_encoding))
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
124
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
125 /* #### This homebrew lashup should be replaced with FcConstants.
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
126
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
127 fontconfig assumes that objects (property names) are statically allocated,
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
128 and you will get bizarre results if you pass Lisp string data or strings
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
129 allocated on the stack as objects. fontconfig _does_ copy values, so we
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
130 (I hope) don't have to worry about that member.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
131
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
132 Probably these functions don't get called so often that the memory leak
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
133 due to strdup'ing every time we add a property would matter, but XEmacs
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
134 _is_ a long-running process. So we hash them.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
135
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
136 I suspect that using symbol names or even keywords does not provide
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
137 assurance that the string won't move in memory. So we hash them
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
138 ourselves; hash.c hashtables do not interpret the value pointers.
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
139
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
140 This array should be FcChar8**, but GCC 4.x bitches about signedness. */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
141 static Extbyte *fc_standard_properties[] = {
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
142 /* treated specially, ordered first */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
143 "family", "size",
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
144 /* remaining are alphabetized by group */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
145 /* standard properties in fontconfig and Xft v.2 */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
146 "antialias", "aspect", "autohint", "charset", "dpi", "file",
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
147 "foundry", "ftface", "globaladvance", "hinting", "index", "lang",
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
148 "minspace", "outline", "pixelsize", "rasterizer", "rgba", "scalable",
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
149 "scale", "slant", "spacing", "style", "verticallayout", "weight",
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
150 /* common in modern fonts */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
151 "fontformat", "fontversion",
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
152 /* obsolete after Xft v. 1 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
153 "charwidth", "charheight", "core", "encoding", "render"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
154 };
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
155
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
156 static struct hash_table *fc_property_name_hash_table;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
157
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
158 /* #### Maybe fc_intern should be exposed to LISP? The idea is that
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
159 fc-pattern-add could warn or error if the property isn't interned. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
160
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
161 static FcChar8 *
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
162 fc_intern (Lisp_Object property)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
163 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
164 const void *dummy;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
165 FcChar8 *prop = extract_fcapi_string (property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
166 const void *val = gethash (prop, fc_property_name_hash_table, &dummy);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
167
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
168 /* extract_fcapi_string returns something alloca'd
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
169 so we can just drop the old value of prop on the floor */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
170 if (val)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
171 prop = (FcChar8 *) val;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
172 else
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
173 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
174 prop = FcStrCopy (prop);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
175 puthash (prop, NULL, fc_property_name_hash_table);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
176 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
177 return prop;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
178 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
179
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
180 DEFUN("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
181 Returns t if OBJECT is of type fc-pattern, nil otherwise.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
182 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
183 (object))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
184 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
185 return FCPATTERNP(object) ? Qt : Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
186 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
187
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
188 DEFUN("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
189 Return a new, empty fc-pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
190 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
191 ())
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
192 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
193 fc_pattern *fcpat =
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
194 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
195
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
196 fcpat->fcpatPtr = FcPatternCreate();
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
197 return wrap_fcpattern(fcpat);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
198 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
199
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
200 DEFUN("fc-name-parse", Ffc_name_parse, 1, 1, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
201 Parse an Fc font name and return its representation as a fc pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
202 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
203 (name))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
204 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
205 struct fc_pattern *fcpat =
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
206 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
207
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
208 CHECK_STRING(name); /* #### MEMORY LEAK!! maybe not ... */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
209
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
210 fcpat->fcpatPtr = FcNameParse (extract_fcapi_string (name));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
211 return wrap_fcpattern(fcpat);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
212 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
213
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
214 /* #### Ga-a-ack! Xft's similar function is actually a different API.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
215 We provide both. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
216 DEFUN("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
217 Unparse an fc pattern object to a string.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
218 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
219 (pattern))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
220 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
221 CHECK_FCPATTERN(pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
222 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
223 FcChar8 *temp = FcNameUnparse(XFCPATTERN_PTR(pattern));
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
224 Lisp_Object res = build_ext_string (temp, Qfc_font_name_encoding);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
225 free (temp);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
226 return res;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
227 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
228 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
229
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
230 DEFUN("fc-pattern-duplicate", Ffc_pattern_duplicate, 1, 1, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
231 Make a copy of the fc pattern object PATTERN and return it.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
232 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
233 (pattern))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
234 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
235 struct fc_pattern *copy = NULL;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
236 CHECK_FCPATTERN(pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
237
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
238 copy = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
239 copy->fcpatPtr = FcPatternDuplicate(XFCPATTERN_PTR(pattern));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
240 return wrap_fcpattern(copy);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
241 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
242
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
243 DEFUN("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
244 Add attributes to the pattern object PATTERN. PROPERTY is a string naming
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
245 the attribute to add, VALUE the value for this attribute.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
246
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
247 VALUE may be a string, integer, float, or symbol, in which case the value
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
248 will be added as an FcChar8[], int, double, or FcBool respectively.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
249 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
250 (pattern, property, value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
251 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
252 Bool res = 0;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
253 Extbyte *obj;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
254 FcPattern *fcpat;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
255
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
256 CHECK_FCPATTERN(pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
257 CHECK_STRING(property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
258
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
259 obj = fc_intern (property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
260 fcpat = XFCPATTERN_PTR (pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
261
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
262 if (STRINGP(value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
263 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
264 FcChar8 *str = (FcChar8 *) extract_fcapi_string (value);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
265 res = FcPatternAddString (fcpat, obj, str);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
266 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
267 else if (INTP(value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
268 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
269 res = FcPatternAddInteger (fcpat, obj, XINT(value));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
270 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
271 else if (FLOATP(value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
272 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
273 res = FcPatternAddDouble (fcpat, obj, (double) XFLOAT_DATA(value));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
274 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
275 else if (SYMBOLP(value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
276 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
277 res = FcPatternAddBool (fcpat, obj, !NILP(value));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
278 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
279 /* else ... maybe we should wta here? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
280
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
281 return res ? Qt : Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
282 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
283
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
284 DEFUN("fc-pattern-del", Ffc_pattern_del, 2, 2, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
285 Remove attribute PROPERTY from fc pattern object OBJECT.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
286 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
287 (pattern, property))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
288 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
289 Bool res;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
290
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
291 CHECK_FCPATTERN(pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
292 CHECK_STRING(property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
293
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
294 res = FcPatternDel(XFCPATTERN_PTR(pattern),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
295 extract_fcapi_string (property));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
296 return res ? Qt : Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
297 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
298
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
299 /* Generic interface to FcPatternGet()
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
300 * Don't support the losing symbol-for-property interface.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
301 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
302 DEFUN("fc-pattern-get", Ffc_pattern_get, 2, 4, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
303 From PATTERN, extract PROPERTY for the ID'th member, of type TYPE.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
304
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
305 PATTERN is an Xft (fontconfig) pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
306 PROPERTY is a string naming an fontconfig font property.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
307 Optional ID is a nonnegative integer indexing the list of values for PROPERTY
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
308 stored in PATTERN, defaulting to 0 (the first value).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
309 Optional TYPE is a symbol, one of 'string, 'boolean, 'integer, 'float,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
310 'double, 'matrix, 'charset, or 'void, corresponding to the FcValue types.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
311 ('float is an alias for 'double).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
312
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
313 The Lisp types returned will conform to TYPE:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
314 string string
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
315 boolean `t' or `nil'
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
316 integer integer
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
317 double (float) float
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
318 matrix not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
319 charset not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
320 void not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
321
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
322 Symbols with names of the form "fc-result-DESCRIPTION" are returned when
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
323 the desired value is not available. These are
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
324
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
325 fc-result-type-mismatch the value found has an unexpected type
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
326 fc-result-no-match there is no such attribute
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
327 fc-result-no-id there is no value for the requested ID
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
328
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
329 The types of the following standard properties are predefined by fontconfig.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
330 The symbol 'fc-result-type-mismatch will be returned if the object exists but
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
331 TYPE does not match the predefined type. It is best not to specify a type
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
332 for predefined properties, as a mistake here ensures error returns on the
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
333 correct type.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
334
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
335 Each standard property has a convenience accessor defined in fontconfig.el,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
336 named in the form "fc-pattern-get-PROPERTY". The convenience functions are
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
337 preferred to `fc-pattern-get' since a typo in the string naming a property
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
338 will result in a silent null return, while a typo in a function name will
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
339 usually result in a compiler or runtime \"not fboundp\" error. You may use
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
340 `defsubst' to define convenience functions for non-standard properties.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
341
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
342 family String Font family name
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
343 style String Font style. Overrides weight and slant
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
344 slant Int Italic, oblique or roman
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
345 weight Int Light, medium, demibold, bold or black
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
346 size Double Point size
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
347 aspect Double Stretches glyphs horizontally before hinting
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
348 pixelsize Double Pixel size
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
349 spacing Int Proportional, monospace or charcell
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
350 foundry String Font foundry name
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
351 antialias Bool Whether glyphs can be antialiased
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
352 hinting Bool Whether the rasterizer should use hinting
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
353 verticallayout Bool Use vertical layout
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
354 autohint Bool Use autohinter instead of normal hinter
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
355 globaladvance Bool Use font global advance data
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
356 file String The filename holding the font
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
357 index Int The index of the font within the file
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
358 ftface FT_Face Use the specified FreeType face object
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
359 rasterizer String Which rasterizer is in use
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
360 outline Bool Whether the glyphs are outlines
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
361 scalable Bool Whether glyphs can be scaled
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
362 scale Double Scale factor for point->pixel conversions
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
363 dpi Double Target dots per inch
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
364 rgba Int unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
365 minspace Bool Eliminate leading from line spacing
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
366 charset CharSet Unicode chars encoded by the font
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
367 lang String List of RFC-3066-style languages this font supports
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
368
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
369 The FT_Face, Matrix, CharSet types are unimplemented, so the corresponding
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
370 properties are not accessible from Lisp at this time. If the value of a
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
371 property returned has type FT_Face, FcCharSet, or FcMatrix,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
372 `fc-result-type-mismatch' is returned.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
373
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
374 The following properties which were standard in Xft v.1 are obsolete in
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
375 Xft v.2: encoding, charwidth, charheight, core, and render. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
376 (pattern, property, id, type))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
377 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
378 FcChar8 *fc_property; /* UExtbyte * */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
379 FcResult fc_result;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
380 FcValue fc_value;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
381
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
382 /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
383 process arguments
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
384 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
385 CHECK_FCPATTERN (pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
386
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
387 #if 0
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
388 /* Don't support the losing symbol-for-property interface. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
389 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
390 #endif
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
391 if (STRINGP (property))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
392 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
393 fc_property = (FcChar8 *) extract_fcapi_string (property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
394 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
395 else
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
396 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
397 /* if we allow symbols, this would need to be
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
398 list3 (Qlambda, list1 (Qobject),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
399 list3 (Qor, list2 (Qstringp, Qobject),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
400 list2 (Qsymbolp, Qobject)))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
401 or something like that? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
402 dead_wrong_type_argument (Qstringp, property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
403 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
404
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
405 if (!NILP (id)) CHECK_NATNUM (id);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
406 if (!NILP (type)) CHECK_SYMBOL (type);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
407
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
408 /* get property */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
409 fc_result = FcPatternGet (XFCPATTERN_PTR (pattern),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
410 fc_property,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
411 NILP (id) ? 0 : XINT(id),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
412 &fc_value);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
413
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
414 switch (fc_result)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
415 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
416 case FcResultMatch:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
417 /* wrap it and return */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
418 switch (fc_value.type)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
419 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
420 case FcTypeInteger:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
421 return ((!NILP (type) && !EQ (type, Qinteger))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
422 ? Qfc_result_type_mismatch : make_int (fc_value.u.i));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
423 case FcTypeDouble:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
424 return ((!NILP (type) && !EQ (type, intern ("double"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
425 && !EQ (type, Qfloat))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
426 ? Qfc_result_type_mismatch : make_float (fc_value.u.d));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
427 case FcTypeString:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
428 return ((!NILP (type) && !EQ (type, Qstring))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
429 ? Qfc_result_type_mismatch
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
430 : build_ext_string (fc_value.u.s, Qfc_font_name_encoding));
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
431 case FcTypeBool:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
432 return ((!NILP (type) && !EQ (type, Qboolean))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
433 ? Qfc_result_type_mismatch : fc_value.u.b ? Qt : Qnil);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
434 case FcTypeMatrix:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
435 return Qfc_result_type_mismatch;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
436 /* #### unimplemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
437 return ((!NILP (type) && !EQ (type, intern ("matrix")))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
438 ? Qfc_result_type_mismatch : make_int (fc_value.u.m));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
439 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
440 case FcTypeCharSet:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
441 return Qfc_result_type_mismatch;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
442 /* #### unimplemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
443 return ((!NILP (type) && !EQ (type, intern ("charset")))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
444 ? Qfc_result_type_mismatch : make_int (fc_value.u.c));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
445 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
446 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
447 case FcResultTypeMismatch:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
448 return Qfc_result_type_mismatch;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
449 case FcResultNoMatch:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
450 return Qfc_result_no_match;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
451 case FcResultNoId:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
452 return Qfc_result_no_id;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
453 default:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
454 return Qfc_internal_error;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
455 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
456 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
457
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
458 DEFUN("fc-font-match", Ffc_font_match, 2, 2, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
459 Return the font on DEVICE that most closely matches PATTERN.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
460
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
461 DEVICE is an X11 device.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
462 PATTERN is a fontconfig pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
463 Returns a fontconfig pattern object representing the closest match to the
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
464 given pattern, or an error code. Possible error codes are
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
465 `fc-result-no-match' and `fc-result-no-id'. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
466 (device, pattern))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
467 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
468 FcResult res;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
469
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
470 struct fc_pattern *res_fcpat =
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
471 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
472 CHECK_FCPATTERN(pattern); /* #### MEMORY LEAKS!!! */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
473 if (NILP(device))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
474 return Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
475 CHECK_X_DEVICE(device);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
476 if (!DEVICE_LIVE_P(XDEVICE(device)))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
477 return Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
478
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
479 {
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
480 FcPattern *p = XFCPATTERN_PTR(pattern);
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
481 FcConfig *fcc = FcConfigGetCurrent ();
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
482
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
483 FcConfigSubstitute (fcc, p, FcMatchPattern);
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
484 FcDefaultSubstitute (p);
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
485 res_fcpat->fcpatPtr = FcFontMatch (fcc, p, &res);
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
486 }
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
487
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
488 if (res_fcpat->fcpatPtr == NULL)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
489 switch (res) {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
490 case FcResultNoMatch:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
491 return Qfc_result_no_match;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
492 case FcResultNoId:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
493 return Qfc_result_no_id;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
494 default:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
495 return Qfc_internal_error;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
496 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
497 else
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
498 return wrap_fcpattern(res_fcpat);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
499 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
500
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
501 /* NOTE NOTE NOTE This function destroys the FcFontSet passed to it. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
502 static Lisp_Object
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
503 fontset_to_list (FcFontSet *fontset)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
504 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
505 int idx;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
506 Lisp_Object fontlist = Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
507 fc_pattern *fcpat;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
508
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
509 /* #### improve this error message */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
510 if (!fontset)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
511 Fsignal (Qinvalid_state,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
512 list1 (build_string ("failed to create FcFontSet")));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
513 for (idx = 0; idx < fontset->nfont; ++idx)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
514 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
515 fcpat =
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
516 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
517 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
518 fontlist = Fcons (wrap_fcpattern(fcpat), fontlist);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
519 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
520 FcFontSetDestroy (fontset);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
521 return fontlist;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
522 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
523
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
524 /* #### fix this name to correspond to Ben's new nomenclature */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
525 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
526 3, 3, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
527 Return a list of fonts on DEVICE that match PATTERN for PROPERTIES.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
528 Each font is represented by a fontconfig pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
529
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
530 DEVICE is an X11 device.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
531 PATTERN is a fontconfig pattern to be matched.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
532 PROPERTIES is a list of property names (strings) that should match.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
533
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
534 #### DEVICE is unused, ignored, and may be removed if it's not needed to
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
535 match other font-listing APIs. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
536 (UNUSED (device), pattern, properties))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
537 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
538 FcObjectSet *os;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
539 FcFontSet *fontset;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
540
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
541 CHECK_FCPATTERN (pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
542 CHECK_LIST (properties);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
543
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
544 os = FcObjectSetCreate ();
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
545 string_list_to_fcobjectset (properties, os);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
546 /* #### why don't we need to do the "usual substitutions"? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
547 fontset = FcFontList (NULL, XFCPATTERN_PTR (pattern), os);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
548 FcObjectSetDestroy (os);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
549
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
550 return fontset_to_list (fontset);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
551
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
552 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
553
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
554 /* #### maybe this can/should be folded into fc-list-fonts-pattern-objects? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
555 DEFUN("fc-font-sort", Ffc_font_sort, 2, 4, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
556 Return a list of all fonts sorted by proximity to PATTERN.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
557 Each font is represented by a fontconfig pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
558
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
559 DEVICE is an X11 device.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
560 PATTERN is a fontconfig pattern to be matched.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
561 Optional argument TRIM, if non-nil, means to trim trailing fonts that do not
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
562 contribute new characters to the union repertoire.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
563
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
564 #### Optional argument NOSUB, if non-nil, suppresses some of the usual
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
565 property substitutions. DON'T USE THIS in production code, it is intended
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
566 for exploring behavior of fontconfig and will be removed when this code is
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
567 stable.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
568
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
569 #### DEVICE is unused, ignored, and may be removed if it's not needed to
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
570 match other font-listing APIs. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
571 (UNUSED (device), pattern, trim, nosub))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
572 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
573 CHECK_FCPATTERN (pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
574
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
575 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
576 FcConfig *fcc = FcConfigGetCurrent();
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
577 FcFontSet *fontset;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
578 FcPattern *p = XFCPATTERN_PTR (pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
579 FcResult fcresult;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
580
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
581 if (NILP(nosub)) /* #### temporary debug hack */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
582 FcDefaultSubstitute (p);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
583 FcConfigSubstitute (fcc, p, FcMatchPattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
584 fontset = FcFontSort (fcc, p, !NILP(trim), NULL, &fcresult);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
585
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
586 return fontset_to_list (fontset);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
587 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
588 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
589
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
590 DEFUN("xlfd-font-name-p", Fxlfd_font_name_p, 1, 1, 0, /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
591 Check whether the string FONTNAME is a XLFD font name. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
592 (fontname))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
593 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
594 CHECK_STRING(fontname);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
595 /* #### should bind `case-fold-search' here? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
596 return Fstring_match(Vxlfd_font_name_regexp, fontname, Qnil, Qnil);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
597 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
598
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
599 /* FcPatternPrint: there is no point in having wrappers fc-pattern-print,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
600 Ffc_pattern_print since this function prints to stdout. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
601
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
602 /* Initialization of font-mgr */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
603
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
604 #define XE_XLFD_SEPARATOR "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
605 /* XLFD specifies ISO 8859-1 encoding, but we can't handle non-ASCII
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
606 in Mule when this function is called. So use HPC. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
607 #if 0
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
608 #define XE_XLFD_PREFIX "\\(\\+[\040-\176\240-\377]*\\)?-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
609 #define XE_XLFD_OPT_TEXT "\\([\040-\044\046-\176\240-\377]*\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
610 #define XE_XLFD_TEXT "\\([\040-\044\046-\176\240-\377]+\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
611 #else
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
612 #define XE_XLFD_PREFIX "\\(\\+[\040-\176]*\\)?-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
613 #define XE_XLFD_OPT_TEXT "\\([^-]*\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
614 #define XE_XLFD_TEXT "\\([^-]+\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
615 #endif
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
616
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
617 #define XE_XLFD_SLANT "\\([0-9ior?*][iot]?\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
618 #define XE_XLFD_SPACING "\\([cmp?*]\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
619 /* Hyphen as minus conflicts with use as separator. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
620 #define XE_XLFD_OPT_NEGATE "~?"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
621 #define XE_XLFD_NUMBER "\\([0-9?*]+\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
622 #define XE_XLFD_PSIZE "\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
623
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
624 /* Call this only from the init code
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
625 #### This is really horrible, let's get rid of it, please. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
626 static Lisp_Object
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
627 make_xlfd_font_regexp (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
628 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
629 struct gcpro gcpro1;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
630 unsigned i;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
631 Lisp_Object reg = Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
632 const Extbyte *re[] = /* #### This could just be catenated by
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
633 cpp and passed to build_ext_string. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
634 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
635 /* Regular expression matching XLFDs as defined by XLFD v. 1.5.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
636 Matches must be case-insensitive.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
637 PSIZE is a pixel or point size, which may be a "matrix". The
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
638 syntax of a matrix is not checked, just some lexical properties.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
639 AFAICT none of the TEXT fields except adstyle is optional.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
640
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
641 NB. It should not be a problem if this matches "too much", since
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
642 an "old" server will simply not be able to find a matching font. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
643 "\\`",
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
644 XE_XLFD_PREFIX, /* prefix */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
645 XE_XLFD_TEXT, /* foundry */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
646 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
647 XE_XLFD_TEXT, /* family */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
648 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
649 XE_XLFD_TEXT, /* weight */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
650 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
651 XE_XLFD_SLANT, /* slant */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
652 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
653 XE_XLFD_TEXT, /* swidth */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
654 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
655 XE_XLFD_OPT_TEXT, /* adstyle */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
656 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
657 XE_XLFD_PSIZE, /* pixelsize */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
658 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
659 XE_XLFD_PSIZE, /* pointsize */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
660 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
661 XE_XLFD_NUMBER, /* resx */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
662 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
663 XE_XLFD_NUMBER, /* resy */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
664 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
665 XE_XLFD_SPACING, /* spacing */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
666 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
667 XE_XLFD_OPT_NEGATE, /* avgwidth */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
668 XE_XLFD_NUMBER,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
669 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
670 XE_XLFD_TEXT, /* registry */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
671 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
672 XE_XLFD_TEXT, /* encoding */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
673 "\\'"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
674 };
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
675
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
676 GCPRO1 (reg);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
677 for (i = 0; i < sizeof(re)/sizeof(Extbyte *); i++)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
678 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
679 /* #### Currently this is Host Portable Coding, not ISO 8859-1. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
680 reg = concat2(reg, build_ext_string (re[i], Qx_font_name_encoding));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
681 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
682
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
683 RETURN_UNGCPRO (reg);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
684 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
685 #undef XE_XLFD_SEPARATOR
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
686 #undef XE_XLFD_PREFIX
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
687 #undef XE_XLFD_OPT_TEXT
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
688 #undef XE_XLFD_TEXT
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
689 #undef XE_XLFD_OPT_SLANT
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
690 #undef XE_XLFD_OPT_SPACING
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
691 #undef XE_XLFD_OPT_NEGATE
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
692 #undef XE_XLFD_NUMBER
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
693 #undef XE_XLFD_PSIZE
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
694
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
695 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
696 ? ((unsigned long) (x)) : ((unsigned long) (y)))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
697
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
698 static void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
699 string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
700 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
701 EXTERNAL_LIST_LOOP_2 (elt, list)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
702 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
703 FcChar8 *s;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
704
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
705 CHECK_STRING (elt);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
706 s = fc_intern (elt);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
707 FcObjectSetAdd (os, s);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
708 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
709 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
710
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
711 void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
712 syms_of_font_mgr (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
713 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
714 INIT_LRECORD_IMPLEMENTATION(fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
715
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
716 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
717
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
718 DEFSYMBOL(Qfc_result_type_mismatch);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
719 DEFSYMBOL(Qfc_result_no_match);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
720 DEFSYMBOL(Qfc_result_no_id);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
721 DEFSYMBOL(Qfc_internal_error);
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
722 DEFSYMBOL(Qfont_mgr);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
723
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
724 DEFSUBR(Ffc_pattern_p);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
725 DEFSUBR(Ffc_pattern_create);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
726 DEFSUBR(Ffc_name_parse);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
727 DEFSUBR(Ffc_name_unparse);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
728 DEFSUBR(Ffc_pattern_duplicate);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
729 DEFSUBR(Ffc_pattern_add);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
730 DEFSUBR(Ffc_pattern_del);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
731 DEFSUBR(Ffc_pattern_get);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
732 DEFSUBR(Ffc_list_fonts_pattern_objects);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
733 DEFSUBR(Ffc_font_sort);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
734 DEFSUBR(Ffc_font_match);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
735 DEFSUBR(Fxlfd_font_name_p);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
736 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
737
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
738 void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
739 vars_of_font_mgr (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
740 {
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
741 /* #### The next two functions belong somewhere else. */
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
742
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
743 /* #### I know, but the right fix is use the generic debug facility. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
744 DEFVAR_INT ("xft-debug-level", &debug_xft /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
745 Level of debugging messages to issue to stderr for Xft.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
746 A nonnegative integer. Set to 0 to suppress all warnings.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
747 Default is 1 to ensure a minimum of debugging output at initialization.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
748 Higher levels give even more information.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
749 */ );
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
750 debug_xft = 1;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
751
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
752 DEFVAR_LISP("xft-version", &Vxft_version /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
753 The major version number of the Xft library being used.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
754 */ );
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
755 Vxft_version = make_int(XFT_VERSION);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
756
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
757 Fprovide (intern ("font-mgr"));
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
758 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
759
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
760 void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
761 complex_vars_of_font_mgr (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
762 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
763 DEFVAR_LISP("xft-xlfd-font-regexp", &Vxlfd_font_name_regexp /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
764 The regular expression used to match XLFD font names. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
765 );
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
766 Vxlfd_font_name_regexp = make_xlfd_font_regexp();
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
767 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
768
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
769 void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
770 reinit_vars_of_font_mgr (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
771 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
772 int i, size = (int) countof (fc_standard_properties);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
773
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
774 FcInit ();
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
775
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
776 fc_property_name_hash_table = make_string_hash_table (size);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
777 for (i = 0; i < size; ++i)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
778 puthash (fc_standard_properties[i], NULL, fc_property_name_hash_table);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
779 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
780