annotate src/font-mgr.c @ 5090:0ca81354c4c7

Further frame-geometry cleanups -------------------- ChangeLog entries follow: -------------------- man/ChangeLog addition: 2010-03-03 Ben Wing <ben@xemacs.org> * internals/internals.texi (Intro to Window and Frame Geometry): * internals/internals.texi (The Paned Area): * internals/internals.texi (The Displayable Area): Update to make note of e.g. the fact that the bottom gutter is actually above the minibuffer. src/ChangeLog addition: 2010-03-03 Ben Wing <ben@xemacs.org> * emacs.c: * emacs.c (assert_equal_failed): * lisp.h: * lisp.h (assert_equal): New fun assert_equal, asserting that two values == each other, and printing out both values upon failure. * frame-gtk.c (gtk_initialize_frame_size): * frame-impl.h: * frame-impl.h (FRAME_TOP_INTERNAL_BORDER_START): * frame-impl.h (FRAME_BOTTOM_INTERNAL_BORDER_START): * frame-impl.h (FRAME_LEFT_INTERNAL_BORDER_START): * frame-impl.h (FRAME_PANED_TOP_EDGE): * frame-impl.h (FRAME_NONPANED_SIZE): * frame-x.c (x_initialize_frame_size): * frame.c: * gutter.c (get_gutter_coords): * gutter.c (calculate_gutter_size): * gutter.h: * gutter.h (WINDOW_REAL_TOP_GUTTER_BOUNDS): * gutter.h (FRAME_TOP_GUTTER_BOUNDS): * input-method-xlib.c: * input-method-xlib.c (XIM_SetGeometry): * redisplay-output.c (clear_left_border): * redisplay-output.c (clear_right_border): * redisplay-output.c (redisplay_output_pixmap): * redisplay-output.c (redisplay_clear_region): * redisplay-output.c (redisplay_clear_top_of_window): * redisplay-output.c (redisplay_clear_to_window_end): * redisplay-xlike-inc.c (XLIKE_clear_frame): * redisplay.c: * redisplay.c (UPDATE_CACHE_RETURN): * redisplay.c (pixel_to_glyph_translation): * toolbar.c (update_frame_toolbars_geometry): * window.c (Fwindow_pixel_edges): Get rid of some redundant macros. Consistently use the FRAME_TOP_*_START, FRAME_RIGHT_*_END, etc. format. Rename FRAME_*_BORDER_* to FRAME_*_INTERNAL_BORDER_*. Comment out FRAME_BOTTOM_* for gutters and the paned area due to the uncertainty over where the paned area actually begins. (Eventually we should probably move the gutters outside the minibuffer so that the paned area is contiguous.) Use FRAME_PANED_* more often in the code to make things clearer. Update the diagram to show that the bottom gutter is inside the minibuffer (!) and that there are "junk boxes" when you have left and/or right gutters (dead boxes that are mistakenly left uncleared, unlike the corresponding scrollbar dead boxes). Update the text appropriately to cover the bottom gutter position, etc. Rewrite gutter-geometry code to use the FRAME_*_GUTTER_* in place of equivalent expressions referencing other frame elements, to make the code more portable in case we move around the gutter location. Cleanup FRAME_*_GUTTER_BOUNDS() in gutter.h. Add some #### GEOM! comments where I think code is incorrect -- typically, it wasn't fixed up properly when the gutter was added. Some cosmetic changes.
author Ben Wing <ben@xemacs.org>
date Wed, 03 Mar 2010 05:07:47 -0600
parents 3c3c1d139863
children b5df3737028a 8b2f75cecb89
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
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
5 Copyright (C) 2004-2009 Free Software Foundation, Inc.
3354
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
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
11 Updated: 18 November 2009 by Stephen J. Turnbull
3354
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
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
49 #include "sysfile.h"
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
50
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
51 /* #### TO DO ####
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
52 . 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
53 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
54 . 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
55 . 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
56 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
57 use the Fc* namespace.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
58 . Mule-ize this file.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
59 . 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
60 allow fallback to X.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
61 . 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
62 really need efficiency, can reimplement in C later.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
63 . 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
64 . Implement FcMatrix (Lisp vector).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
65 . Implement FcCharSets (Lisp chartable? For implementation hints, see
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
66 FcCharSetFirstPage and FcCharSetNextPage).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
67 . Implement FcConfigs.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
68 DONE
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
69 . Fontconfig fontnames are encoded in UTF-8.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
70 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
71
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
72 Lisp_Object Qfont_mgr;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
73 Lisp_Object Qfc_patternp;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
74 /* Lisp_Object Qfc_result_match; */ /* FcResultMatch */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
75 Lisp_Object Qfc_result_type_mismatch; /* FcResultTypeMismatch */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
76 Lisp_Object Qfc_result_no_match; /* FcResultNoMatch */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
77 Lisp_Object Qfc_result_no_id; /* FcResultNoId */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
78 Lisp_Object Qfc_internal_error;
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
79 Lisp_Object Qfc_match_pattern;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
80 Lisp_Object Qfc_match_font;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
81 Lisp_Object Vxlfd_font_name_regexp; /* #### Really needed? */
3935
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
82 Fixnum xft_version;
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
83 Fixnum fc_version;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
84 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
85 Setting it to 2 or 3 enables even more. */
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
86 #ifdef FONTCONFIG_EXPOSE_CONFIG
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
87 Lisp_Object Qfc_configp;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
88 static Lisp_Object Vfc_config_weak_list;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
89 #endif
3354
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 /****************************************************************
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
92 * FcPattern objects *
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
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
95 static void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
96 finalize_fc_pattern (void *header, int UNUSED (for_disksave))
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 struct fc_pattern *p = (struct fc_pattern *) header;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
99 if (p->fcpatPtr)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
100 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
101 FcPatternDestroy (p->fcpatPtr);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
102 p->fcpatPtr = 0;
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 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
105
3906
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
106 static void
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
107 print_fc_pattern (Lisp_Object obj, Lisp_Object printcharfun,
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
108 int UNUSED(escapeflag))
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
109 {
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
110 struct fc_pattern *c = XFCPATTERN (obj);
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
111 if (print_readably)
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
112 printing_unreadable_object ("#<fc-pattern 0x%x>", c->header.uid);
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
113 write_fmt_string (printcharfun, "#<fc-pattern 0x%x>", c->header.uid);
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
114 }
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
115
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
116 /* #### We really need an equal method and a hash method (required if you
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
117 have an equal method). For the equal method, we can probably use one
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
118 or both of
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
119
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
120 -- Function: FcBool FcPatternEqual (const FcPattern *pa, const
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
121 FcPattern *pb);
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
122 Returns whether PA and PB are exactly alike.
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
123
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
124 -- Function: FcBool FcPatternEqualSubset (const FcPattern *pa, const
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
125 FcPattern *pb, const FcObjectSet *os)
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
126 Returns whether PA and PB have exactly the same values for all of
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
127 the objects in OS.
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
128
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
129 For the hash, we'll have to extract some subset of attributes.
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
130
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
131 #### Crap. It's altogether unobvious what we need. x_color_instance
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
132 does have a hash method, but fonts are apparently special. I get the
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
133 feeling that for this to work properly we're going to need to switch
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
134 to fontconfig-based font specifications (although we can allow the
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
135 platform syntaxes, the underlying specification object will need to
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
136 conform to the fontconfig API, or more precisely the font-mgr API).
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
137
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
138 I think the whole `font-truename' interface needs to be dropped. */
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
139
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
140 static const struct memory_description fcpattern_description [] = {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
141 /* #### nothing here, is this right?? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
142 { XD_END }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
143 };
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
144
3906
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
145 DEFINE_LRECORD_IMPLEMENTATION("fc-pattern", fc_pattern, 0,
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
146 0, print_fc_pattern, finalize_fc_pattern,
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
147 0, 0, fcpattern_description,
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
148 struct fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
149
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
150 /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
151 * Helper Functions
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
152 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
153 static Lisp_Object make_xlfd_font_regexp (void);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
154 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
155
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
156 /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
157 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
158 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
159 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
160 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
161 is a Lisp string.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
162 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
163 #define extract_fcapi_string(str) \
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
164 (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
165
3906
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
166 #define build_fcapi_string(str) \
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
167 (build_extstring ((Extbyte *) (str), Qfc_font_name_encoding))
3906
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
168
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
169 /* #### This homebrew lashup should be replaced with FcConstants.
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
170
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
171 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
172 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
173 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
174 (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
175
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
176 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
177 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
178 _is_ a long-running process. So we hash them.
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 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
181 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
182 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
183
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
184 This array should be FcChar8**, but GCC 4.x bitches about signedness. */
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4860
diff changeset
185 static const Extbyte *fc_standard_properties[] = {
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
186 /* treated specially, ordered first */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
187 "family", "size",
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
188 /* remaining are alphabetized by group */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
189 /* standard properties in fontconfig and Xft v.2 */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
190 "antialias", "aspect", "autohint", "charset", "dpi", "file",
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
191 "foundry", "ftface", "globaladvance", "hinting", "index", "lang",
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
192 "minspace", "outline", "pixelsize", "rasterizer", "rgba", "scalable",
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
193 "scale", "slant", "spacing", "style", "verticallayout", "weight",
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
194 /* common in modern fonts */
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
195 "fontformat", "fontversion",
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
196 /* obsolete after Xft v. 1 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
197 "charwidth", "charheight", "core", "encoding", "render"
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 static struct hash_table *fc_property_name_hash_table;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
201
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
202 /* #### 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
203 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
204
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
205 static const Extbyte *
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
206 fc_intern (Lisp_Object property)
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 const void *dummy;
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
209 const Extbyte *prop = extract_fcapi_string (property);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
210 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
211
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
212 /* extract_fcapi_string returns something alloca'd
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
213 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
214 if (val)
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
215 prop = (const Extbyte *) val;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
216 else
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
217 {
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
218 prop = (const Extbyte *) FcStrCopy ((FcChar8 *) prop);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
219 puthash (prop, NULL, fc_property_name_hash_table);
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 return prop;
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
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
224 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
225 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
226 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
227 (object))
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 return FCPATTERNP(object) ? Qt : Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
230 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
231
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
232 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
233 Return a new, empty fc-pattern object.
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 ())
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
236 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
237 fc_pattern *fcpat =
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
238 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
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
240 fcpat->fcpatPtr = FcPatternCreate();
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
241 return wrap_fcpattern(fcpat);
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
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
244 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
245 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
246 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
247 (name))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
248 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
249 struct fc_pattern *fcpat =
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
250 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
251
3906
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
252 CHECK_STRING(name);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
253
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
254 fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name));
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
255 return wrap_fcpattern(fcpat);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
256 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
257
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
258 /* #### 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
259 We provide both. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
260 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
261 Unparse an fc pattern object to a string.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
262 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
263 (pattern))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
264 {
4799
ca99a807b025 Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents: 4758
diff changeset
265 FcChar8 *name;
ca99a807b025 Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents: 4758
diff changeset
266 Lisp_Object result;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
267 CHECK_FCPATTERN(pattern);
4799
ca99a807b025 Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents: 4758
diff changeset
268 name = FcNameUnparse (XFCPATTERN_PTR (pattern));
ca99a807b025 Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents: 4758
diff changeset
269 result = build_fcapi_string (name);
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
270 xfree (name);
4799
ca99a807b025 Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents: 4758
diff changeset
271 return result;
3354
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
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
274 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
275 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
276 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
277 (pattern))
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 struct fc_pattern *copy = NULL;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
280 CHECK_FCPATTERN(pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
281
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
282 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
283 copy->fcpatPtr = FcPatternDuplicate(XFCPATTERN_PTR(pattern));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
284 return wrap_fcpattern(copy);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
285 }
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 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
288 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
289 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
290
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
291 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
292 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
293 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
294 (pattern, property, value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
295 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
296 Bool res = 0;
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
297 const Extbyte *obj;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
298 FcPattern *fcpat;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
299
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
300 CHECK_FCPATTERN(pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
301 CHECK_STRING(property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
302
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
303 obj = fc_intern (property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
304 fcpat = XFCPATTERN_PTR (pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
305
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
306 if (STRINGP(value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
307 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
308 FcChar8 *str = (FcChar8 *) extract_fcapi_string (value);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
309 res = FcPatternAddString (fcpat, obj, str);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
310 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
311 else if (INTP(value))
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 res = FcPatternAddInteger (fcpat, obj, XINT(value));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
314 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
315 else if (FLOATP(value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
316 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
317 res = FcPatternAddDouble (fcpat, obj, (double) XFLOAT_DATA(value));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
318 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
319 else if (SYMBOLP(value))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
320 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
321 res = FcPatternAddBool (fcpat, obj, !NILP(value));
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
322 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
323 /* else ... maybe we should wta here? */
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 return res ? Qt : Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
326 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
327
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
328 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
329 Remove attribute PROPERTY from fc pattern object OBJECT.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
330 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
331 (pattern, property))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
332 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
333 Bool res;
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 CHECK_FCPATTERN(pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
336 CHECK_STRING(property);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
337
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
338 res = FcPatternDel(XFCPATTERN_PTR(pattern), extract_fcapi_string (property));
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
339 return res ? Qt : Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
340 }
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 /* Generic interface to FcPatternGet()
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
343 * Don't support the losing symbol-for-property interface.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
344 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
345 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
346 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
347
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
348 PATTERN is an Xft (fontconfig) pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
349 PROPERTY is a string naming an fontconfig font property.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
350 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
351 stored in PATTERN, defaulting to 0 (the first value).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
352 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
353 '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
354 ('float is an alias for 'double).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
355
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
356 The Lisp types returned will conform to TYPE:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
357 string string
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
358 boolean `t' or `nil'
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
359 integer integer
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
360 double (float) float
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
361 matrix not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
362 charset not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
363 void not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
364
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
365 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
366 the desired value is not available. These are
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
367
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
368 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
369 fc-result-no-match there is no such attribute
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
370 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
371
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
372 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
373 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
374 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
375 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
376 correct 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 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
379 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
380 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
381 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
382 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
383 `defsubst' to define convenience functions for non-standard properties.
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 family String Font family name
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
386 style String Font style. Overrides weight and slant
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
387 slant Int Italic, oblique or roman
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
388 weight Int Light, medium, demibold, bold or black
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
389 size Double Point size
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
390 aspect Double Stretches glyphs horizontally before hinting
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
391 pixelsize Double Pixel size
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
392 spacing Int Proportional, monospace or charcell
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
393 foundry String Font foundry name
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
394 antialias Bool Whether glyphs can be antialiased
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
395 hinting Bool Whether the rasterizer should use hinting
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
396 verticallayout Bool Use vertical layout
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
397 autohint Bool Use autohinter instead of normal hinter
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
398 globaladvance Bool Use font global advance data
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
399 file String The filename holding the font
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
400 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
401 ftface FT_Face Use the specified FreeType face object
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
402 rasterizer String Which rasterizer is in use
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
403 outline Bool Whether the glyphs are outlines
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
404 scalable Bool Whether glyphs can be scaled
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
405 scale Double Scale factor for point->pixel conversions
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
406 dpi Double Target dots per inch
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
407 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
408 minspace Bool Eliminate leading from line spacing
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
409 charset CharSet Unicode chars encoded by the font
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
410 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
411
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
412 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
413 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
414 property returned has type FT_Face, FcCharSet, or FcMatrix,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
415 `fc-result-type-mismatch' is returned.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
416
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
417 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
418 Xft v.2: encoding, charwidth, charheight, core, and render. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
419 (pattern, property, id, type))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
420 {
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
421 Extbyte *fc_property;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
422 FcResult fc_result;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
423 FcValue fc_value;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
424
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
425 /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
426 process arguments
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
427 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
428 CHECK_FCPATTERN (pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
429
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
430 #if 0
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
431 /* Don't support the losing symbol-for-property interface. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
432 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
433 #endif
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
434 if (STRINGP (property))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
435 {
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
436 fc_property = extract_fcapi_string (property);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
437 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
438 else
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 /* if we allow symbols, this would need to be
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
441 list3 (Qlambda, list1 (Qobject),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
442 list3 (Qor, list2 (Qstringp, Qobject),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
443 list2 (Qsymbolp, Qobject)))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
444 or something like that? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
445 dead_wrong_type_argument (Qstringp, property);
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
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
448 if (!NILP (id)) CHECK_NATNUM (id);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
449 if (!NILP (type)) CHECK_SYMBOL (type);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
450
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
451 /* get property */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
452 fc_result = FcPatternGet (XFCPATTERN_PTR (pattern),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
453 fc_property,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
454 NILP (id) ? 0 : XINT(id),
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
455 &fc_value);
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 switch (fc_result)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
458 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
459 case FcResultMatch:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
460 /* wrap it and return */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
461 switch (fc_value.type)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
462 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
463 case FcTypeInteger:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
464 return ((!NILP (type) && !EQ (type, Qinteger))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
465 ? 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
466 case FcTypeDouble:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
467 return ((!NILP (type) && !EQ (type, intern ("double"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
468 && !EQ (type, Qfloat))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
469 ? 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
470 case FcTypeString:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
471 return ((!NILP (type) && !EQ (type, Qstring))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
472 ? Qfc_result_type_mismatch
3906
605c915d2b9d [xemacs-hg @ 2007-04-14 16:10:53 by stephent]
stephent
parents: 3469
diff changeset
473 : build_fcapi_string (fc_value.u.s));
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
474 case FcTypeBool:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
475 return ((!NILP (type) && !EQ (type, Qboolean))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
476 ? 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
477 case FcTypeMatrix:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
478 return Qfc_result_type_mismatch;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
479 /* #### unimplemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
480 return ((!NILP (type) && !EQ (type, intern ("matrix")))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
481 ? 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
482 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
483 case FcTypeCharSet:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
484 return Qfc_result_type_mismatch;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
485 /* #### unimplemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
486 return ((!NILP (type) && !EQ (type, intern ("charset")))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
487 ? 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
488 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
489 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
490 case FcResultTypeMismatch:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
491 return Qfc_result_type_mismatch;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
492 case FcResultNoMatch:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
493 return Qfc_result_no_match;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
494 case FcResultNoId:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
495 return Qfc_result_no_id;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
496 default:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
497 return Qfc_internal_error;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
498 }
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
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
501 /* FcConfig handling functions. */
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
502
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
503 /* We obviously need to be careful about garbage collecting the current
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
504 FcConfig. I infer from the documentation of FcConfigDestroy that that
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
505 is the only reference maintained by fontconfig.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
506 So we keep track of our own references on a weak list, and only cons a
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
507 new object if we don't already have a reference to it there. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
508
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
509 enum DestroyFontsetP { DestroyNo = 0, DestroyYes = 1 };
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
510
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
511 static Lisp_Object
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
512 fc_config_create_using (FcConfig * (*create_function) ())
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
513 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
514 FcConfig *fc = (*create_function) ();
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
515 Lisp_Object configs = XWEAK_LIST_LIST (Vfc_config_weak_list);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
516
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
517 /* Linear search: fc_configs are not going to multiply like conses. */
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
518 {
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
519 LIST_LOOP_2 (cfg, configs)
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
520 if (fc == XFCCONFIG_PTR (cfg))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
521 return cfg;
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
522 }
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
523
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
524 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
525 fc_config *fccfg =
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
526 ALLOC_LCRECORD_TYPE (struct fc_config, &lrecord_fc_config);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
527 fccfg->fccfgPtr = fc;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
528 configs = Fcons (wrap_fcconfig (fccfg), configs);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
529 XWEAK_LIST_LIST (Vfc_config_weak_list) = configs;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
530 return wrap_fcconfig (fccfg);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
531 }
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
532 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
533
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
534 static Lisp_Object
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
535 fc_strlist_to_lisp_using (FcStrList * (*getter) (FcConfig *),
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
536 Lisp_Object config)
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
537 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
538 FcChar8 *thing;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
539 Lisp_Object value = Qnil;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
540 FcStrList *thing_list;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
541
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
542 CHECK_FCCONFIG (config);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
543 thing_list = (*getter) (XFCCONFIG_PTR(config));
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
544 /* Yes, we need to do this check -- sheesh, Keith! */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
545 if (!thing_list)
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
546 return Qnil;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
547 while ((thing = FcStrListNext (thing_list)))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
548 value = Fcons (build_fcapi_string (thing), value);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
549 FcStrListDone (thing_list);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
550 return value;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
551 }
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
552
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
553 static Lisp_Object
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
554 fontset_to_list (FcFontSet *fontset, enum DestroyFontsetP destroyp)
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
555 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
556 int idx;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
557 Lisp_Object fontlist = Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
558 fc_pattern *fcpat;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
559
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
560 /* #### improve this error message */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
561 if (!fontset)
4860
edc0cd26b4a8 fix more build problems
Ben Wing <ben@xemacs.org>
parents: 4849
diff changeset
562 invalid_state ("failed to create FcFontSet", Qunbound);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
563 for (idx = 0; idx < fontset->nfont; ++idx)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
564 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
565 fcpat =
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
566 ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
567 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
568 fontlist = Fcons (wrap_fcpattern(fcpat), fontlist);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
569 }
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
570 if (destroyp)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
571 FcFontSetDestroy (fontset);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
572 return fontlist;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
573 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
574
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
575 DEFUN("fc-config-p", Ffc_config_p, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
576 Returns t if OBJECT is of type fc-config, nil otherwise.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
577 */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
578 (object))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
579 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
580 return FCCONFIGP (object) ? Qt : Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
581 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
582
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
583 DEFUN("fc-config-create", Ffc_config_create, 0, 0, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
584 -- Function: FcConfig *FcConfigCreate (void)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
585 Creates an empty configuration. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
586 ())
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
587 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
588 return fc_config_create_using (&FcConfigCreate);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
589 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
590
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
591 #if 0
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
592 /* I'm sorry, but we just don't do this in Lisp, OK?
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
593 Don't even think about implementing this. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
594 DEFUN("fc-config-destroy", Ffc_config_destroy, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
595 -- Function: void FcConfigDestroy (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
596 Destroys a configuration and any data associated with it. Note
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
597 that calling this function with the return value from
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
598 FcConfigGetCurrent will place the library in an indeterminate
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
599 state. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
600 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
601 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
602 signal_error (Qunimplemented, "No user-servicable parts!",
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
603 intern ("fc-config-destroy"));
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
604 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
605 #endif
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
606
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
607 DEFUN("fc-config-up-to-date", Ffc_config_up_to_date, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
608 -- Function: FcBool FcConfigUptoDate (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
609 Checks all of the files related to 'config' and returns whether the
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
610 in-memory version is in sync with the disk version. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
611 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
612 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
613 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
614 return FcConfigUptoDate (XFCCONFIG_PTR (config)) == FcFalse ? Qnil : Qt;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
615 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
616
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
617 DEFUN("fc-config-build-fonts", Ffc_config_build_fonts, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
618 -- Function: FcBool FcConfigBuildFonts (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
619 Builds the set of available fonts for the given configuration.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
620 Note that any changes to the configuration after this call have
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
621 indeterminate effects. Returns FcFalse if this operation runs out
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
622 of memory.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
623 XEmacs: signal out-of-memory, or return nil on success. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
624 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
625 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
626 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
627 if (FcConfigBuildFonts (XFCCONFIG_PTR (config)) == FcFalse)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
628 out_of_memory ("FcConfigBuildFonts failed", config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
629 return Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
630 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
631
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
632 DEFUN("fc-config-get-config-dirs", Ffc_config_get_config_dirs, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
633 -- Function: FcStrList *FcConfigGetConfigDirs (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
634 Returns the list of font directories specified in the
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
635 configuration files for 'config'. Does not include any
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
636 subdirectories. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
637 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
638 {
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
639 return fc_strlist_to_lisp_using (&FcConfigGetConfigDirs, config);
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
640 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
641
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
642 DEFUN("fc-config-get-font-dirs", Ffc_config_get_font_dirs, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
643 -- Function: FcStrList *FcConfigGetFontDirs (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
644 Returns the list of font directories in 'config'. This includes the
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
645 configured font directories along with any directories below those
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
646 in the filesystem. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
647 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
648 {
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
649 return fc_strlist_to_lisp_using (&FcConfigGetFontDirs, config);
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
650 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
651
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
652 DEFUN("fc-config-get-config-files", Ffc_config_get_config_files, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
653 -- Function: FcStrList *FcConfigGetConfigFiles (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
654 Returns the list of known configuration files used to generate
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
655 'config'. Note that this will not include any configuration done
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
656 with FcConfigParse. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
657 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
658 {
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
659 return fc_strlist_to_lisp_using (&FcConfigGetConfigFiles, config);
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
660 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
661
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
662 DEFUN("fc-config-get-cache", Ffc_config_get_cache, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
663 -- Function: char *FcConfigGetCache (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
664 Returns the name of the file used to store per-user font
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
665 information. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
666 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
667 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
668 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
669 /* Surely FcConfigGetCache just casts an FcChar8* to char*. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
670 return build_fcapi_string ((FcChar8 *) FcConfigGetCache (XFCCONFIG_PTR (config)));
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
671 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
672
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
673 DEFUN("fc-config-get-fonts", Ffc_config_get_fonts, 2, 2, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
674 -- Function: FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
675 Returns one of the two sets of fonts from the configuration as
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
676 specified by 'set'.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
677 `FcSetName'
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
678 Specifies one of the two sets of fonts available in a
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
679 configuration; FcSetSystem for those fonts specified in the
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
680 configuration and FcSetApplication which holds fonts provided by
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
681 the application. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
682 (config, set))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
683 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
684 FcSetName name = FcSetSystem;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
685 FcFontSet *fs = NULL;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
686
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
687 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
688 CHECK_SYMBOL (set);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
689
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
690 if (EQ (set, intern ("fc-set-system")))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
691 name = FcSetSystem;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
692 else if (EQ (set, intern ("fc-set-application")))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
693 name = FcSetApplication;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
694 else
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
695 wtaerror ("must be in (fc-set-system fc-set-application)", set);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
696
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
697 fs = FcConfigGetFonts (XFCCONFIG_PTR (config), name);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
698 return fs ? fontset_to_list (fs, DestroyNo) : Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
699 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
700
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
701 DEFUN("fc-config-set-current", Ffc_config_set_current, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
702 -- Function: FcBool FcConfigSetCurrent (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
703 Sets the current default configuration to 'config'. Implicitly
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
704 calls FcConfigBuildFonts if necessary, returning FcFalse if that
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
705 call fails.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
706 XEmacs: signals out-of-memory if FcConfigBuildFonts fails, or args-out-of-range
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
707 if the resulting FcConfig has no fonts (which would crash XEmacs if installed).
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
708 */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
709 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
710 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
711 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
712 /* *sigh* "Success" DOES NOT mean you have any fonts available. It is
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
713 easy to crash fontconfig, and XEmacs with it. Without the following
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
714 check, this will do it:
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
715 (progn
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
716 (fc-config-set-current (fc-config-create))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
717 (set-face-font 'default "serif-12"))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
718 */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
719
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
720 if (FcConfigBuildFonts (XFCCONFIG_PTR (config)) == FcFalse)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
721 out_of_memory ("FcConfigBuildFonts failed", config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
722 /* #### We'd like to avoid this consing, and FcConfigGetFonts sometimes
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
723 returns NULL, but it doesn't always. This will do for now .... */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
724 if (NILP (Ffc_config_get_fonts (config, intern ("fc-set-system")))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
725 && NILP (Ffc_config_get_fonts (config, intern ("fc-set-application"))))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
726 signal_error (intern ("args-out-of-range"), "no fonts found", config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
727 /* Should never happen, but I don't trust Keith anymore .... */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
728 if (FcConfigSetCurrent (XFCCONFIG_PTR (config)) == FcFalse)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
729 out_of_memory ("FcConfigBuildFonts failed in set", config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
730 return Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
731 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
732
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
733 DEFUN("fc-config-get-blanks", Ffc_config_get_blanks, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
734 -- Function: FcBlanks *FcConfigGetBlanks (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
735 Returns the FcBlanks object associated with the given
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
736 configuration, if no blanks were present in the configuration,
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
737 this function will return 0.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
738 XEmacs: should convert to a chartable.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
739 #### Unimplemented. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
740 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
741 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
742 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
743 signal_error (Qunimplemented, "no method to convert FcBlanks object",
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
744 intern ("fc-config-get-blanks"));
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
745 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
746
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
747 DEFUN("fc-config-get-rescan-interval", Ffc_config_get_rescan_interval, 1, 1, 0, /*
4328
dfd878799ef0 Autoconfiscate the recent fontconfig spelling change.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3935
diff changeset
748 -- Function: int FcConfigGetRescanInterval (FcConfig *config)
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
749 Returns the interval between automatic checks of the configuration
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
750 (in seconds) specified in 'config'. The configuration is checked
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
751 during a call to FcFontList when this interval has passed since
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
752 the last check. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
753 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
754 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
755 CHECK_FCCONFIG (config);
4328
dfd878799ef0 Autoconfiscate the recent fontconfig spelling change.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3935
diff changeset
756 return make_int (FcConfigGetRescanInterval (XFCCONFIG_PTR (config)));
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
757 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
758
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
759 DEFUN("fc-config-set-rescan-interval", Ffc_config_set_rescan_interval, 2, 2, 0, /*
4328
dfd878799ef0 Autoconfiscate the recent fontconfig spelling change.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3935
diff changeset
760 -- Function: FcBool FcConfigSetRescanInterval (FcConfig *config, int
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
761 rescanInterval)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
762 Sets the rescan interval; returns FcFalse if an error occurred.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
763 XEmacs: signal such error, or return nil on success. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
764 (config, rescan_interval))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
765 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
766 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
767 CHECK_INT (rescan_interval);
4328
dfd878799ef0 Autoconfiscate the recent fontconfig spelling change.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3935
diff changeset
768 if (FcConfigSetRescanInterval (XFCCONFIG_PTR (config),
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
769 XINT (rescan_interval)) == FcFalse)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
770 signal_error (Qio_error, "FcConfigSetRescanInverval barfed",
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
771 intern ("fc-config-set-rescan-interval"));
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
772 return Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
773 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
774
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
775 /* #### This might usefully be made interactive. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
776 DEFUN("fc-config-app-font-add-file", Ffc_config_app_font_add_file, 2, 2, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
777 -- Function: FcBool FcConfigAppFontAddFile (FcConfig *config, const
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
778 char *file)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
779 Adds an application-specific font to the configuration. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
780 (config, file))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
781 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
782 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
783 CHECK_STRING (file);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
784 if (FcConfigAppFontAddFile
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
785 (XFCCONFIG_PTR (config),
4834
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
786 /* #### FIXME! is Qfile_name right? */
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
787 (FcChar8 *) LISP_STRING_TO_EXTERNAL (file, Qfile_name)) == FcFalse)
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
788 return Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
789 else
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
790 return Qt;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
791 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
792
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
793 /* #### This might usefully be made interactive. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
794 DEFUN("fc-config-app-font-add-dir", Ffc_config_app_font_add_dir, 2, 2, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
795 -- Function: FcBool FcConfigAppFontAddDir (FcConfig *config, const
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
796 char *dir)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
797 Scans the specified directory for fonts, adding each one found to
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
798 the application-specific set of fonts. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
799 (config, dir))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
800 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
801 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
802 CHECK_STRING (dir);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
803 if (FcConfigAppFontAddDir
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
804 (XFCCONFIG_PTR (config),
4834
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
805 /* #### FIXME! is Qfile_name right? */
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
806 (FcChar8 *) LISP_STRING_TO_EXTERNAL (dir, Qfile_name)) == FcFalse)
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
807 return Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
808 else
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
809 return Qt;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
810 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
811
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
812 /* #### This might usefully be made interactive. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
813 DEFUN("fc-config-app-font-clear", Ffc_config_app_font_clear, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
814 -- Function: void FcConfigAppFontClear (FcConfig *config)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
815 Clears the set of application-specific fonts. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
816 (config))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
817 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
818 CHECK_FCCONFIG (config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
819 FcConfigAppFontClear (XFCCONFIG_PTR (config));
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
820 return Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
821 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
822
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
823 /* These functions provide some control over how the default
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
824 configuration of the library is initialized. (This configuration is
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
825 normally implicitly initialized.) */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
826
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
827 DEFUN("fc-config-filename", Ffc_config_filename, 1, 1, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
828 -- Function: char *FcConfigFilename (const char *name)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
829 Given the specified external entity name, return the associated
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
830 filename. This provides applications a way to convert various
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
831 configuration file references into filename form.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
832
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
833 A null or empty 'name' indicates that the default configuration
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
834 file should be used; which file this references can be overridden
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
835 with the FC_CONFIG_FILE environment variable. Next, if the name
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
836 starts with '~', it refers to a file in the current users home
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
837 directory. Otherwise if the name doesn't start with '/', it
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
838 refers to a file in the default configuration directory; the
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
839 built-in default directory can be overridden with the
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
840 FC_CONFIG_DIR environment variable. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
841 (name))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
842 {
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4860
diff changeset
843 const Ascbyte *fcname = "";
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
844
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
845 if (!NILP (name))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
846 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
847 CHECK_STRING (name);
4834
b3ea9c582280 Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents: 4809
diff changeset
848 /* #### FIXME! is Qfile_name right? */
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4953
diff changeset
849 LISP_PATHNAME_CONVERT_OUT (name, fcname);
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
850 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
851 return (build_fcapi_string (FcConfigFilename ((FcChar8 *) fcname)));
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
852 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
853
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
854 DEFUN("fc-init-load-config", Ffc_init_load_config, 0, 0, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
855 -- Function: FcConfig *FcInitLoadConfig (void)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
856 Loads the default configuration file and returns the resulting
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
857 configuration. Does not load any font information. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
858 ())
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
859 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
860 return fc_config_create_using (&FcInitLoadConfig);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
861 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
862
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
863 DEFUN("fc-init-load-config-and-fonts", Ffc_init_load_config_and_fonts, 0, 0, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
864 -- Function: FcConfig *FcInitLoadConfigAndFonts (void)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
865 Loads the default configuration file and builds information about
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
866 the available fonts. Returns the resulting configuration. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
867 ())
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
868 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
869 return fc_config_create_using (&FcInitLoadConfigAndFonts);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
870 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
871
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
872 DEFUN("fc-config-get-current", Ffc_config_get_current, 0, 0, 0, /*
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
873 -- Function: FcConfig *FcConfigGetCurrent (void)
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
874 Returns the current default configuration. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
875 ())
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
876 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
877 return fc_config_create_using (&FcConfigGetCurrent);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
878 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
879
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
880 /* Pattern manipulation functions. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
881
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
882 DEFUN("fc-default-substitute", Ffc_default_substitute, 1, 1, 0, /*
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
883 Adds defaults for certain attributes if not specified in PATTERN.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
884 FcPattern PATTERN is modified in-place, and nil is returned.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
885 * Patterns without a specified style or weight are set to Medium
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
886 * Patterns without a specified style or slant are set to Roman
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
887 * Patterns without a specified pixel size are given one computed from any
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
888 specified point size (default 12), dpi (default 75) and scale (default 1). */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
889 (pattern))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
890 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
891 CHECK_FCPATTERN (pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
892 FcDefaultSubstitute (XFCPATTERN_PTR (pattern));
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
893 return Qnil;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
894 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
895
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
896 /* -- Function: FcBool FcConfigSubstituteWithPat (FcConfig *config,
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
897 FcPattern *p, FcPattern *p_pat FcMatchKind kind)
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
898 OMITTED: use optional arguments in `fc-config-substitute'. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
899
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
900 DEFUN("fc-config-substitute", Ffc_config_substitute, 1, 4, 0, /*
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
901 Modifies PATTERN according to KIND and TESTPAT using operations from CONFIG.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
902 PATTERN is modified in-place. Returns an undocumented Boolean value.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
903 If optional KIND is `fc-match-pattern', then those tagged as pattern operations
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
904 are applied, else if KIND is `fc-match-font', those tagged as font operations
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
905 are applied and TESTPAT is used for <test> elements with target=pattern. KIND
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
906 defaults to `fc-match-font'.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
907 If optional TESTPAT is nil, it is ignored. Otherwise it must be an FcPattern.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
908 Optional CONFIG must be an FcConfig, defaulting to the current one.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
909
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
910 Note that this function actually corresponds to FcConfigSubstituteWithPat, and
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
911 the argument order is changed to take advantage of Lisp optional arguments. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
912 (pattern, kind, testpat, config))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
913 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
914 FcMatchKind knd;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
915
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
916 /* There ought to be a standard idiom for this.... */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
917 if (NILP (kind)
4860
edc0cd26b4a8 fix more build problems
Ben Wing <ben@xemacs.org>
parents: 4849
diff changeset
918 || EQ (kind, Qfc_match_font))
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
919 knd = FcMatchFont;
4860
edc0cd26b4a8 fix more build problems
Ben Wing <ben@xemacs.org>
parents: 4849
diff changeset
920 else if (EQ (kind, Qfc_match_pattern))
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
921 knd = FcMatchPattern;
4860
edc0cd26b4a8 fix more build problems
Ben Wing <ben@xemacs.org>
parents: 4849
diff changeset
922 else
edc0cd26b4a8 fix more build problems
Ben Wing <ben@xemacs.org>
parents: 4849
diff changeset
923 wtaerror ("need `fc-match-pattern' or `fc-match-font'", kind);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
924
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
925 /* Typecheck arguments */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
926 CHECK_FCPATTERN (pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
927 if (!NILP (testpat)) CHECK_FCPATTERN (testpat);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
928 if (!NILP (config)) CHECK_FCCONFIG (config);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
929
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
930 return (FcConfigSubstituteWithPat
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
931 (NILP (config) ? FcConfigGetCurrent () : XFCCONFIG_PTR (config),
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
932 XFCPATTERN_PTR (pattern),
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
933 NILP (testpat) ? NULL : XFCPATTERN_PTR (testpat),
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
934 knd) == FcTrue)
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
935 ? Qt : Qnil;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
936 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
937
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
938 /* Pattern matching functions. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
939
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
940 /* The following functions return fonts that match a certain pattern.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
941 `FcFontRenderPrepare' and `FcFontMatch' always return a single best
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
942 match. `FcFontList' returns the list of fonts that match a given
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
943 pattern on a certain set of properties. `FcFontSort' returns the
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
944 entire list of fonts, sorted in order of match quality, possibly
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
945 filtering out fonts that do not provide additional characters beyond
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
946 those provided by preferred fonts. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
947
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
948 DEFUN("fc-font-render-prepare", Ffc_font_render_prepare, 2, 3, 0, /*
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
949 Return a new pattern blending PATTERN and FONT.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
950 Optional CONFIG is an FcConfig, defaulting to the current one.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
951 The returned pattern consists of elements of FONT not appearing in PATTERN,
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
952 elements of PATTERN not appearing in FONT, and the best matching value from
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
953 PATTERN for elements appearing in both. The result is passed to
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
954 FcConfigSubstitute with 'kind' FcMatchFont and then returned. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
955 (pattern, font, config))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
956 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
957 if (NILP (config)) {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
958 config = Ffc_config_get_current ();
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
959 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
960 CHECK_FCPATTERN (pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
961 CHECK_FCPATTERN (font);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
962 CHECK_FCCONFIG (config);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
963
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
964 /* I don't think this can fail? */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
965 return wrap_fcpattern (FcFontRenderPrepare (XFCCONFIG_PTR(config),
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
966 XFCPATTERN_PTR(font),
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
967 XFCPATTERN_PTR(pattern)));
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
968 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
969
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
970 DEFUN("fc-font-match", Ffc_font_match, 2, 3, 0, /*
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
971 Return the font on DEVICE that most closely matches PATTERN.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
972
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
973 DEVICE is an X11 device.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
974 PATTERN is a fontconfig pattern object.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
975 Optional CONFIG is an FcConfig, defaulting to the current one.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
976 Returns a fontconfig pattern object representing the closest match to the
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
977 given pattern, or an error code. Possible error codes are
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
978 `fc-result-no-match' and `fc-result-no-id'.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
979 PATTERN is massaged with FcConfigSubstitute and FcDefaultSubstitute before
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
980 being processed by FcFontMatch. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
981 (device, pattern, config))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
982 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
983 FcResult res;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
984 struct fc_pattern *res_fcpat;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
985 FcPattern *p;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
986 FcConfig *fcc;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
987
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
988 CHECK_FCPATTERN(pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
989 if (NILP(device))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
990 return Qnil;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
991 CHECK_X_DEVICE(device);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
992 if (!DEVICE_LIVE_P(XDEVICE(device)))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
993 return Qnil;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
994 if (!NILP (config))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
995 CHECK_FCCONFIG (config);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
996
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
997 res_fcpat = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
998 p = XFCPATTERN_PTR(pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
999 fcc = NILP (config) ? FcConfigGetCurrent () : XFCCONFIG_PTR (config);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1000
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1001 FcConfigSubstitute (fcc, p, FcMatchPattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1002 FcDefaultSubstitute (p);
4809
0d3ccd5a2509 Initialize the result variable passed to FcFontMatch. See xemacs-patches
Jerry James <james@xemacs.org>
parents: 4799
diff changeset
1003 res = FcResultMatch;
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1004 res_fcpat->fcpatPtr = FcFontMatch (fcc, p, &res);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1005
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1006 if (res_fcpat->fcpatPtr == NULL)
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1007 switch (res) {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1008 case FcResultNoMatch:
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1009 return Qfc_result_no_match;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1010 case FcResultNoId:
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1011 return Qfc_result_no_id;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1012 default:
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1013 return Qfc_internal_error;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1014 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1015 else
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1016 return wrap_fcpattern(res_fcpat);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1017 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1018
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1019 /* #### fix this name to correspond to Ben's new nomenclature */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1020 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects,
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1021 3, 3, 0, /*
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1022 Return a list of fonts on DEVICE that match PATTERN for PROPERTIES.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1023 Each font is represented by a fontconfig pattern object.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1024
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1025 DEVICE is an X11 device.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1026 PATTERN is a fontconfig pattern to be matched.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1027 PROPERTIES is a list of property names (strings) that should match.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1028
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1029 #### DEVICE is unused, ignored, and may be removed if it's not needed to
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1030 match other font-listing APIs. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1031 (UNUSED (device), pattern, properties))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1032 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1033 FcObjectSet *os;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1034 FcFontSet *fontset;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1035
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1036 CHECK_FCPATTERN (pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1037 CHECK_LIST (properties);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1038
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1039 os = FcObjectSetCreate ();
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1040 string_list_to_fcobjectset (properties, os);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1041 /* #### why don't we need to do the "usual substitutions"? */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1042 fontset = FcFontList (NULL, XFCPATTERN_PTR (pattern), os);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1043 FcObjectSetDestroy (os);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1044
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1045 return fontset_to_list (fontset, DestroyYes);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1046
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1047 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1048
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1049 /* #### maybe this can/should be folded into fc-list-fonts-pattern-objects? */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1050 DEFUN("fc-font-sort", Ffc_font_sort, 2, 4, 0, /*
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1051 Return a list of all fonts sorted by proximity to PATTERN.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1052 Each font is represented by a fontconfig pattern object.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1053
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1054 DEVICE is an X11 device.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1055 PATTERN is a fontconfig pattern to be matched.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1056 Optional argument TRIM, if non-nil, means to trim trailing fonts that do not
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1057 contribute new characters to the union repertoire.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1058
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1059 #### Optional argument NOSUB, if non-nil, suppresses some of the usual
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1060 property substitutions. DON'T USE THIS in production code, it is intended
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1061 for exploring behavior of fontconfig and will be removed when this code is
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1062 stable.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1063
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1064 #### DEVICE is unused, ignored, and may be removed if it's not needed to
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1065 match other font-listing APIs. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1066 (UNUSED (device), pattern, trim, nosub))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1067 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1068 CHECK_FCPATTERN (pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1069
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1070 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1071 FcConfig *fcc = FcConfigGetCurrent();
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1072 FcFontSet *fontset;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1073 FcPattern *p = XFCPATTERN_PTR (pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1074 FcResult fcresult;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1075
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1076 if (NILP(nosub)) /* #### temporary debug hack */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1077 FcDefaultSubstitute (p);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1078 FcConfigSubstitute (fcc, p, FcMatchPattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1079 fontset = FcFontSort (fcc, p, !NILP(trim), NULL, &fcresult);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1080
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1081 return fontset_to_list (fontset, DestroyYes);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1082 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1083 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1084
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1085 #ifdef FONTCONFIG_EXPOSE_CONFIG
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1086
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1087 /* Configuration routines --- for debugging
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1088 Don't depend on these routines being available in the future!
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1089
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1090 3.2.10 Initialization
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1091 ---------------------
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1092
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1093 An FcConfig object holds the internal representation of a configuration.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1094 There is a default configuration which applications may use by passing
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1095 0 to any function using the data within an FcConfig.
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1096 */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1097
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1098 static void
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1099 finalize_fc_config (void *header, int UNUSED (for_disksave))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1100 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1101 struct fc_config *p = (struct fc_config *) header;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1102 if (p->fccfgPtr && p->fccfgPtr != FcConfigGetCurrent())
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1103 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1104 /* If we get here, all of *our* references are garbage (see comment on
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1105 fc_config_create_using() for why), and the only reference that
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1106 fontconfig keeps is the current FcConfig. */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1107 FcConfigDestroy (p->fccfgPtr);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1108 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1109 p->fccfgPtr = 0;
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1110 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1111
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1112 static void
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1113 print_fc_config (Lisp_Object obj, Lisp_Object printcharfun,
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1114 int UNUSED(escapeflag))
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1115 {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1116 struct fc_config *c = XFCCONFIG (obj);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1117 if (print_readably)
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1118 printing_unreadable_object ("#<fc-config 0x%x>", c->header.uid);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1119 write_fmt_string (printcharfun, "#<fc-config 0x%x>", c->header.uid);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1120 }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1121
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1122 static const struct memory_description fcconfig_description [] = {
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1123 /* #### nothing here, is this right?? */
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1124 { XD_END }
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1125 };
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1126
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1127 DEFINE_LRECORD_IMPLEMENTATION("fc-config", fc_config, 0,
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1128 0, print_fc_config, finalize_fc_config, 0, 0,
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1129 fcconfig_description,
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1130 struct fc_config);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1131
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1132 DEFUN("fc-init", Ffc_init, 0, 0, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1133 -- Function: FcBool FcInit (void)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1134 Loads the default configuration file and the fonts referenced
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1135 therein and sets the default configuration to that result.
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1136 Returns whether this process succeeded or not. If the default
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1137 configuration has already been loaded, this routine does nothing
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1138 and returns FcTrue. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1139 ())
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1140 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1141 return (FcInit () == FcTrue) ? Qt : Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1142 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1143
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1144 DEFUN("fc-get-version", Ffc_get_version, 0, 0, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1145 -- Function: int FcGetVersion (void)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1146 Returns the version number of the library.
3935
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1147 XEmacs: No, this should NOT return a pretty string.
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1148 (let ((i (fc-get-version)))
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1149 (format "%d.%d.%d" (/ i 10000) (mod (/ i 100) 100) (mod i 100)))
3935
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1150 gives the usual x.y.z format. This is the version of the .so. It can be
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1151 checked against `fc-version', which is the version of fontconfig.h.
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1152 It's probably not a disaster if `(> (fc-get-version) fc-version)'. */
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1153 ())
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1154 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1155 return make_int (FcGetVersion ());
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1156 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1157
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1158 DEFUN("fc-init-reinitialize", Ffc_init_reinitialize, 0, 0, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1159 -- Function: FcBool FcInitReinitialize (void)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1160 Forces the default configuration file to be reloaded and resets
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1161 the default configuration. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1162 ())
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1163 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1164 return (FcInitReinitialize () == FcTrue) ? Qt : Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1165 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1166
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1167 DEFUN("fc-init-bring-up-to-date", Ffc_init_bring_up_to_date, 0, 0, 0, /*
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1168 -- Function: FcBool FcInitBringUptoDate (void)
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1169 Checks the rescan interval in the default configuration, checking
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1170 the configuration if the interval has passed and reloading the
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1171 configuration when any changes are detected. */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1172 ())
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1173 {
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1174 return (FcInitBringUptoDate () == FcTrue) ? Qt : Qnil;
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1175 }
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1176
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1177 #endif /* FONTCONFIG_EXPOSE_CONFIG */
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1178
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1179 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
1180 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
1181 (fontname))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1182 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1183 CHECK_STRING(fontname);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1184 /* #### should bind `case-fold-search' here? */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1185 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
1186 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1187
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1188 /* 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
1189 Ffc_pattern_print since this function prints to stdout. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1190
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1191 /* Initialization of font-mgr */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1192
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1193 #define XE_XLFD_SEPARATOR "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1194 /* 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
1195 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
1196 #if 0
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1197 #define XE_XLFD_PREFIX "\\(\\+[\040-\176\240-\377]*\\)?-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1198 #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
1199 #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
1200 #else
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1201 #define XE_XLFD_PREFIX "\\(\\+[\040-\176]*\\)?-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1202 #define XE_XLFD_OPT_TEXT "\\([^-]*\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1203 #define XE_XLFD_TEXT "\\([^-]+\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1204 #endif
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1205
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1206 #define XE_XLFD_SLANT "\\([0-9ior?*][iot]?\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1207 #define XE_XLFD_SPACING "\\([cmp?*]\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1208 /* Hyphen as minus conflicts with use as separator. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1209 #define XE_XLFD_OPT_NEGATE "~?"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1210 #define XE_XLFD_NUMBER "\\([0-9?*]+\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1211 #define XE_XLFD_PSIZE "\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1212
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1213 /* Call this only from the init code
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1214 #### 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
1215 static Lisp_Object
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1216 make_xlfd_font_regexp (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1217 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1218 struct gcpro gcpro1;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1219 unsigned i;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1220 Lisp_Object reg = Qnil;
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1221 const Extbyte *re[] = /* #### This could just be catenated by
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
1222 cpp and passed to build_extstring. */
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1223 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1224 /* 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
1225 Matches must be case-insensitive.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1226 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
1227 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
1228 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
1229
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1230 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
1231 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
1232 "\\`",
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1233 XE_XLFD_PREFIX, /* prefix */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1234 XE_XLFD_TEXT, /* foundry */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1235 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1236 XE_XLFD_TEXT, /* family */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1237 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1238 XE_XLFD_TEXT, /* weight */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1239 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1240 XE_XLFD_SLANT, /* slant */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1241 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1242 XE_XLFD_TEXT, /* swidth */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1243 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1244 XE_XLFD_OPT_TEXT, /* adstyle */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1245 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1246 XE_XLFD_PSIZE, /* pixelsize */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1247 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1248 XE_XLFD_PSIZE, /* pointsize */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1249 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1250 XE_XLFD_NUMBER, /* resx */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1251 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1252 XE_XLFD_NUMBER, /* resy */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1253 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1254 XE_XLFD_SPACING, /* spacing */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1255 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1256 XE_XLFD_OPT_NEGATE, /* avgwidth */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1257 XE_XLFD_NUMBER,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1258 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1259 XE_XLFD_TEXT, /* registry */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1260 XE_XLFD_SEPARATOR,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1261 XE_XLFD_TEXT, /* encoding */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1262 "\\'"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1263 };
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1264
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1265 GCPRO1 (reg);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1266 for (i = 0; i < sizeof(re)/sizeof(Extbyte *); i++)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1267 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1268 /* #### Currently this is Host Portable Coding, not ISO 8859-1. */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4932
diff changeset
1269 reg = concat2(reg, build_extstring (re[i], Qx_font_name_encoding));
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1270 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1271
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1272 RETURN_UNGCPRO (reg);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1273 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1274 #undef XE_XLFD_SEPARATOR
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1275 #undef XE_XLFD_PREFIX
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1276 #undef XE_XLFD_OPT_TEXT
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1277 #undef XE_XLFD_TEXT
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1278 #undef XE_XLFD_OPT_SLANT
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1279 #undef XE_XLFD_OPT_SPACING
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1280 #undef XE_XLFD_OPT_NEGATE
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1281 #undef XE_XLFD_NUMBER
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1282 #undef XE_XLFD_PSIZE
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1283
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1284 #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
1285 ? ((unsigned long) (x)) : ((unsigned long) (y)))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1286
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1287 static void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1288 string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1289 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1290 EXTERNAL_LIST_LOOP_2 (elt, list)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1291 {
3469
f986ebd9c080 [xemacs-hg @ 2006-06-23 15:44:59 by stephent]
stephent
parents: 3372
diff changeset
1292 const Extbyte *s;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1293
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1294 CHECK_STRING (elt);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1295 s = fc_intern (elt);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1296 FcObjectSetAdd (os, s);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1297 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1298 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1299
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1300 void
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1301 syms_of_font_mgr (void) {
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1302 INIT_LRECORD_IMPLEMENTATION(fc_pattern);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1303
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1304 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1305
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1306 DEFSYMBOL(Qfc_result_type_mismatch);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1307 DEFSYMBOL(Qfc_result_no_match);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1308 DEFSYMBOL(Qfc_result_no_id);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1309 DEFSYMBOL(Qfc_internal_error);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1310 DEFSYMBOL(Qfc_match_pattern);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1311 DEFSYMBOL(Qfc_match_font);
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
1312 DEFSYMBOL(Qfont_mgr);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1313
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1314 DEFSUBR(Ffc_pattern_p);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1315 DEFSUBR(Ffc_pattern_create);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1316 DEFSUBR(Ffc_name_parse);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1317 DEFSUBR(Ffc_name_unparse);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1318 DEFSUBR(Ffc_pattern_duplicate);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1319 DEFSUBR(Ffc_pattern_add);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1320 DEFSUBR(Ffc_pattern_del);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1321 DEFSUBR(Ffc_pattern_get);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1322 DEFSUBR(Ffc_list_fonts_pattern_objects);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1323 DEFSUBR(Ffc_font_sort);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1324 DEFSUBR(Ffc_font_match);
4758
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1325 DEFSUBR(Ffc_default_substitute);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1326 DEFSUBR(Ffc_config_substitute);
75975fd0b7fc Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4757
diff changeset
1327 DEFSUBR(Ffc_font_render_prepare);
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1328 DEFSUBR(Fxlfd_font_name_p);
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1329
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1330 #ifdef FONTCONFIG_EXPOSE_CONFIG
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1331 INIT_LRECORD_IMPLEMENTATION(fc_config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1332
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1333 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_configp);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1334
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1335 DEFSUBR(Ffc_config_p);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1336 DEFSUBR(Ffc_config_create);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1337 #if 0
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1338 DEFSUBR(Ffc_config_destroy);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1339 #endif
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1340 DEFSUBR(Ffc_config_set_current);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1341 DEFSUBR(Ffc_config_get_current);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1342 DEFSUBR(Ffc_config_up_to_date);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1343 DEFSUBR(Ffc_config_build_fonts);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1344 DEFSUBR(Ffc_config_get_config_dirs);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1345 DEFSUBR(Ffc_config_get_font_dirs);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1346 DEFSUBR(Ffc_config_get_config_files);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1347 DEFSUBR(Ffc_config_get_cache);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1348 DEFSUBR(Ffc_config_get_fonts);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1349 DEFSUBR(Ffc_config_get_blanks);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1350 DEFSUBR(Ffc_config_get_rescan_interval);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1351 DEFSUBR(Ffc_config_set_rescan_interval);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1352 DEFSUBR(Ffc_config_app_font_add_file);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1353 DEFSUBR(Ffc_config_app_font_add_dir);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1354 DEFSUBR(Ffc_config_app_font_clear);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1355 DEFSUBR(Ffc_config_filename);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1356 DEFSUBR(Ffc_init_load_config);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1357 DEFSUBR(Ffc_init_load_config_and_fonts);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1358 DEFSUBR(Ffc_init);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1359 DEFSUBR(Ffc_get_version);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1360 DEFSUBR(Ffc_init_reinitialize);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1361 DEFSUBR(Ffc_init_bring_up_to_date);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1362 #endif /* FONTCONFIG_EXPOSE_CONFIG */
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1363 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1364
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1365 void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1366 vars_of_font_mgr (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1367 {
3935
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1368 /* #### The next two DEFVARs belong somewhere else. */
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1369
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1370 /* #### 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
1371 DEFVAR_INT ("xft-debug-level", &debug_xft /*
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1372 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
1373 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
1374 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
1375 Higher levels give even more information.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1376 */ );
4757
a23ac8f90a49 Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4328
diff changeset
1377 debug_xft = 0;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1378
3935
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1379 DEFVAR_CONST_INT("xft-version", &xft_version /*
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1380 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
1381 */ );
3935
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1382 xft_version = XFT_VERSION;
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1383
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1384 DEFVAR_CONST_INT("fc-version", &fc_version /*
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1385 The version number of fontconfig.h. It can be checked against
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1386 `(fc-get-version)', which is the version of the .so.
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1387 It's probably not a disaster if `(> (fc-get-version) fc-version)'.
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1388 */ );
f56fa2f5f055 [xemacs-hg @ 2007-05-01 14:22:36 by stephent]
stephent
parents: 3931
diff changeset
1389 fc_version = FC_VERSION;
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1390
3360
316fddbf58e2 [xemacs-hg @ 2006-04-25 14:01:52 by stephent]
stephent
parents: 3354
diff changeset
1391 Fprovide (intern ("font-mgr"));
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1392 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1393
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1394 void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1395 complex_vars_of_font_mgr (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1396 {
3931
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1397 #ifdef FONTCONFIG_EXPOSE_CONFIG
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1398 Vfc_config_weak_list = make_weak_list (WEAK_LIST_SIMPLE);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1399 staticpro (&Vfc_config_weak_list);
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1400 #endif
fd1f0c73d4df [xemacs-hg @ 2007-04-30 16:46:29 by stephent]
stephent
parents: 3906
diff changeset
1401
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1402 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
1403 The regular expression used to match XLFD font names. */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1404 );
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1405 Vxlfd_font_name_regexp = make_xlfd_font_regexp();
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1406 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1407
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1408 void
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1409 reinit_vars_of_font_mgr (void)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1410 {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1411 int i, size = (int) countof (fc_standard_properties);
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1412
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1413 FcInit ();
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1414
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1415 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
1416 for (i = 0; i < size; ++i)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1417 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
1418 }
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1419