changeset 3354:15fb91e3a115

[xemacs-hg @ 2006-04-23 16:11:16 by stephent] Xft/fontconfig refactoring, Part I. <87hd4ks29d.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Sun, 23 Apr 2006 16:11:34 +0000
parents 521d94807505
children 721daee0fcd8
files ChangeLog configure.ac lisp/ChangeLog lisp/dumped-lisp.el lisp/font-mgr.el lisp/fontconfig.el lisp/x-faces.el lisp/x-font-menu.el lwlib/ChangeLog lwlib/lwlib-fonts.c man/ChangeLog man/internals/internals.texi src/ChangeLog src/Makefile.in.in src/config.h.in src/console-x.h src/emacs.c src/font-mgr.c src/font-mgr.h src/inline.c src/objects-x.c src/symsinit.h src/xft-fonts.c src/xft-fonts.h
diffstat 24 files changed, 1625 insertions(+), 1111 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Apr 22 21:51:52 2006 +0000
+++ b/ChangeLog	Sun Apr 23 16:11:34 2006 +0000
@@ -1,3 +1,7 @@
+2006-04-15  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* configure.ac: Add stubs for fontconfig configuration.
+
 2006-03-31  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.5.26 "endive" is released.
--- a/configure.ac	Sat Apr 22 21:51:52 2006 +0000
+++ b/configure.ac	Sun Apr 23 16:11:34 2006 +0000
@@ -669,6 +669,11 @@
 	[AC_DEFINE(INFOPATH_USER_DEFINED)], [])
 dnl
 XE_HELP_SUBSECTION([Window-system options])
+dnl Enable when fontconfig support is factored out of Xft.
+dnl XE_MERGED_ARG([fontconfig],
+dnl	AS_HELP_STRING([--with-fontconfig],
+dnl		       [Use fontconfig library to configure fonts.],
+dnl		       [],[])
 dnl if you change defaults, make sure to fix arg 6 of the OPTION_HELP macro.
 XE_COMPLEX_ARG([xft],
 	[XE_COMPLEX_OPTION_HELP_STRING([--with-xft],
@@ -3463,6 +3468,9 @@
           [XE_DIE(["Unable to find libfontconfig for --with-xft"])])
       AC_CHECK_LIB(Xft, XftFontOpen, XE_PREPEND(-lXft, libs_x),
           [XE_DIE(["Unable to find libXft for --with-xft"])])
+      dnl #### detect fontconfig properly!!!!
+      with_fontconfig=yes
+      AC_DEFINE(HAVE_FONTCONFIG)
       AC_DEFINE(USE_XFT)
       dnl Due to interactions with other libraries, must postpone AC_DEFINE
       dnl of USE_XFT_MENUBARS, USE_XFT_TABS, and USE_XFT_GAUGE.
@@ -5977,6 +5985,9 @@
   if test "$with_wmcommand" != no; then
     echo "    - Handling WM_COMMAND properly."
   fi
+  if test "$with_fontconfig" = "yes"; then
+    echo "    - Using fontconfig to manage fonts."
+  fi
   if test "$with_xft_emacs" = "yes"; then
     echo "    - Compiling in support for Xft antialiased fonts (EXPERIMENTAL)."
   fi
--- a/lisp/ChangeLog	Sat Apr 22 21:51:52 2006 +0000
+++ b/lisp/ChangeLog	Sun Apr 23 16:11:34 2006 +0000
@@ -1,3 +1,35 @@
+2006-04-24  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* dumped-lisp.el (fontconfig): Load only with Xft.
+
+	* x-faces.el (fontconfig): Require only with Xft.
+
+2006-04-16  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* font-mgr.el: New file.  Provides Lisp emulation of fontconfig.
+
+	* fontconfig.el: Require 'font-mgr.
+
+2006-04-11  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* fontconfig.el:
+	Add some comments on proposed generic APIs.
+	Remove some unused and probably broken code.
+	Use `fc-define-property' to define new X11 XLFD standard
+	properties: x11-swidth, x11-adstyle, x11-resx, x11-resy,
+	x11-registry, and x11-encoding.
+	Delete fc-font-name-property-PROPERTY constants.
+	(fc-define-property):
+	Add `fc-pattern-del-PROPERTY'.
+
+	* x-faces.el (x-make-font-bold-xft):
+	(x-make-font-unbold-xft):
+	(x-make-font-italic-xft):
+	(x-make-font-unitalic-xft):
+	(x-find-xft-font-of-size): 
+	* x-font-menu.el (x-font-menu-load-font-xft):
+	Use property-specific APIs instead of defconsts for property names.
+
 2006-04-16  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* cl.el (incf):
--- a/lisp/dumped-lisp.el	Sat Apr 22 21:51:52 2006 +0000
+++ b/lisp/dumped-lisp.el	Sun Apr 23 16:11:34 2006 +0000
@@ -54,7 +54,7 @@
        "specifier"
        "frame"			; needed by faces
        ;; #### this should be (featurep 'xft)
-       (when (featurep 'x) "fontconfig") ; needed by x-faces
+       (when (featurep 'xft-fonts) "fontconfig") ; needed by x-faces
        (when (featurep 'x) "x-faces") ; needed by faces
        (when (featurep 'gtk) "gtk-faces")
        (when (valid-console-type-p 'mswindows) "msw-faces")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/font-mgr.el	Sun Apr 23 16:11:34 2006 +0000
@@ -0,0 +1,255 @@
+;;; font-mgr.el --- Lisp emulation of fontconfig for X fonts.
+
+;; Copyright (C) 2006 Free Software Foundation, Inc.
+
+;; Author:	Stephen J. Turnbull <stephen@xemacs.org>
+;; Created:	12 Apr 2006 by Stephen J. Turnbull
+
+;; This file is part of XEmacs.
+
+;; XEmacs is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by the
+;; Free Software Foundation; either version 2, or (at your option) any
+;; later version.
+
+;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+;; for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with XEmacs; see the file COPYING.  If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Synched up with: Not in GNU Emacs.
+
+;; Commentary
+;; This module provides the Lisp interface to fonts in X11, including Xft,
+;; but (at least at first) not GTK+ or Qt.  It is a substitute for the
+;; C library fontconfig, whose interface is provided in ../src/font-mgr.c.
+
+;; static FcChar8 *fc_standard_properties[] = {
+;;   "antialias", "aspect", "autohint", "charset", "dpi", "family", "file",
+;;   "foundry", "ftface", "globaladvance", "hinting", "index", "lang",
+;;   "minspace", "outline", "pixelsize", "rasterizer", "rgba", "scalable",
+;;   "scale", "size", "slant", "spacing", "style", "verticallayout", "weight",
+;;   /* obsolete after Xft v. 1 */
+;;   "charwidth", "charheight", "core", "encoding", "render"
+
+;; #### should we wrap the world in `(unless (featurep 'font-mgr) ... )'?
+
+(provide 'font-mgr)
+
+(defvar xft-xlfd-font-regexp
+  (concat
+   ;; XLFD specifies ISO 8859-1 encoding, but we can't handle non-ASCII
+   ;; in Mule when this function is called.  So use HPC.
+   ;; (xe_xlfd_prefix "\\(\\+[\040-\176\240-\377]*\\)?-")
+   ;; (xe_xlfd_opt_text "\\([\040-\044\046-\176\240-\377]*\\)")
+   ;; (xe_xlfd_text "\\([\040-\044\046-\176\240-\377]+\\)")
+   "\\`"
+   "\\(\\+[\040-\176]*\\)?-"		; prefix
+   "\\([^-]+\\)"			; foundry
+   "-"
+   "\\([^-]+\\)"			; family
+   "-"
+   "\\([^-]+\\)"			; weight
+   "-"
+   "\\([0-9ior?*][iot]?\\)"		; slant
+   "-"
+   "\\([^-]+\\)"			; swidth
+   "-"
+   "\\([^-]*\\)"			; adstyle
+   "-"
+   "\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)"    ; pixelsize
+   "-"
+   "\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)"    ; pointsize
+   "-"
+   "\\([0-9?*]+\\)"			; resx
+   "-"
+   "\\([0-9?*]+\\)"			; resy
+   "-"
+   "\\([cmp?*]\\)"			; spacing
+   "-"
+   "~?"					; avgwidth
+   "\\([0-9?*]+\\)"
+   "-"
+   "\\([^-]+\\)"			; registry
+   "-"
+   "\\([^-]+\\)"			; encoding
+   "\\'")
+  "The regular expression used to match XLFD font names.")
+
+(defun fc-pattern-p (object)
+  "Returns t if OBJECT is of type fc-pattern, nil otherwise."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+(defun fc-pattern-create ()
+  "Return a new, empty fc-pattern object."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+(defun fc-name-parse (fontname)
+  "Parse an Fc font name and return its representation as a fc pattern object."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+(defun fc-name-unparse (pattern)
+  "Unparse an fc pattern object to a string."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+(defun fc-pattern-duplicate (pattern)
+  "Make a copy of the fc pattern object PATTERN and return it."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+(defun fc-pattern-add (pattern property value)
+  "Add attributes to the pattern object PATTERN.  PROPERTY is a string naming
+the attribute to add, VALUE the value for this attribute.
+
+VALUE may be a string, integer, float, or symbol, in which case the value
+will be added as an FcChar8[], int, double, or FcBool respectively."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+(defun fc-pattern-del (pattern property)
+  "Remove attribute PROPERTY from fc pattern object PATTERN."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+;; Generic interface to FcPatternGet()
+;; Don't support the losing symbol-for-property interface.
+
+(defun fc-pattern-get (pattern property &optional id type)
+  "From PATTERN, extract PROPERTY for the ID'th member, of type TYPE.
+
+PATTERN is an Xft \(fontconfig) pattern object.
+PROPERTY is a string naming an fontconfig font property.
+Optional ID is a nonnegative integer indexing the list of values for PROPERTY
+  stored in PATTERN, defaulting to 0 (the first value).
+Optional TYPE is a symbol, one of 'string, 'boolean, 'integer, 'float,
+  'double, 'matrix, 'charset, or 'void, corresponding to the FcValue types.
+  \('float is an alias for 'double).
+
+The Lisp types returned will conform to TYPE:
+  string		string
+  boolean		`t' or `nil'
+  integer		integer
+  double \(float)	float
+  matrix		not implemented
+  charset		not implemented
+  void			not implemented
+
+Symbols with names of the form \"fc-result-DESCRIPTION\" are returned when
+the desired value is not available.  These are
+
+  fc-result-type-mismatch       the value found has an unexpected type
+  fc-result-no-match            there is no such attribute
+  fc-result-no-id               there is no value for the requested ID
+
+The types of the following standard properties are predefined by fontconfig.
+The symbol 'fc-result-type-mismatch will be returned if the object exists but
+TYPE does not match the predefined type.  It is best not to specify a type
+for predefined properties, as a mistake here ensures error returns on the
+correct type.
+
+Each standard property has a convenience accessor defined in fontconfig.el,
+named in the form \"fc-pattern-get-PROPERTY\".  The convenience functions are
+preferred to `fc-pattern-get' since a typo in the string naming a property
+will result in a silent null return, while a typo in a function name will
+usually result in a compiler or runtime \"not fboundp\" error.  You may use
+`defsubst' to define convenience functions for non-standard properties.
+
+family         String  Font family name 
+style          String  Font style. Overrides weight and slant 
+slant          Int     Italic, oblique or roman 
+weight         Int     Light, medium, demibold, bold or black 
+size           Double  Point size 
+aspect         Double  Stretches glyphs horizontally before hinting 
+pixelsize      Double  Pixel size 
+spacing        Int     Proportional, monospace or charcell 
+foundry        String  Font foundry name 
+antialias      Bool    Whether glyphs can be antialiased 
+hinting        Bool    Whether the rasterizer should use hinting 
+verticallayout Bool    Use vertical layout 
+autohint       Bool    Use autohinter instead of normal hinter 
+globaladvance  Bool    Use font global advance data 
+file           String  The filename holding the font 
+index          Int     The index of the font within the file 
+ftface         FT_Face Use the specified FreeType face object 
+rasterizer     String  Which rasterizer is in use 
+outline        Bool    Whether the glyphs are outlines 
+scalable       Bool    Whether glyphs can be scaled 
+scale          Double  Scale factor for point->pixel conversions 
+dpi            Double  Target dots per inch 
+rgba           Int     unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry 
+minspace       Bool    Eliminate leading from line spacing 
+charset        CharSet Unicode chars encoded by the font 
+lang           String  List of RFC-3066-style languages this font supports
+
+The FT_Face, Matrix, CharSet types are unimplemented, so the corresponding
+properties are not accessible from Lisp at this time.  If the value of a
+property returned has type FT_Face, FcCharSet, or FcMatrix,
+`fc-result-type-mismatch' is returned.
+
+The following properties which were standard in Xft v.1 are obsolete in
+Xft v.2:  encoding, charwidth, charheight, core, and render."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+(defun fc-font-match (device pattern)
+  "Return the font on DEVICE that most closely matches PATTERN.
+
+DEVICE is an X11 device.
+PATTERN is a fontconfig pattern object.
+Returns a fontconfig pattern object representing the closest match to the
+given pattern, or an error code.  Possible error codes are
+`fc-result-no-match' and `fc-result-no-id'."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+;; #### fix this name to correspond to Ben's new nomenclature
+(defun fc-list-fonts-pattern-objects (device pattern properties)
+  "Return a list of fonts on DEVICE that match PATTERN for PROPERTIES.
+Each font is represented by a fontconfig pattern object.
+
+DEVICE is an X11 device.
+PATTERN is a fontconfig pattern to be matched.
+PROPERTIES is a list of property names (strings) that should match.
+
+#### DEVICE is unused, ignored, and may be removed if it's not needed to
+match other font-listing APIs."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+;; #### maybe this can/should be folded into fc-list-fonts-pattern-objects?
+(defun fc-font-sort (device pattern &optional trim nosub)
+  "Return a list of all fonts sorted by proximity to PATTERN.
+Each font is represented by a fontconfig pattern object.
+
+DEVICE is an X11 device.
+PATTERN is a fontconfig pattern to be matched.
+Optional argument TRIM, if non-nil, means to trim trailing fonts that do not
+contribute new characters to the union repertoire.
+
+#### Optional argument NOSUB, if non-nil, suppresses some of the usual
+property substitutions.  DON'T USE THIS in production code, it is intended
+for exploring behavior of fontconfig and will be removed when this code is
+stable.
+
+#### DEVICE is unused, ignored, and may be removed if it's not needed to
+match other font-listing APIs."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+
+(when nil
+  ;; #### this actually is an Xft function, should split those out
+  ;; or get rid of them entirely?
+  ;; #### be consistent about argument order.
+(defun fc-font-real-pattern (fontname xdevice)
+  "Temporarily open FONTNAME (a string) and return the actual
+fc pattern matched by the Fc library."
+  (error 'unimplemented "font-mgr library is experimental and incomplete"))
+)
+
+(defun xlfd-font-name-p (fontname)
+  "Check whether the string FONTNAME is a XLFD font name."
+  (save-match-data
+    (string-match xft-xlfd-font-regexp fontname)))
+
+;; FcPatternPrint: there is no point in having wrappers fc-pattern-print,
+;; Ffc_pattern_print since this function prints to stdout.
+
+;;; end font-mgr.el
--- a/lisp/fontconfig.el	Sat Apr 22 21:51:52 2006 +0000
+++ b/lisp/fontconfig.el	Sun Apr 23 16:11:34 2006 +0000
@@ -105,10 +105,11 @@
 ;; constructor function `fc-pattern-create'.  #### It might make sense
 ;; to generalize `make-fc-pattern' by allowing a plist of properties
 ;; as an optional argument.  We also provide accessors
-;; `fc-pattern-get-PROPERTY' and mutators `fc-pattern-add-PROPERTY'
-;; for each of the standard properties used by Xft, which overlap
-;; substantially with the properties defined by X11.  #### We probably
-;; should provide `fc-pattern-delete-PROPERTY', too.
+;; `fc-pattern-get-PROPERTY' and mutators `fc-pattern-add-PROPERTY' and
+;; `fc-pattern-del-PROPERTY' for each of the standard properties used by
+;; Xft, which overlap substantially with the properties defined by X11.
+
+(require 'font-mgr)
 
 (defalias 'make-fc-pattern 'fc-pattern-create)
 
@@ -117,10 +118,10 @@
 
 A font property is a key in a fontconfig pattern and is associated with
 one or more values of a given type.  This macro creates wrappers around
-`fc-pattern-get' and `fc-pattern-add' for PROPERTY.  Wrappers are
-preferred to use of primitives with a string as the OBJECT argument because
-typos in wrappers result in \"not fboundp\" errors, while a typo in a string
-produces a silent null return.
+`fc-pattern-get', `fc-pattern-add', and `fc-pattern-del' for PROPERTY.
+\(Wrappers are preferred to use of primitives with a string as the OBJECT
+argument because typos in wrappers result in \"not fboundp\" errors, while
+a typo in a string produces a silent null return.)
 
 PROPERTY is a string.
 TYPE is a symbol indicating the type of the property value.  It is used only
@@ -140,7 +141,10 @@
 A mutator `fc-pattern-add-PROPERTY' which takes a fontconfig pattern object
 and a value as arguments, and adds the value to the property with the next
 id.  The type of the value is recognized by `fc-pattern-add', and the id
-is chosen by the fontconfig implementation."
+is chosen by the fontconfig implementation.
+
+A mutator `fc-pattern-del-PROPERTY' which takes a fontconfig pattern object,
+and deletes all values of that property from the pattern."
 
   `(progn
     (defsubst ,(intern (concat "fc-pattern-get-" property))
@@ -179,6 +183,20 @@
 		 "")
 	       type)
       (fc-pattern-add pattern ,property value))
+
+    (defsubst ,(intern (concat "fc-pattern-del-" property))
+      (pattern)
+      ,(format "\
+Delete all values of the %s property of fontconfig pattern PATTERN.%s
+
+This function is a convenience wrapper for `fc-pattern-del'.
+See `fc-pattern-del' for documentation of patterns and error returns."
+	       property
+	       (if obsolete-p "
+\(Obsolete, only available on systems using Xft version 1.)"
+		 "")
+	       type)
+      (fc-pattern-del pattern ,property))
     ,property))
 
 ;; define the standard properties for Xft v.2 here
@@ -202,68 +220,26 @@
 (fc-define-property "weight" integer "the weight")
 (fc-define-property "xlfd" string "the XLFD (full name in X11)")
 
-;; Xft v.1 properties (marked as obsolete)
+;; Xft v.1 properties (generally marked as obsolete)
+;; had different semantics from XLFD "encoding"
 (fc-define-property "encoding" string "the encoding" t)
-(fc-define-property "charwidth" integer "the average character width" t)
+;; also used by X11 XLFDs, so not obsolete
+(fc-define-property "charwidth" integer "the average character width")
 (fc-define-property "charheight" integer "the average character height" t)
 (fc-define-property "core" boolean "represents a core font" t)
 (fc-define-property "render" boolean "represents a render (Xft) font" t)
 
-
-(defconst fc-font-name-property-family "family")
-(defconst fc-font-name-property-style "style")
-(defconst fc-font-name-property-slant "slant")
-(defconst fc-font-name-property-weight "weight")
-(defconst fc-font-name-property-size "size")
-(defconst fc-font-name-property-pixelsize "pixelsize")
-(defconst fc-font-name-property-spacing "spacing")
-(defconst fc-font-name-property-foundry "foundry")
-(defconst fc-font-name-property-antialias "antialias")
-(defconst fc-font-name-property-xlfd "xlfd")
-(defconst fc-font-name-property-file "file")
-(defconst fc-font-name-property-index "index")
-(defconst fc-font-name-property-rasterizer "rasterizer")
-(defconst fc-font-name-property-outline "outline")
-(defconst fc-font-name-property-scalable "scalable")
-(defconst fc-font-name-property-rgba "rgba")
-(defconst fc-font-name-property-minspace "minspace")
-(defconst fc-font-name-property-dpi "dpi")
-
-;; Xft version 1 only
-;;(defconst fc-font-name-property-encoding "encoding")
-;;(defconst fc-font-name-property-charwidth "charwidth")
-;;(defconst fc-font-name-property-charheight "charheight")
-;;(defconst fc-font-name-property-core "core")
-;;(defconst fc-font-name-property-render "render")
+;; X11 XLFD and other standard properties
+(fc-define-property "x11-swidth" string "the 'set' width")
+(fc-define-property "x11-adstyle" string "any additional style")
+(fc-define-property "x11-resx" string "the horizontal design resolution")
+(fc-define-property "x11-resy" string "the vertical design resolution")
+;; use "charwidth" instead of "x11-avgwidth"
+(fc-define-property "x11-registry" string "the encoding registry")
+;; "x11-encoding" has different semantics from Xft v.1 "encoding"
+(fc-define-property "x11-encoding" string "the encoding index")
 
 
-(defconst fc-pattern-selector-mapping
-  `((,fc-font-name-property-family        . fc-pattern-get-family)
-    (,fc-font-name-property-style         . fc-pattern-get-style)
-    (,fc-font-name-property-slant         . fc-pattern-get-slant)
-    (,fc-font-name-property-weight        . fc-pattern-get-weight)
-    (,fc-font-name-property-size          . fc-pattern-get-size)
-    (,fc-font-name-property-pixelsize     . fc-pattern-get-pixelsize)
-    (,fc-font-name-property-spacing       . fc-pattern-get-spacing)
-    (,fc-font-name-property-foundry       . fc-pattern-get-foundry)
-    (,fc-font-name-property-antialias     . fc-pattern-get-antialias)
-    (,fc-font-name-property-xlfd          . fc-pattern-get-xlfd)
-    (,fc-font-name-property-file          . fc-pattern-get-file)
-    (,fc-font-name-property-index         . fc-pattern-get-index)
-    (,fc-font-name-property-rasterizer    . fc-pattern-get-rasterizer)
-    (,fc-font-name-property-outline       . fc-pattern-get-outline)
-    (,fc-font-name-property-scalable      . fc-pattern-get-scalable)
-    (,fc-font-name-property-rgba          . fc-pattern-get-rgba)
-    (,fc-font-name-property-minspace      . fc-pattern-get-minspace)
-    (,fc-font-name-property-dpi           . fc-pattern-get-dpi)
-    ;; Xft version 1 only
-    ;; (,fc-font-name-property-encoding      . fc-pattern-get-encoding)
-    ;; (,fc-font-name-property-charwidth     . fc-pattern-get-char-width)
-    ;; (,fc-font-name-property-charheight    . fc-pattern-get-char-height)
-    ;; (,fc-font-name-property-core          . fc-pattern-get-core)
-    ;; (,fc-font-name-property-render        . fc-pattern-get-render)
-    ))
-
 (defvar fc-find-available-font-families-fc-fonts-only t
   "If `fc-find-available-font-families-fc-fonts-only' is set to `t',
 `fc-find-available-font-families' will ignore core fonts.")
@@ -415,7 +391,33 @@
 ;;
 ;;   fc-name-parse
 ;;   fc-name-unparse
-;;   xft-name-unparse
+;;   xft-name-unparse (nonfunctional and presumably obsolete)
+;;
+;; For interfacing with various font rendering systems, we need to be able
+;; to convert the fontconfig patterns to names, and vice versa.  The high-
+;; level API is
+;;
+;;   font-default-name-syntax
+;;     variable naming the default naming syntax
+;;     maybe this could be a list to try in order?
+;;
+;;   font-name-to-pattern NAME &optional SYNTAX
+;;     returns a fontconfig pattern, or nil if the name could not be parsed
+;;     NAME is a string
+;;     SYNTAX is a name syntax symbol
+;;
+;;   font-pattern-to-name PATTERN &optional SYNTAX
+;;     returns a string
+;;     PATTERN is a fontconfig pattern
+;;     SYNTAX is a name syntax symbol
+;;
+;; A "name syntax symbol" is a symbol for a font naming syntax.  This may be
+;; a rendering engine syntax or a font manager syntax.  Initially, 'x and
+;; 'fontconfig will be supported.  Patterns may be unambiguous (one value for
+;; each specified property) or ambiguous (multiple values are allowed for
+;; some specified properties).  `font-name-to-pattern' should be unambiguous,
+;; but `font-pattern-to-name' may not be an exact conversion for some
+;; syntaxes, especially for ambiguous patterns.
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
@@ -429,6 +431,29 @@
 ;;   fc-list-fonts-pattern-objects
 ;;   fc-font-sort
 ;;   fc-font-real-pattern
+;;
+;; The high-level API is
+;;
+;;   font-list &optional PATTERN DEVICE ATTRIBUTE-LIST OPTION-LIST
+;;     returns a list of patterns matching pattern
+;;     PATTERN is an ambiguous pattern, defaulting to the empty pattern
+;;     DEVICE is the display device to query (default: selected device)
+;;     ATTRIBUTE-LIST is a list of font attributes to restrict the patterns
+;;       in the returned list to; other attributes will not be present in
+;;       the patterns, and duplicates will be removed after pruning unwanted
+;;       attributes; ATTRIBUTE-LIST has no necessary relation to the active
+;;       attributes in PATTERN, both subset and superset make sense; if nil,
+;;       the active attributes in PATTERN is used
+;;     OPTION-LIST is a list of presentation options, such as sort order
+;;       and refresh-cache (if any).
+;;
+;;   font-match PATTERN &optional DEVICE
+;;     returns a pattern representing the platform match for PATTERN,
+;;       which should unambiguously select the same font
+;;     PATTERN is an ambiguous pattern
+;;     DEVICE is the display device to query (default: selected device)
+;;
+;; Maybe these APIs should get an error-behavior argument?
 
 ;; #### it might make sense to generalize `fc-try-font' by having a
 ;; global variable that contains a list of font name parsers.  They are
@@ -446,15 +471,17 @@
 				   (fc-name-parse font))
 				 nil))
 
+;; for example, we'd like these next two to be implementable as
+;; (font-list (fc-create-pattern) device '("family" "style")) and
+;; (font-list (let ((p (fc-create-pattern))) (fc-pattern-add "family" family))
+;;            device
+;;            '("weight"))
+
 (defun fc-find-available-font-families (&optional device filter-fun)
   "Find all available font families."
   (let ((device (or device (default-x-device)))
 	(pattern (make-fc-pattern))
 	(objectset '("family" "style")))
-;     Xft2: does not work anymore
-;     (if (not fc-find-available-font-families-fc-fonts-only)
-; 	(fc-pattern-add pattern fc-font-name-property-core t))
-;     (fc-objectset-add objectset fc-font-name-property-encoding)
     (let* ((all-fonts
 	    (fc-list-fonts-pattern-objects device pattern objectset)))
       (fc-delete-duplicates
@@ -465,24 +492,14 @@
 	    (fc-filter all-fonts filter-fun)
 	  all-fonts))))))
 
-; Xft2: does not work anymore
-; (defun fc-find-available-font-families-non-mule (&optional device)
-;   (fc-find-available-font-families
-;    device
-;    '(lambda (pattern)
-;       (let ((encodings (fc-pattern-get-all-attributes 
-; 			pattern 'fc-pattern-get-encoding)))
-; 	;; Be sure that the font support ISO-8859-1
-; 	(member "iso8859-1" encodings)))))
-
 (defun fc-find-available-weights-for-family (family &optional style device)
   "Find available weights for font FAMILY."
   (let* ((device (or device (default-x-device)))
 	 (pattern (make-fc-pattern))
 	 (objectset '("weight")))
-    (fc-pattern-add pattern fc-font-name-property-family family)
+    (fc-pattern-add-family pattern family)
     (if style
-	(fc-pattern-add pattern fc-font-name-property-style style))
+	(fc-pattern-add-style pattern style))
     (mapcar
      '(lambda (pattern)
 	(let ((fc-weight-constant (fc-pattern-get-weight pattern 0)))
--- a/lisp/x-faces.el	Sat Apr 22 21:51:52 2006 +0000
+++ b/lisp/x-faces.el	Sun Apr 23 16:11:34 2006 +0000
@@ -66,7 +66,19 @@
  '(x-get-resource-and-maybe-bogosity-check
    x-get-resource x-init-pointer-shape))
 
-(require 'fontconfig)
+(if (featurep 'xft-fonts)
+    (require 'fontconfig)
+  (globally-declare-boundp
+   '(fc-font-name-weight-bold     fc-font-name-weight-black
+     fc-font-name-weight-demibold fc-font-name-weight-medium
+     fc-font-name-slant-oblique   fc-font-name-slant-italic
+     fc-font-name-slant-roman))
+  (globally-declare-fboundp
+    '(fc-font-real-pattern  fc-pattern-get-size  fc-copy-pattern-partial
+      fc-pattern-del-weight fc-pattern-del-style fc-pattern-duplicate
+      fc-pattern-add-weight fc-try-font          fc-pattern-add-size
+      fc-name-unparse       fc-pattern-del-slant fc-pattern-add-slant
+      fc-pattern-del-size   fc-pattern-get-pixelsize)))
 
 (defconst x-font-regexp nil)
 (defconst x-font-regexp-head nil)
@@ -186,32 +198,28 @@
 		  font (or device (default-x-device)))))
     (if pattern
 	(let ((size (fc-pattern-get-size pattern 0))
-	      (copy (fc-copy-pattern-partial 
-		     pattern (list fc-font-name-property-family))))
-	  (fc-pattern-del copy fc-font-name-property-weight)
-	  (fc-pattern-del copy fc-font-name-property-style)
+	      (copy (fc-copy-pattern-partial pattern (list "family"))))
+	  (fc-pattern-del-weight copy)
+	  (fc-pattern-del-style copy)
 	  (when copy
 	    (or 
 	     ;; try bold font
 	     (let ((copy-2 (fc-pattern-duplicate copy)))
-	       (fc-pattern-add copy-2 fc-font-name-property-weight
-				fc-font-name-weight-bold)
+	       (fc-pattern-add-weight copy-2 fc-font-name-weight-bold)
 	       (when (fc-try-font copy-2 device)
-		 (fc-pattern-add copy-2 fc-font-name-property-size size)
+		 (fc-pattern-add-size copy-2 size)
 		 (fc-name-unparse copy-2)))
 	     ;; try black font
 	     (let ((copy-2 (fc-pattern-duplicate copy)))
-	       (fc-pattern-add copy-2 fc-font-name-property-weight
-				fc-font-name-weight-black)
+	       (fc-pattern-add-weight copy-2 fc-font-name-weight-black)
 	       (when (fc-try-font copy-2 device)
-		 (fc-pattern-add copy-2 fc-font-name-property-size size)
+		 (fc-pattern-add-size copy-2 size)
 		 (fc-name-unparse copy-2)))
 	     ;; try demibold font
 	     (let ((copy-2 (fc-pattern-duplicate copy)))
-	       (fc-pattern-add copy-2 fc-font-name-property-weight
-				fc-font-name-weight-demibold)
+	       (fc-pattern-add-weight copy-2 fc-font-name-weight-demibold)
 	       (when (fc-try-font copy-2 device)
-		 (fc-pattern-add copy-2 fc-font-name-property-size size)
+		 (fc-pattern-add-size copy-2 size)
 		 (fc-name-unparse copy-2)))))))))
   
 (defun x-make-font-bold-core (font &optional device)
@@ -233,9 +241,8 @@
   (let ((pattern (fc-font-real-pattern 
 		  font (or device (default-x-device)))))
     (when pattern
-      (fc-pattern-del pattern fc-font-name-property-weight)
-      (fc-pattern-add pattern fc-font-name-property-weight
-		       fc-font-name-weight-medium)
+      (fc-pattern-del-weight pattern)
+      (fc-pattern-add-weight pattern fc-font-name-weight-medium)
       (if (fc-try-font pattern device)
 	  (fc-name-unparse pattern)))))
 
@@ -265,39 +272,37 @@
 		  font (or device (default-x-device)))))
     (if pattern
       (let ((size (fc-pattern-get-size pattern 0))
-	    (copy (fc-copy-pattern-partial
-		   pattern (list fc-font-name-property-family))))
+	    (copy (fc-copy-pattern-partial pattern (list "family"))))
 	(when copy
-	  (fc-pattern-del copy fc-font-name-property-slant)
-	  (fc-pattern-del copy fc-font-name-property-style)
+	  (fc-pattern-del-slant copy)
+	  (fc-pattern-del-style copy)
+	  ;; #### can't we do this with one ambiguous pattern?
 	  (let ((pattern-oblique (fc-pattern-duplicate copy))
 		(pattern-italic (fc-pattern-duplicate copy)))
-	    (fc-pattern-add pattern-oblique fc-font-name-property-slant
-			     fc-font-name-slant-oblique)
-	    (fc-pattern-add pattern-italic fc-font-name-property-slant
-			     fc-font-name-slant-italic)
+	    (fc-pattern-add-slant pattern-oblique fc-font-name-slant-oblique)
+	    (fc-pattern-add-slant pattern-italic fc-font-name-slant-italic)
 	    (let ((have-oblique (fc-try-font pattern-oblique device))
 		  (have-italic (fc-try-font pattern-italic device)))
 	      (if try-oblique-before-italic-fonts
 		  (if have-oblique
 		      (progn 
 			(if size
-			    (fc-pattern-add pattern-oblique fc-font-name-property-size size))
+			    (fc-pattern-add-size pattern-oblique size))
 			(fc-name-unparse pattern-oblique))
 		    (if have-italic
 			(progn
 			  (if size
-			      (fc-pattern-add pattern-italic fc-font-name-property-size size))
+			      (fc-pattern-add-size pattern-italic size))
 			  (fc-name-unparse pattern-italic))))
 		(if have-italic
 		    (progn
 		      (if size
-			  (fc-pattern-add pattern-italic fc-font-name-property-size size))
+			  (fc-pattern-add-size pattern-italic size))
 		      (fc-name-unparse pattern-italic))
 		  (if have-oblique
 		      (progn
 			(if size
-			    (fc-pattern-add pattern-oblique fc-font-name-property-size size))
+			    (fc-pattern-add-size pattern-oblique size))
 			(fc-name-unparse pattern-oblique))))))))))))
   
 (defun x-make-font-italic-core (font &optional device)
@@ -320,9 +325,8 @@
   (let ((pattern (fc-font-real-pattern 
 		  font (or device (default-x-device)))))
     (when pattern
-      (fc-pattern-del pattern fc-font-name-property-slant)
-      (fc-pattern-add pattern fc-font-name-property-slant
-		       fc-font-name-slant-roman)
+      (fc-pattern-del-slant pattern)
+      (fc-pattern-add-slant pattern fc-font-name-slant-roman)
       (if (fc-try-font pattern device)
 	  (fc-name-unparse pattern)))))
 
@@ -523,9 +527,8 @@
       (let ((size (fc-pattern-get-size pattern 0)))
 	(if (floatp size)
 	    (let ((copy (fc-pattern-duplicate pattern)))
-	      (fc-pattern-del copy fc-font-name-property-size)
-	      (fc-pattern-add copy fc-font-name-property-size 
-			       (funcall new-size-proc size))
+	      (fc-pattern-del-size copy)
+	      (fc-pattern-add-size copy (funcall new-size-proc size))
 	      (if (fc-try-font font device)
 		  (fc-name-unparse copy))))))))
 
--- a/lisp/x-font-menu.el	Sat Apr 22 21:51:52 2006 +0000
+++ b/lisp/x-font-menu.el	Sun Apr 23 16:11:34 2006 +0000
@@ -346,15 +346,15 @@
 
 (defun x-font-menu-load-font-xft (family weight size slant resolution)
   (let ((pattern (make-fc-pattern)))
-    (fc-pattern-add pattern fc-font-name-property-family family)
+    (fc-pattern-add-family pattern family)
     (if weight 
-	(fc-pattern-add pattern fc-font-name-property-weight
-			 (fc-font-weight-translate-from-string weight)))
+	(fc-pattern-add-weight pattern
+			       (fc-font-weight-translate-from-string weight)))
     (if size
-	(fc-pattern-add pattern fc-font-name-property-size size))
+	(fc-pattern-add-size pattern size))
     (if slant
-	(fc-pattern-add pattern fc-font-name-property-slant
-			 (fc-font-slant-translate-from-string slant)))
+	(fc-pattern-add-slant pattern
+			      (fc-font-slant-translate-from-string slant)))
     (make-font-instance (fc-name-unparse pattern))))
 
 (defun x-font-menu-load-font-core (family weight size slant resolution)
--- a/lwlib/ChangeLog	Sat Apr 22 21:51:52 2006 +0000
+++ b/lwlib/ChangeLog	Sun Apr 23 16:11:34 2006 +0000
@@ -1,3 +1,7 @@
+2006-04-22  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* lwlib-fonts.c: Rename xft-fonts.h to font-mgr.h.
+
 2006-03-31  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.5.26 "endive" is released.
--- a/lwlib/lwlib-fonts.c	Sat Apr 22 21:51:52 2006 +0000
+++ b/lwlib/lwlib-fonts.c	Sun Apr 23 16:11:34 2006 +0000
@@ -36,7 +36,7 @@
 #include "device.h"
 #include "device-impl.h"
 #include "console-x-impl.h"
-#include "xft-fonts.h"
+#include "font-mgr.h"
 #endif
 
 /*
--- a/man/ChangeLog	Sat Apr 22 21:51:52 2006 +0000
+++ b/man/ChangeLog	Sun Apr 23 16:11:34 2006 +0000
@@ -1,3 +1,8 @@
+2006-04-23  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* internals/internals.texi:  Run texinfo-master-menu.
+	(Creating a New Console/Device/Frame Type): New node.
+
 2006-03-31  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.5.26 "endive" is released.
--- a/man/internals/internals.texi	Sat Apr 22 21:51:52 2006 +0000
+++ b/man/internals/internals.texi	Sun Apr 23 16:11:34 2006 +0000
@@ -311,7 +311,7 @@
 * XEmacs from the Perspective of Building::  
 * Build-Time Dependencies::     
 * The Modules of XEmacs::       
-* The Build Configuration System::
+* The Build Configuration System::  
 * Rules When Writing New C Code::  
 * Regression Testing XEmacs::   
 * CVS Techniques::              
@@ -361,6 +361,7 @@
 The Modules of XEmacs
 
 * A Summary of the Various XEmacs Modules::  
+* Modules for Building XEmacs::  
 * Low-Level Modules::           
 * Basic Lisp Modules::          
 * Modules for Standard Editing Operations::  
@@ -368,6 +369,19 @@
 * Modules for Other Aspects of the Lisp Interpreter and Object System::  
 * Modules for Interfacing with the Operating System::  
 
+Modules for Building XEmacs
+
+* Modules for Build Configuration::  
+* Modules for Compiling XEmacs::  
+* Modules for Preloading Lisp::  
+
+The Build Configuration System
+
+* The version.sh Script::       
+* Adding Configurable Features::  
+* The configure Script::        
+* The Makefile Precursors::     
+
 Rules When Writing New C Code
 
 * Introduction to Writing C Code::  
@@ -393,7 +407,7 @@
 
 CVS Techniques
 
-* Creating a Branch::  
+* Creating a Branch::           
 * Merging a Branch into the Trunk::  
 
 Low-Level Allocation
@@ -471,12 +485,12 @@
 * Encodings::                   
 * Internal Mule Encodings::     
 * Byte/Character Types; Buffer Positions; Other Typedefs::  
-* Internal Text APIs::         
+* Internal Text APIs::          
 * Coding for Mule::             
 * CCL::                         
 * Microsoft Windows-Related Multilingual Issues::  
 * Modules for Internationalization::  
-* The Great Mule Merge of March 2002::
+* The Great Mule Merge of March 2002::  
 
 Encodings
 
@@ -525,18 +539,18 @@
 
 The Great Mule Merge of March 2002
 
-* List of changed files in new Mule workspace::
-* Changes to the MULE subsystems::
-* Pervasive changes throughout XEmacs sources::
-* Changes to specific subsystems::
-* Mule changes by theme::
-* File-coding rewrite::
-* General User-Visible Changes::
-* General Lisp-Visible Changes::
-* User documentation::
-* General internal changes::
-* Ben's TODO list::                                Probably obsolete.
-* Ben's README::                                   Probably obsolete.
+* List of changed files in new Mule workspace::  
+* Changes to the MULE subsystems::  
+* Pervasive changes throughout XEmacs sources::  
+* Changes to specific subsystems::  
+* Mule changes by theme::       
+* File-coding rewrite::         
+* General User-Visible Changes::  
+* General Lisp-Visible Changes::  
+* User documentation::          
+* General internal changes::    
+* Ben's TODO list::             Probably obsolete.
+* Ben's README::                Probably obsolete.
 
 Consoles; Devices; Frames; Windows
 
@@ -544,6 +558,7 @@
 * Point::                       
 * Window Hierarchy::            
 * The Window Object::           
+* Creating a New Console/Device/Frame Type::  
 * Modules for the Basic Displayable Lisp Objects::  
 
 The Redisplay Mechanism
@@ -595,7 +610,7 @@
 
 Subprocesses
 
-* Ben's separate stderr notes:: Probably obsolete.
+* Ben's separate stderr notes::  Probably obsolete.
 
 Interface to MS Windows
 
@@ -603,7 +618,7 @@
 * Windows Build Flags::         
 * Windows I18N Introduction::   
 * Modules for Interfacing with MS Windows::  
-* CHANGES from 21.4-windows branch::                  Probably obsolete.
+* CHANGES from 21.4-windows branch::  Probably obsolete.
 
 Interface to the X Window System
 
@@ -661,7 +676,7 @@
 * Future Work -- Display Tables::  
 * Future Work -- Making Elisp Function Calls Faster::  
 * Future Work -- Lisp Engine Replacement::  
-* Future Work -- Better Rendering Support::
+* Future Work -- Better Rendering Support::  
 
 Future Work -- Toolbars
 
@@ -697,6 +712,20 @@
 * Future Work -- Lisp Engine Replacement -- Implementation::  
 * Future Work -- Startup File Modification by Packages::  
 
+Future Work -- Better Rendering Support
+
+* Better Rendering Support -- Review Criteria::  
+* Better Rendering Support -- Implementation::  
+* Better Rendering Support -- Current Status::  
+* Better Rendering Support -- Configuration with the Interim Patches::  
+* Better Rendering Support -- Modern Font Support::  
+
+Better Rendering Support -- Modern Font Support
+
+* Modern Font Support -- Font Concepts::  GUI devices, fonts, glyphs, rendering.
+* Modern Font Support -- fontconfig::  Querying and selecting fonts.
+* Modern Font Support -- Xft::  Rendering fonts on X11.
+
 Future Work Discussion
 
 * Discussion -- Garbage Collection::  
@@ -2737,7 +2766,7 @@
 
 @menu
 * A Summary of the Various XEmacs Modules::  
-* Modules for Building XEmacs::       
+* Modules for Building XEmacs::  
 * Low-Level Modules::           
 * Basic Lisp Modules::          
 * Modules for Standard Editing Operations::  
@@ -3247,9 +3276,9 @@
 @cindex building XEmacs, modules for
 
 @menu
-* Modules for Build Configuration:: 
-* Modules for Compiling XEmacs:: 
-* Modules for Preloading Lisp:: 
+* Modules for Build Configuration::  
+* Modules for Compiling XEmacs::  
+* Modules for Preloading Lisp::  
 @end menu
 
 
@@ -3288,7 +3317,7 @@
 
 
 
-@node Modules for Preloading Lisp, , Modules for Compiling XEmacs, Modules for Building XEmacs
+@node Modules for Preloading Lisp,  , Modules for Compiling XEmacs, Modules for Building XEmacs
 @subsection Modules for Preloading Lisp
 @cindex modules for preloading lisp
 @cindex preloading lisp, modules for
@@ -4357,10 +4386,10 @@
 system.
 
 @menu
-* The version.sh Script::
+* The version.sh Script::       
 * Adding Configurable Features::  
-* The configure Script::  
-* The Makefile Precursors::  
+* The configure Script::        
+* The Makefile Precursors::     
 @end menu
 
 
@@ -4836,7 +4865,7 @@
 
 
 
-@node The Makefile Precursors, , The configure Script, The Build Configuration System
+@node The Makefile Precursors,  , The configure Script, The Build Configuration System
 @section The Makefile Precursors
 @cindex Makefile precursors
 @cindex precursors, Makefile
@@ -6603,7 +6632,7 @@
 @cindex CVS techniques
 
 @menu
-* Creating a Branch::  
+* Creating a Branch::           
 * Merging a Branch into the Trunk::  
 @end menu
 
@@ -10389,12 +10418,12 @@
 * Encodings::                   
 * Internal Mule Encodings::     
 * Byte/Character Types; Buffer Positions; Other Typedefs::  
-* Internal Text APIs::         
+* Internal Text APIs::          
 * Coding for Mule::             
 * CCL::                         
 * Microsoft Windows-Related Multilingual Issues::  
 * Modules for Internationalization::  
-* The Great Mule Merge of March 2002::
+* The Great Mule Merge of March 2002::  
 @end menu
 
 @node Introduction to Multilingual Issues #1, Introduction to Multilingual Issues #2, Multilingual Support, Multilingual Support
@@ -14102,7 +14131,7 @@
 prepended with an L (causing it to be a wide string) depending on
 XEUNICODE_P.
 
-@node Modules for Internationalization,  The Great Mule Merge of March 2002, Microsoft Windows-Related Multilingual Issues, Multilingual Support
+@node Modules for Internationalization, The Great Mule Merge of March 2002, Microsoft Windows-Related Multilingual Issues, Multilingual Support
 @section Modules for Internationalization
 @cindex modules for internationalization
 @cindex internationalization, modules for
@@ -14208,22 +14237,22 @@
 remains to be done.
 
 @menu
-* List of changed files in new Mule workspace::
-* Changes to the MULE subsystems::
-* Pervasive changes throughout XEmacs sources::
-* Changes to specific subsystems::
-* Mule changes by theme::
-* File-coding rewrite::
-* General User-Visible Changes::
-* General Lisp-Visible Changes::
-* User documentation::
-* General internal changes::
-* Ben's TODO list::                                Probably obsolete.
-* Ben's README::                                   Probably obsolete.
-@end menu
-
-
-@node List of changed files in new Mule workspace, Changes to the MULE subsystems, , The Great Mule Merge of March 2002
+* List of changed files in new Mule workspace::  
+* Changes to the MULE subsystems::  
+* Pervasive changes throughout XEmacs sources::  
+* Changes to specific subsystems::  
+* Mule changes by theme::       
+* File-coding rewrite::         
+* General User-Visible Changes::  
+* General Lisp-Visible Changes::  
+* User documentation::          
+* General internal changes::    
+* Ben's TODO list::             Probably obsolete.
+* Ben's README::                Probably obsolete.
+@end menu
+
+
+@node List of changed files in new Mule workspace, Changes to the MULE subsystems, The Great Mule Merge of March 2002, The Great Mule Merge of March 2002
 @subsection List of changed files in new Mule workspace
 
 This node lists the files that were touched in the Great Mule Merge.
@@ -15307,7 +15336,7 @@
 interrupt the same process, use the injection method.
 @end itemize
 
-@node Ben's README, , Ben's TODO list, The Great Mule Merge of March 2002
+@node Ben's README,  , Ben's TODO list, The Great Mule Merge of March 2002
 @subsection Ben's README (probably obsolete)
 
 These notes substantially overlap those in @ref{Ben's TODO list}.  They
@@ -17176,6 +17205,7 @@
 * Point::                       
 * Window Hierarchy::            
 * The Window Object::           
+* Creating a New Console/Device/Frame Type::  
 * Modules for the Basic Displayable Lisp Objects::  
 @end menu
 
@@ -17345,7 +17375,7 @@
 artifact that should be fixed.)
 @end enumerate
 
-@node The Window Object, Modules for the Basic Displayable Lisp Objects, Window Hierarchy, Consoles; Devices; Frames; Windows
+@node The Window Object, Creating a New Console/Device/Frame Type, Window Hierarchy, Consoles; Devices; Frames; Windows
 @section The Window Object
 @cindex window object, the
 @cindex object, the window
@@ -17452,7 +17482,144 @@
 this field is @code{nil}.
 @end table
 
-@node Modules for the Basic Displayable Lisp Objects,  , The Window Object, Consoles; Devices; Frames; Windows
+
+@node Creating a New Console/Device/Frame Type, Modules for the Basic Displayable Lisp Objects, The Window Object, Consoles; Devices; Frames; Windows
+@section Creating a New Console, Device, or Frame Type
+@cindex creating a new console type
+@cindex console type, creating a new
+@cindex creating a new device type
+@cindex device type, creating a new
+@cindex creating a new frame type
+@cindex frame type, creating a new
+
+Unfortunately, at the present time, only the console abstraction is at
+all well-maintained.  Device and frame internals are referred to from
+many places in the redisplay and console code.  The best that can be
+done therefore is to create a whole new console type, even though much
+code will be shared.  (Ben Wing has complained about the code
+duplication in the GTK+ v1 console, and probably would not be happy with
+the unpublished Qt console or Andrew Choi's Carbon console, but it's
+hard to see how those consoles could have been done better without
+fixing the abstractions in the X (actually Xt), MS Windows, and tty
+consoles as well as doing a complete refactoring of the console, device,
+and frame code.)
+
+What is desireable is sharing console, device, and frame methods across
+platforms in a more general way, reducing the amount of duplicated code
+by pulling it back into the redisplay engine proper or the Lisp modules
+as appropriate.  For example, we should be able to use
+@samp{make-frame-on-device} to share a single X connection among GTK, X,
+and Xft frames.  Xft is partially implemented, but GTK would be much
+harder (impossible?) because it has its own event loop.  (Xft shares the
+Xt event loop with the X console.)
+
+The way all methods get added to the console type is uncool.  A console
+should be a composite, which indicates a collection of I/O resources
+``used together.''  It should indicate where operations that change
+``focus'' search for targets, @emph{i.e.}, by default new frames are
+created on the selected device of the console where the input that
+invoked the command was received, @samp{pop-to-buffer-other-window} only
+considers existing windows on the same device of the same console,
+@emph{etc.}  But it should be possible to assemble consoles out of
+component input channels, imaging devices, and multimedia (audio)
+channels.
+
+The following notes may provide some guidance to those who wish to
+create new console types (@emph{i.e.}, port the redisplay code to a new
+platform).  They are based on an unsuccessful attempt to refactor the
+Xft code into a new console type while sharing most routines with the X
+console.  (For clarification or suggestions, feel free to write
+@email{stephen@@xemacs.org,Stephen Turnbull}.)
+
+The first thing to realize is that the naming of many modules obscures
+their relationship to the console abstraction.  For example, the
+@file{objects-@var{console-type}}, @file{redisplay-@var{console-type}},
+and @file{glyphs-@var{console-type}} series of modules have nothing to
+do with Lisp objects and little to do with redisplay, respectively.
+Rather they implement abstractions used for rendering on each console
+type, such as fonts and colors (@file{objects}) and string and graphics
+drawing primitives (@file{rendering}).  These modules are conceptually
+part of the console implementations, not part of redisplay or Lisp.
+
+Public methods of a console are implemented as C functions declared
+@code{static}, following a rigid naming convention:
+@samp{@var{console-type}_@var{method-name}}.  Methods are bound to the
+console type in the @samp{console_type_create_@var{file}} functions for
+each console component (console, device, and frame) using the
+@samp{CONSOLE_HAS_METHOD} family of macros.  Methods for displaying
+images are bound using the @samp{IIFORMAT_HAS_DEVMETHOD} family of
+macros.  Methods are invoked using the @samp{CONMETH}, @samp{DEVMETH},
+and @samp{FRAMEMETH} families of macros, which look up the relevant
+methods in the object's table of methods.
+
+@strong{N.B.} All of the object tables are actually references to
+console method tables.  To create a variant of an existing console,
+there is a @samp{CONSOLE_INHERITS_METHOD} constructor, but this actually
+constructs the name of the parent's method pointer and stores in the
+derived console type's method table.  Of course this is time-efficient,
+and since there are few console types it is a neglible waste of space.
+However in practice this may have contributed to breaking the various
+abstractions, and the variant console must be coded in the same file as
+the parent (because the methods are static).  Another minor symptom of
+the incompleteness of the abstraction is the fact that the API for
+inheritance of device methods for image formats is named
+@samp{IIFORMAT_HAS_SHARED_METHOD}, although the semantics are identical.
+
+One problem encountered in attempting to create an Xft console type as a
+derivative of the X console type was that there is no support for such
+union types in the consistency-checking code, whether for the
+fundamental Lisp consistency checks (the @samp{CHECK_SOMETHING} family
+of macros) or for the error-checking variants of many functions.  These
+APIs all simply check for the apparent console type, which is a single
+symbol (or enumerator).
+
+To create a new console with mostly new methods, it's probably best to
+copy all of the @file{@var{function}-@var{console-type}} files from a
+similar console (or several, if the new console type seems like a
+combination of several existing console types), renaming the files by
+substituting @var{new-console-type} for @var{console-type}.  Then
+proceed in the obvious way by renaming methods from
+@samp{@var{console-type}_@var{method-name}} to
+@samp{@var{new-console-type}_@var{method-name}}, and implementing them.
+
+Once you've done that, then the fun starts.  Insert the initialization
+functions (@samp{syms_of_@var{file}}, @samp{vars_of_@var{file}},
+@samp{console_type_create_@var{file}}, @emph{etc.}) in @samp{main_1} in
+@file{emacs.c}.
+
+Add a device creation function @samp{make-@var{console-type}-device} in
+@file{device.el}.  Add the device type to the calls to
+@samp{Face-frob-property} in @file{faces.el}, as well as calls to the
+device initializer functions for devices and frames, and ``additional
+frobbing'' in that file.
+
+You may wish to add an option to force the initial frame to that device
+type to @file{emacs.c}.  Don't forget to document it in the command help
+function in @file{startup.el}.
+
+You may need to add support for your console type in
+@samp{init_event_stream} in @file{event-stream.c}.
+
+If your console has a different UI for fonts or colors, or adds new
+capability, you may need to add a @file{@var{console-type}-faces.el}
+file, or add code to the @file{@var{parent-type}-faces.el} file, to
+support new font or color capability.  Probably initialization code in
+@file{faces.c} will be needed too.
+
+A check for the console type is probably needed in @samp{init_redisplay}
+in @file{redisplay.c}.
+
+Ditto for the @file{@var{console-type}-init.el} file.
+
+Don't forget that Emacs windows are console-dependent, too.  At least a
+@samp{WINDOW_@var{console-type}_P}-checking macro should be added in
+@file{window-impl.h}.
+
+Note that this project failed; there are probably many other details to
+be implemented that I didn't get to.  But don't let that stop you!
+
+
+@node Modules for the Basic Displayable Lisp Objects,  , Creating a New Console/Device/Frame Type, Consoles; Devices; Frames; Windows
 @section Modules for the Basic Displayable Lisp Objects
 @cindex modules for the basic displayable Lisp objects
 @cindex displayable Lisp objects, modules for the basic
@@ -17602,6 +17769,7 @@
 is part of the redisplay mechanism or the code for particular object
 types such as scrollbars.
 
+
 @node The Redisplay Mechanism, Extents, Consoles; Devices; Frames; Windows, Top
 @chapter The Redisplay Mechanism
 @cindex redisplay mechanism, the
@@ -20404,11 +20572,11 @@
 @end table
 
 @menu
-* Ben's separate stderr notes::                Probably obsolete.
-@end menu
-
-
-@node Ben's separate stderr notes, , , Subprocesses
+* Ben's separate stderr notes::  Probably obsolete.
+@end menu
+
+
+@node Ben's separate stderr notes,  , Subprocesses, Subprocesses
 @subsection Ben's separate stderr notes (probably obsolete)
 
 This node contains some notes that Ben kept on his separate subprocess
@@ -20449,7 +20617,7 @@
 * Windows Build Flags::         
 * Windows I18N Introduction::   
 * Modules for Interfacing with MS Windows::  
-* CHANGES from 21.4-windows branch::                  Probably obsolete.
+* CHANGES from 21.4-windows branch::  Probably obsolete.
 @end menu
 
 @node Different kinds of Windows environments, Windows Build Flags, Interface to MS Windows, Interface to MS Windows
@@ -20978,7 +21146,7 @@
 @end table
 
 
-@node CHANGES from 21.4-windows branch, , Modules for Interfacing with MS Windows, Interface to MS Windows
+@node CHANGES from 21.4-windows branch,  , Modules for Interfacing with MS Windows, Interface to MS Windows
 @section CHANGES from 21.4-windows branch (probably obsolete)
 
 This node contains the @file{CHANGES-msw} log that Andy Piper kept while
@@ -26741,7 +26909,7 @@
 
 @end itemize
 
-@node Future Work -- Lisp Engine Replacement,  Future Work -- Better Rendering Support, Future Work -- Making Elisp Function Calls Faster, Future Work
+@node Future Work -- Lisp Engine Replacement, Future Work -- Better Rendering Support, Future Work -- Making Elisp Function Calls Faster, Future Work
 @section Future Work -- Lisp Engine Replacement
 @cindex future work, lisp engine replacement
 @cindex lisp engine replacement, future work
@@ -27354,7 +27522,7 @@
 
 
 
-@node Future Work -- Better Rendering Support, , Future Work -- Lisp Engine Replacement,  Future Work
+@node Future Work -- Better Rendering Support,  , Future Work -- Lisp Engine Replacement, Future Work
 @section Future Work -- Better Rendering Support
 @cindex future work, better rendering support
 @cindex better rendering support, future work
@@ -27387,15 +27555,15 @@
 one may be made available for the Knauel-Matthias patch soon.
 
 @menu
-* Better Rendering Support -- Review Criteria::
-* Better Rendering Support -- Implementation::
-* Better Rendering Support -- Current Status::
-* Better Rendering Support -- Configuration with the Interim Patches::
-* Better Rendering Support -- Modern Font Support::
-@end menu
-
-
-@node Better Rendering Support -- Review Criteria, Better Rendering Support -- Implementation, , Future Work -- Better Rendering Support
+* Better Rendering Support -- Review Criteria::  
+* Better Rendering Support -- Implementation::  
+* Better Rendering Support -- Current Status::  
+* Better Rendering Support -- Configuration with the Interim Patches::  
+* Better Rendering Support -- Modern Font Support::  
+@end menu
+
+
+@node Better Rendering Support -- Review Criteria, Better Rendering Support -- Implementation, Future Work -- Better Rendering Support, Future Work -- Better Rendering Support
 @subsection Better Rendering Support -- Review Criteria
 @cindex better rendering support, issues
 @cindex issues, better rendering support
@@ -27738,7 +27906,7 @@
 
 
 
-@node Better Rendering Support -- Modern Font Support, , Better Rendering Support -- Configuration with the Interim Patches, Future Work -- Better Rendering Support
+@node Better Rendering Support -- Modern Font Support,  , Better Rendering Support -- Configuration with the Interim Patches, Future Work -- Better Rendering Support
 @subsection Better Rendering Support -- Modern Font Support
 
 @c Maybe eventually all these @cindexes should be spread about?
@@ -27784,12 +27952,12 @@
 available on all @file{fontconfig} systems.
 
 @menu
-* Modern Font Support -- Font Concepts:: GUI devices, fonts, glyphs, rendering.
-* Modern Font Support -- fontconfig::    Querying and selecting fonts.
-* Modern Font Support -- Xft::           Rendering fonts on X11.
-@end menu
-
-@node Modern Font Support -- Font Concepts, Modern Font Support -- fontconfig, , Better Rendering Support -- Modern Font Support
+* Modern Font Support -- Font Concepts::  GUI devices, fonts, glyphs, rendering.
+* Modern Font Support -- fontconfig::  Querying and selecting fonts.
+* Modern Font Support -- Xft::  Rendering fonts on X11.
+@end menu
+
+@node Modern Font Support -- Font Concepts, Modern Font Support -- fontconfig, Better Rendering Support -- Modern Font Support, Better Rendering Support -- Modern Font Support
 @subsubsection Modern Font Support -- Font Concepts
 
 In modern systems, displays are invariably @dfn{raster graphic devices},
@@ -28201,7 +28369,7 @@
 
 
 
-@node Modern Font Support -- Xft, , Modern Font Support -- fontconfig, Better Rendering Support -- Modern Font Support
+@node Modern Font Support -- Xft,  , Modern Font Support -- fontconfig, Better Rendering Support -- Modern Font Support
 @subsubsection Modern Font Support -- fontconfig
 
 IIRC, we don't really provide any @file{Xft} APIs at the LISP level yet.
--- a/src/ChangeLog	Sat Apr 22 21:51:52 2006 +0000
+++ b/src/ChangeLog	Sun Apr 23 16:11:34 2006 +0000
@@ -1,3 +1,36 @@
+2006-04-23  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* Makefile.in.in (x_objs): Change xft-fonts.o to font-mgr.o.
+
+2006-04-17  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* config.h.in: New symbol HAVE_FONTCONFIG.
+
+2006-04-22  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	Rename xft-fonts.{c,h} to font-mgr.{c,h}.
+
+	* font-mgr.c:
+	* emacs.c:
+	* symsinit.h:
+	(syms_of_font_mgr):
+	(vars_of_font_mgr):
+	(reinit_vars_of_font_mgr):
+	(complex_vars_of_font_mgr):
+	Renamed from *_xft_fonts versions.
+
+	* font-mgr.c:
+	* inline.c:
+	* objects-x.c:
+	Update #includes and comments to refer to font-mgr.h.
+	N.B. The feature provided by objects-x.c is still "xft-fonts",
+	which is separate from the font management by fontconfig (from
+	font-mgr.*).
+
+2006-04-15  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* console-x.h (<X11/Xft/Xft.h>): Don't cater to Xft v.1.
+
 2006-04-17  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* unicode.c: Improve comment on to/from_unicode table design.
--- a/src/Makefile.in.in	Sat Apr 22 21:51:52 2006 +0000
+++ b/src/Makefile.in.in	Sun Apr 23 16:11:34 2006 +0000
@@ -134,7 +134,7 @@
 x_objs=console-x.o device-x.o event-Xt.o frame-x.o \
  glyphs-x.o objects-x.o redisplay-x.o select-x.o xgccache.o intl-x.o
 #ifdef USE_XFT
-x_objs += xft-fonts.o
+x_objs += font-mgr.o
 #endif
 x_gui_objs=$(gui_objs:.o=-x.o)
 #ifdef HAVE_TOOLBARS
--- a/src/config.h.in	Sat Apr 22 21:51:52 2006 +0000
+++ b/src/config.h.in	Sun Apr 23 16:11:34 2006 +0000
@@ -206,6 +206,9 @@
 /* Compile in support for the X window system? */
 #undef HAVE_X_WINDOWS
 
+/* Compile with support for fontconfig? */
+#undef HAVE_FONTCONFIG
+
 /* Compile with support for Xft? */
 #undef USE_XFT
 /* Per-widget stuff will go away? */
--- a/src/console-x.h	Sat Apr 22 21:51:52 2006 +0000
+++ b/src/console-x.h	Sun Apr 23 16:11:34 2006 +0000
@@ -58,10 +58,6 @@
 #include <X11/Xft/Xft.h>
 #undef glyph_index
 #undef face_index
-/* #### this should be made gone */
-#ifndef XFT_VERSION
-#define XFT_VERSION 1
-#endif
 #endif
 
 /* R5 defines the XPointer type, but R4 doesn't.
--- a/src/emacs.c	Sat Apr 22 21:51:52 2006 +0000
+++ b/src/emacs.c	Sun Apr 23 16:11:34 2006 +0000
@@ -1620,7 +1620,7 @@
 #endif /* HAVE_XIM */
 
 #ifdef USE_XFT
-      syms_of_xft_fonts();
+      syms_of_font_mgr();
 #endif
 
 #endif /* HAVE_X_WINDOWS */
@@ -2205,7 +2205,7 @@
 #endif
 
 #ifdef USE_XFT
-      vars_of_xft_fonts ();
+      vars_of_font_mgr ();
 #endif
 
 #endif /* HAVE_X_WINDOWS */
@@ -2335,7 +2335,7 @@
       reinit_vars_of_gui_x ();
 #endif
 #ifdef USE_XFT
-      reinit_vars_of_xft_fonts ();
+      reinit_vars_of_font_mgr ();
 #endif
 #endif /* HAVE_X_WINDOWS */
 
@@ -2407,7 +2407,7 @@
 #ifdef USE_XFT
       /* This uses coding systems.  Must be done before faces are init'ed. */
       /* not in xft reloaded #3 */
-      complex_vars_of_xft_fonts ();
+      complex_vars_of_font_mgr ();
 #endif
 
       /* Depends on specifiers. */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/font-mgr.c	Sun Apr 23 16:11:34 2006 +0000
@@ -0,0 +1,806 @@
+/* Lisp font handling implementation for X with Xft.
+
+Copyright (C) 2003 Eric Knauel and Matthias Neubauer
+Copyright (C) 2005 Eric Knauel
+Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+Authors:	Eric Knauel <knauel@informatik.uni-tuebingen.de>
+		Matthias Neubauer <neubauer@informatik.uni-freiburg.de>
+		Stephen J. Turnbull <stephen@xemacs.org>
+Created:	27 Oct 2003
+Updated:	05 Mar 2005 by Stephen J. Turnbull
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in GNU Emacs. */
+
+/* This module provides the Lisp interface to fonts in X11, including Xft,
+   but (at least at first) not GTK+ or Qt.
+
+   It should be renamed to fonts-x.h.
+
+   Sealevel code should be in ../lwlib/lwlib-fonts.c or
+   ../lwlib/lwlib-colors.c.
+*/
+
+#include <config.h>
+#include "lisp.h"
+#include "device.h"
+#include "device-impl.h"
+#include "console-x-impl.h"
+#include "objects-x.h"
+#include "objects-x-impl.h"
+#include "hash.h"
+#include "font-mgr.h"
+
+/* #### TO DO ####
+   . The "x-xft-*" and "x_xft_*" nomenclature is mostly redundant, especially
+     if we separate X fonts from Xft fonts, and use fontconfig more generally.
+   . We should support the most recent Xft first, old Xft libraries later.
+   . We may (think about it) wish to use fontconfig generally, even if we're
+     not using Xft.  Either way, names that are really from fontconfig should
+     use the Fc* namespace.
+   . Mule-ize this file.
+   . Separate X Font Struct ops from Xft Font ops; give precedence to Xft but
+     allow fallback to X.
+   . Push decisions about font choice, defaults, fallbacks to Lisp; if we
+     really need efficiency, can reimplement in C later.
+   . Implement symbols interned in this file in the Q* namespace.
+   . Implement FcMatrix (Lisp vector).
+   . Implement FcCharSets (Lisp chartable?  For implementation hints, see
+     FcCharSetFirstPage and FcCharSetNextPage).
+   . Implement FcConfigs.
+   DONE
+   . Fontconfig fontnames are encoded in UTF-8.
+*/
+
+Lisp_Object Qxft_font;
+Lisp_Object Qfc_patternp;
+Lisp_Object Qfc_fontsetp;
+/* Lisp_Object Qfc_result_match; */ 	/* FcResultMatch */
+Lisp_Object Qfc_result_type_mismatch;	/* FcResultTypeMismatch */
+Lisp_Object Qfc_result_no_match; 	/* FcResultNoMatch */
+Lisp_Object Qfc_result_no_id;		/* FcResultNoId */
+Lisp_Object Qfc_internal_error;
+Lisp_Object Vxlfd_font_name_regexp;	/* #### Really needed? */
+Lisp_Object Vxft_version;
+/* Lisp_Object Vfc_version; */		/* #### Should have this, too! */
+Fixnum debug_xft;		/* Set to 1 enables lots of obnoxious messages.
+				   Setting it to 2 or 3 enables even more. */
+
+/****************************************************************
+*                       FcPattern objects                       *
+****************************************************************/
+
+static void
+finalize_fc_pattern (void *header, int UNUSED (for_disksave))
+{
+  struct fc_pattern *p = (struct fc_pattern *) header;
+  if (p->fcpatPtr)
+    {
+      FcPatternDestroy (p->fcpatPtr);
+      p->fcpatPtr = 0;
+    }
+}
+
+static const struct memory_description fcpattern_description [] = {
+  /* #### nothing here, is this right?? */
+  { XD_END }
+};
+
+DEFINE_LRECORD_IMPLEMENTATION("fc-pattern", fc_pattern,
+			      0, 0, 0, finalize_fc_pattern, 0, 0,
+			      fcpattern_description,
+			      struct fc_pattern);
+
+/*
+ * Helper Functions
+ */
+static Lisp_Object make_xlfd_font_regexp (void);
+static void string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os);
+
+/* 
+   extract the C representation of the Lisp string STR and convert it
+   to the encoding used by the Fontconfig API for property and font
+   names.  I suppose that Qnative is the right encoding, the manual
+   doesn't say much about this topic.  This functions assumes that STR
+   is a Lisp string.
+*/
+#define extract_fcapi_string(str) \
+  ((FcChar8 *) NEW_LISP_STRING_TO_EXTERNAL ((str), Qnative))
+
+/* fontconfig assumes that objects (property names) are statically allocated,
+   and you will get bizarre results if you pass Lisp string data or strings
+   allocated on the stack as objects.  fontconfig _does_ copy values, so we
+   (I hope) don't have to worry about that member.
+
+   Probably these functions don't get called so often that the memory leak
+   due to strdup'ing every time we add a property would matter, but XEmacs
+   _is_ a long-running process.  So we hash them.
+
+   I suspect that using symbol names or even keywords does not provide
+   assurance that the string won't move in memory.  So we hash them
+   ourselves; hash.c hashtables do not interpret the value pointers. */
+static FcChar8 *fc_standard_properties[] = {
+  "antialias", "aspect", "autohint", "charset", "dpi", "family", "file",
+  "foundry", "ftface", "globaladvance", "hinting", "index", "lang",
+  "minspace", "outline", "pixelsize", "rasterizer", "rgba", "scalable",
+  "scale", "size", "slant", "spacing", "style", "verticallayout", "weight",
+  /* obsolete after Xft v. 1 */
+  "charwidth", "charheight", "core", "encoding", "render"
+};
+
+static struct hash_table *fc_property_name_hash_table;
+
+/* #### Maybe fc_intern should be exposed to LISP?  The idea is that
+   fc-pattern-add could warn or error if the property isn't interned. */
+
+static FcChar8 *
+fc_intern (Lisp_Object property)
+{
+  const void *dummy;
+  FcChar8 *prop = extract_fcapi_string (property);
+  const void *val = gethash (prop, fc_property_name_hash_table, &dummy);
+
+  /* extract_fcapi_string returns something alloca'd
+     so we can just drop the old value of prop on the floor */
+  if (val)
+    prop = (FcChar8 *) val;
+  else
+    {
+      prop = FcStrCopy (prop);
+      puthash (prop, NULL, fc_property_name_hash_table);
+    }
+  return prop;
+}
+
+DEFUN("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /*
+Returns t if OBJECT is of type fc-pattern, nil otherwise.
+*/
+      (object))
+{
+  return FCPATTERNP(object) ? Qt : Qnil;
+}
+
+DEFUN("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /* 
+Return a new, empty fc-pattern object.
+*/
+      ())
+{
+  fc_pattern *fcpat =
+    ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
+
+  fcpat->fcpatPtr = FcPatternCreate();
+  return wrap_fcpattern(fcpat);
+}
+
+DEFUN("fc-name-parse", Ffc_name_parse, 1, 1, 0, /*
+Parse an Fc font name and return its representation as a fc pattern object.
+*/
+      (name))
+{
+  struct fc_pattern *fcpat =
+    ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
+
+  CHECK_STRING(name);		/* #### MEMORY LEAK!!  maybe not ... */
+
+  fcpat->fcpatPtr = FcNameParse (extract_fcapi_string (name));
+  return wrap_fcpattern(fcpat);
+}
+
+/* #### Ga-a-ack!  Xft's similar function is actually a different API.
+   We provide both. */
+DEFUN("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /*
+Unparse an fc pattern object to a string.
+*/
+      (pattern))
+{
+  CHECK_FCPATTERN(pattern);
+  {
+  FcChar8 *temp = FcNameUnparse(XFCPATTERN_PTR(pattern));
+  Lisp_Object res = build_ext_string (temp, Qxft_font_name_encoding);
+  free (temp);
+  return res;
+  }
+}
+
+DEFUN("fc-pattern-duplicate", Ffc_pattern_duplicate, 1, 1, 0, /* 
+Make a copy of the fc pattern object PATTERN and return it.
+*/
+      (pattern))
+{
+  struct fc_pattern *copy = NULL;
+  CHECK_FCPATTERN(pattern);
+
+  copy = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
+  copy->fcpatPtr = FcPatternDuplicate(XFCPATTERN_PTR(pattern));
+  return wrap_fcpattern(copy);
+}
+
+DEFUN("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /*
+Add attributes to the pattern object PATTERN.  PROPERTY is a string naming
+the attribute to add, VALUE the value for this attribute.
+
+VALUE may be a string, integer, float, or symbol, in which case the value
+will be added as an FcChar8[], int, double, or FcBool respectively.
+*/
+      (pattern, property, value))
+{
+  Bool res = 0;
+  Extbyte *obj;
+  FcPattern *fcpat;
+
+  CHECK_FCPATTERN(pattern);
+  CHECK_STRING(property);
+
+  obj = fc_intern (property);
+  fcpat = XFCPATTERN_PTR (pattern);
+
+  if (STRINGP(value)) 
+    {
+      FcChar8 *str = (FcChar8 *) extract_fcapi_string (value);
+      res = FcPatternAddString (fcpat, obj, str);
+    }
+  else if (INTP(value)) 
+    {
+      res = FcPatternAddInteger (fcpat, obj, XINT(value));
+    }
+  else if (FLOATP(value)) 
+    {
+      res = FcPatternAddDouble (fcpat, obj, (double) XFLOAT_DATA(value));
+    }
+  else if (SYMBOLP(value)) 
+    {
+      res = FcPatternAddBool (fcpat, obj, !NILP(value));
+    }
+  /* else ... maybe we should wta here? */
+
+  return res ? Qt : Qnil;
+}
+
+DEFUN("fc-pattern-del", Ffc_pattern_del, 2, 2, 0, /*
+Remove attribute PROPERTY from fc pattern object OBJECT.
+*/
+      (pattern, property))
+{
+  Bool res;
+
+  CHECK_FCPATTERN(pattern);
+  CHECK_STRING(property);
+
+  res = FcPatternDel(XFCPATTERN_PTR(pattern), 
+		     extract_fcapi_string (property));
+  return res ? Qt : Qnil;
+}
+
+/* Generic interface to FcPatternGet()
+ * Don't support the losing symbol-for-property interface.
+ */
+DEFUN("fc-pattern-get", Ffc_pattern_get, 2, 4, 0, /*
+From PATTERN, extract PROPERTY for the ID'th member, of type TYPE.
+
+PATTERN is an Xft (fontconfig) pattern object.
+PROPERTY is a string naming an fontconfig font property.
+Optional ID is a nonnegative integer indexing the list of values for PROPERTY
+  stored in PATTERN, defaulting to 0 (the first value).
+Optional TYPE is a symbol, one of 'string, 'boolean, 'integer, 'float,
+  'double, 'matrix, 'charset, or 'void, corresponding to the FcValue types.
+  ('float is an alias for 'double).
+
+The Lisp types returned will conform to TYPE:
+  string		string
+  boolean		`t' or `nil'
+  integer		integer
+  double (float)	float
+  matrix		not implemented
+  charset		not implemented
+  void			not implemented
+
+Symbols with names of the form "fc-result-DESCRIPTION" are returned when
+the desired value is not available.  These are
+
+  fc-result-type-mismatch       the value found has an unexpected type
+  fc-result-no-match            there is no such attribute
+  fc-result-no-id               there is no value for the requested ID
+
+The types of the following standard properties are predefined by fontconfig.
+The symbol 'fc-result-type-mismatch will be returned if the object exists but
+TYPE does not match the predefined type.  It is best not to specify a type
+for predefined properties, as a mistake here ensures error returns on the
+correct type.
+
+Each standard property has a convenience accessor defined in fontconfig.el,
+named in the form "fc-pattern-get-PROPERTY".  The convenience functions are
+preferred to `fc-pattern-get' since a typo in the string naming a property
+will result in a silent null return, while a typo in a function name will
+usually result in a compiler or runtime \"not fboundp\" error.  You may use
+`defsubst' to define convenience functions for non-standard properties.
+
+family         String  Font family name 
+style          String  Font style. Overrides weight and slant 
+slant          Int     Italic, oblique or roman 
+weight         Int     Light, medium, demibold, bold or black 
+size           Double  Point size 
+aspect         Double  Stretches glyphs horizontally before hinting 
+pixelsize      Double  Pixel size 
+spacing        Int     Proportional, monospace or charcell 
+foundry        String  Font foundry name 
+antialias      Bool    Whether glyphs can be antialiased 
+hinting        Bool    Whether the rasterizer should use hinting 
+verticallayout Bool    Use vertical layout 
+autohint       Bool    Use autohinter instead of normal hinter 
+globaladvance  Bool    Use font global advance data 
+file           String  The filename holding the font 
+index          Int     The index of the font within the file 
+ftface         FT_Face Use the specified FreeType face object 
+rasterizer     String  Which rasterizer is in use 
+outline        Bool    Whether the glyphs are outlines 
+scalable       Bool    Whether glyphs can be scaled 
+scale          Double  Scale factor for point->pixel conversions 
+dpi            Double  Target dots per inch 
+rgba           Int     unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry 
+minspace       Bool    Eliminate leading from line spacing 
+charset        CharSet Unicode chars encoded by the font 
+lang           String  List of RFC-3066-style languages this font supports
+
+The FT_Face, Matrix, CharSet types are unimplemented, so the corresponding
+properties are not accessible from Lisp at this time.  If the value of a
+property returned has type FT_Face, FcCharSet, or FcMatrix,
+`fc-result-type-mismatch' is returned.
+
+The following properties which were standard in Xft v.1 are obsolete in
+Xft v.2:  encoding, charwidth, charheight, core, and render. */
+      (pattern, property, id, type))
+{
+  FcChar8 *fc_property;		/* UExtbyte * */
+  FcResult fc_result;
+  FcValue fc_value;
+
+  /*
+    process arguments
+  */
+  CHECK_FCPATTERN (pattern);
+
+#if 0
+  /* Don't support the losing symbol-for-property interface. */
+  property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property;
+#endif
+  if (STRINGP (property))
+    {
+      fc_property = (FcChar8 *) extract_fcapi_string (property);
+    }
+  else
+    {
+      /* if we allow symbols, this would need to be
+	 list3 (Qlambda, list1 (Qobject),
+		  list3 (Qor, list2 (Qstringp, Qobject),
+			      list2 (Qsymbolp, Qobject)))
+	 or something like that? */
+      dead_wrong_type_argument (Qstringp, property);
+    }
+
+  if (!NILP (id)) CHECK_NATNUM (id);
+  if (!NILP (type)) CHECK_SYMBOL (type);
+
+  /* get property */
+  fc_result = FcPatternGet (XFCPATTERN_PTR (pattern),
+			    fc_property,
+			    NILP (id) ? 0 : XINT(id),
+			    &fc_value);
+
+  switch (fc_result)
+    {
+    case FcResultMatch:
+      /* wrap it and return */
+      switch (fc_value.type)
+	{
+	case FcTypeInteger:
+	  return ((!NILP (type) && !EQ (type, Qinteger))
+		  ? Qfc_result_type_mismatch : make_int (fc_value.u.i));
+	case FcTypeDouble:
+	  return ((!NILP (type) && !EQ (type, intern ("double"))
+		   && !EQ (type, Qfloat))
+		  ? Qfc_result_type_mismatch : make_float (fc_value.u.d));
+	case FcTypeString:
+	  return ((!NILP (type) && !EQ (type, Qstring))
+		  ? Qfc_result_type_mismatch
+		  : build_ext_string (fc_value.u.s, Qxft_font_name_encoding));
+	case FcTypeBool:
+	  return ((!NILP (type) && !EQ (type, Qboolean))
+		  ? Qfc_result_type_mismatch : fc_value.u.b ? Qt : Qnil);
+	case FcTypeMatrix:
+	  return Qfc_result_type_mismatch;
+	  /* #### unimplemented
+	  return ((!NILP (type) && !EQ (type, intern ("matrix")))
+		  ? Qfc_result_type_mismatch : make_int (fc_value.u.m));
+	  */
+	case FcTypeCharSet:
+	  return Qfc_result_type_mismatch;
+	  /* #### unimplemented
+	  return ((!NILP (type) && !EQ (type, intern ("charset")))
+		  ? Qfc_result_type_mismatch : make_int (fc_value.u.c));
+	  */
+	}
+    case FcResultTypeMismatch:
+      return Qfc_result_type_mismatch;
+    case FcResultNoMatch:
+      return Qfc_result_no_match;
+    case FcResultNoId:
+      return Qfc_result_no_id;
+    default:
+      return Qfc_internal_error;
+    }
+}
+
+DEFUN("fc-font-match", Ffc_font_match, 2, 2, 0, /*
+Return the font on DEVICE that most closely matches PATTERN.
+
+DEVICE is an X11 device.
+PATTERN is a fontconfig pattern object.
+Returns a fontconfig pattern object representing the closest match to the
+given pattern, or an error code.  Possible error codes are
+`fc-result-no-match' and `fc-result-no-id'. */
+      (device, pattern))
+{
+  Display *dpy;
+  FcResult res;
+
+  struct fc_pattern *res_fcpat =
+    ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
+  CHECK_FCPATTERN(pattern);	/* #### MEMORY LEAKS!!! */
+  if (NILP(device))
+    return Qnil;
+  CHECK_X_DEVICE(device);
+  if (!DEVICE_LIVE_P(XDEVICE(device)))
+    return Qnil;
+
+  dpy = DEVICE_X_DISPLAY(XDEVICE(device));
+  /* More Xft vs fontconfig brain damage? */
+  res_fcpat->fcpatPtr = XftFontMatch(dpy, DefaultScreen (dpy),
+				     XFCPATTERN_PTR(pattern), &res);
+  
+  if (res_fcpat->fcpatPtr == NULL)
+    switch (res) {
+    case FcResultNoMatch:
+      return Qfc_result_no_match;
+    case FcResultNoId:
+      return Qfc_result_no_id;
+    default:
+      return Qfc_internal_error;
+    }
+  else
+    return wrap_fcpattern(res_fcpat);
+}
+
+/* NOTE NOTE NOTE This function destroys the FcFontSet passed to it. */
+static Lisp_Object
+fontset_to_list (FcFontSet *fontset)
+{
+  int idx;
+  Lisp_Object fontlist = Qnil;
+  fc_pattern *fcpat;
+
+  /* #### improve this error message */
+  if (!fontset)
+    Fsignal (Qinvalid_state,
+	     list1 (build_string ("failed to create FcFontSet")));
+  for (idx = 0; idx < fontset->nfont; ++idx)
+    {
+      fcpat = 
+	ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
+      fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]);
+      fontlist = Fcons (wrap_fcpattern(fcpat), fontlist);
+    }
+  FcFontSetDestroy (fontset);
+  return fontlist;
+}
+
+/* #### fix this name to correspond to Ben's new nomenclature */
+DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects,
+      3, 3, 0, /*
+Return a list of fonts on DEVICE that match PATTERN for PROPERTIES.
+Each font is represented by a fontconfig pattern object.
+
+DEVICE is an X11 device.
+PATTERN is a fontconfig pattern to be matched.
+PROPERTIES is a list of property names (strings) that should match.
+
+#### DEVICE is unused, ignored, and may be removed if it's not needed to
+match other font-listing APIs. */
+      (UNUSED (device), pattern, properties))
+{
+  FcObjectSet *os;
+  FcFontSet *fontset;
+
+  CHECK_FCPATTERN (pattern);
+  CHECK_LIST (properties);
+
+  os = FcObjectSetCreate ();
+  string_list_to_fcobjectset (properties, os);
+  /* #### why don't we need to do the "usual substitutions"? */
+  fontset = FcFontList (NULL, XFCPATTERN_PTR (pattern), os);
+  FcObjectSetDestroy (os);
+
+  return fontset_to_list (fontset);
+
+}
+
+/* #### maybe this can/should be folded into fc-list-fonts-pattern-objects? */
+DEFUN("fc-font-sort", Ffc_font_sort, 2, 4, 0, /*
+Return a list of all fonts sorted by proximity to PATTERN.
+Each font is represented by a fontconfig pattern object.
+
+DEVICE is an X11 device.
+PATTERN is a fontconfig pattern to be matched.
+Optional argument TRIM, if non-nil, means to trim trailing fonts that do not
+contribute new characters to the union repertoire.
+
+#### Optional argument NOSUB, if non-nil, suppresses some of the usual
+property substitutions.  DON'T USE THIS in production code, it is intended
+for exploring behavior of fontconfig and will be removed when this code is
+stable.
+
+#### DEVICE is unused, ignored, and may be removed if it's not needed to
+match other font-listing APIs. */
+      (UNUSED (device), pattern, trim, nosub))
+{
+  CHECK_FCPATTERN (pattern);
+
+  {
+    FcConfig *fcc = FcConfigGetCurrent();
+    FcFontSet *fontset;
+    FcPattern *p = XFCPATTERN_PTR (pattern);
+    FcResult fcresult;
+
+    if (NILP(nosub))		/* #### temporary debug hack */
+      FcDefaultSubstitute (p);
+    FcConfigSubstitute (fcc, p, FcMatchPattern);
+    fontset = FcFontSort (fcc, p, !NILP(trim), NULL, &fcresult);
+
+    return fontset_to_list (fontset);
+  }
+}
+
+/* #### this actually is an Xft function, should split those out
+   or get rid of them entirely? */
+/* #### be consistent about argument order. */
+DEFUN("fc-font-real-pattern", Ffc_font_real_pattern, 2, 2, 0, /*
+Temporarily open FONTNAME (a string) and return the actual
+fc pattern matched by the Fc library.	*/
+      (fontname, xdevice))
+{
+  FcPattern *copy;
+  Display *dpy;
+  XftFont *font;
+  struct fc_pattern *fcpat =
+    ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
+
+  CHECK_STRING (fontname);	/* #### MEMORY LEAK?!  maybe not ... */
+  if (NILP(xdevice))
+    return Qnil;
+  CHECK_X_DEVICE (xdevice);
+  if (!DEVICE_LIVE_P(XDEVICE(xdevice)))
+    return Qnil;
+
+  /* #### these gymnastics should be unnecessary, just use FcFontMatch */
+  dpy = DEVICE_X_DISPLAY (XDEVICE (xdevice));
+  font = XftFontOpenName (dpy, DefaultScreen(dpy),
+			  extract_fcapi_string (fontname));
+  if (font == NULL)
+    return Qnil;
+  copy = FcPatternDuplicate(font->pattern);
+  XftFontClose(dpy, font);  
+  if (copy == NULL)
+    return Qnil;
+  fcpat->fcpatPtr = copy;
+  return wrap_fcpattern(fcpat);
+}
+
+DEFUN("xlfd-font-name-p", Fxlfd_font_name_p, 1, 1, 0, /*
+Check whether the string FONTNAME is a XLFD font name. */
+      (fontname))
+{
+  CHECK_STRING(fontname);
+  /* #### should bind `case-fold-search' here? */
+  return Fstring_match(Vxlfd_font_name_regexp, fontname, Qnil, Qnil);
+}
+
+/* FcPatternPrint: there is no point in having wrappers fc-pattern-print,
+   Ffc_pattern_print since this function prints to stdout. */
+
+/* Initialization of font-mgr */
+
+#define XE_XLFD_SEPARATOR	"-"
+      /* XLFD specifies ISO 8859-1 encoding, but we can't handle non-ASCII
+	 in Mule when this function is called.  So use HPC. */
+#if 0
+#define XE_XLFD_PREFIX		"\\(\\+[\040-\176\240-\377]*\\)?-"
+#define XE_XLFD_OPT_TEXT	"\\([\040-\044\046-\176\240-\377]*\\)"
+#define XE_XLFD_TEXT		"\\([\040-\044\046-\176\240-\377]+\\)"
+#else
+#define XE_XLFD_PREFIX		"\\(\\+[\040-\176]*\\)?-"
+#define XE_XLFD_OPT_TEXT	"\\([^-]*\\)"
+#define XE_XLFD_TEXT		"\\([^-]+\\)"
+#endif
+
+#define XE_XLFD_SLANT		"\\([0-9ior?*][iot]?\\)"
+#define XE_XLFD_SPACING		"\\([cmp?*]\\)"
+      /* Hyphen as minus conflicts with use as separator. */
+#define XE_XLFD_OPT_NEGATE      "~?"
+#define XE_XLFD_NUMBER		"\\([0-9?*]+\\)"
+#define XE_XLFD_PSIZE		"\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)"
+  
+/* Call this only from the init code
+   #### This is really horrible, let's get rid of it, please. */
+static Lisp_Object
+make_xlfd_font_regexp (void)
+{
+  struct gcpro gcpro1;
+  unsigned i;
+  Lisp_Object reg = Qnil;
+  const Extbyte *re[] = 	/* #### This could just be catenated by
+				   cpp and passed to build_ext_string. */
+    {
+      /* Regular expression matching XLFDs as defined by XLFD v. 1.5.
+	 Matches must be case-insensitive.
+	 PSIZE is a pixel or point size, which may be a "matrix".  The
+	 syntax of a matrix is not checked, just some lexical properties.
+	 AFAICT none of the TEXT fields except adstyle is optional.
+
+	 NB. It should not be a problem if this matches "too much", since
+	 an "old" server will simply not be able to find a matching font. */
+      "\\`",
+      XE_XLFD_PREFIX,		/* prefix */
+      XE_XLFD_TEXT,		/* foundry */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_TEXT,		/* family */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_TEXT,		/* weight */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_SLANT,		/* slant */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_TEXT,		/* swidth */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_OPT_TEXT,		/* adstyle */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_PSIZE,		/* pixelsize */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_PSIZE,		/* pointsize */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_NUMBER,		/* resx */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_NUMBER,		/* resy */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_SPACING,		/* spacing */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_OPT_NEGATE,	/* avgwidth */
+      XE_XLFD_NUMBER,
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_TEXT,		/* registry */
+      XE_XLFD_SEPARATOR,
+      XE_XLFD_TEXT,		/* encoding */
+      "\\'"
+    };
+  
+  GCPRO1 (reg);  
+  for (i = 0; i < sizeof(re)/sizeof(Extbyte *); i++)
+    {
+      /* #### Currently this is Host Portable Coding, not ISO 8859-1. */
+      reg = concat2(reg, build_ext_string (re[i], Qx_font_name_encoding));
+    }
+
+  RETURN_UNGCPRO (reg);
+}
+#undef XE_XLFD_SEPARATOR
+#undef XE_XLFD_PREFIX
+#undef XE_XLFD_OPT_TEXT
+#undef XE_XLFD_TEXT
+#undef XE_XLFD_OPT_SLANT
+#undef XE_XLFD_OPT_SPACING
+#undef XE_XLFD_OPT_NEGATE
+#undef XE_XLFD_NUMBER
+#undef XE_XLFD_PSIZE
+
+#define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
+		   ? ((unsigned long) (x)) : ((unsigned long) (y)))
+
+static void 
+string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os)
+{
+  EXTERNAL_LIST_LOOP_2 (elt, list)
+    {
+      FcChar8 *s;
+
+      CHECK_STRING (elt);
+      s = fc_intern (elt);
+      fprintf (stderr, "%s\n", s);
+      FcObjectSetAdd (os, s);
+    }
+}
+
+void
+syms_of_font_mgr (void)
+{
+  INIT_LRECORD_IMPLEMENTATION(fc_pattern);
+
+  DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp);
+
+  DEFSYMBOL(Qfc_result_type_mismatch);
+  DEFSYMBOL(Qfc_result_no_match);
+  DEFSYMBOL(Qfc_result_no_id);
+  DEFSYMBOL(Qfc_internal_error);
+  DEFSYMBOL(Qxft_font);
+
+  DEFSUBR(Ffc_pattern_p);
+  DEFSUBR(Ffc_pattern_create);
+  DEFSUBR(Ffc_name_parse);
+  DEFSUBR(Ffc_name_unparse);
+  DEFSUBR(Ffc_pattern_duplicate);
+  DEFSUBR(Ffc_pattern_add);
+  DEFSUBR(Ffc_pattern_del);
+  DEFSUBR(Ffc_pattern_get);
+  DEFSUBR(Ffc_list_fonts_pattern_objects);
+  DEFSUBR(Ffc_font_sort);
+  DEFSUBR(Ffc_font_match);
+  DEFSUBR(Ffc_font_real_pattern);
+  DEFSUBR(Fxlfd_font_name_p);
+}
+
+void
+vars_of_font_mgr (void)
+{
+  /* #### These two variables need to go somewhere else. */
+
+  /* #### I know, but the right fix is use the generic debug facility. */
+  DEFVAR_INT ("xft-debug-level", &debug_xft /*
+Level of debugging messages to issue to stderr for Xft.
+A nonnegative integer.  Set to 0 to suppress all warnings.
+Default is 1 to ensure a minimum of debugging output at initialization.
+Higher levels give even more information.
+*/ );
+  debug_xft = 1;
+
+  DEFVAR_LISP("xft-version", &Vxft_version /*
+The major version number of the Xft library being used.
+*/ );
+  Vxft_version = make_int(XFT_VERSION);
+
+  Fprovide (intern ("xft"));
+}
+
+void
+complex_vars_of_font_mgr (void)
+{
+  DEFVAR_LISP("xft-xlfd-font-regexp", &Vxlfd_font_name_regexp /*
+The regular expression used to match XLFD font names. */			       
+	      );
+  Vxlfd_font_name_regexp = make_xlfd_font_regexp();
+}
+
+void
+reinit_vars_of_font_mgr (void)
+{
+  int i, size = (int) countof (fc_standard_properties);
+  
+  FcInit ();
+
+  fc_property_name_hash_table = make_string_hash_table (size);
+  for (i = 0; i < size; ++i)
+    puthash (fc_standard_properties[i], NULL, fc_property_name_hash_table);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/font-mgr.h	Sun Apr 23 16:11:34 2006 +0000
@@ -0,0 +1,71 @@
+/* Lisp font data structures for X and Xft.
+
+Copyright (C) 2003 Eric Knauel and Matthias Neubauer
+Copyright (C) 2005 Eric Knauel
+Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+
+Authors:	Eric Knauel <knauel@informatik.uni-tuebingen.de>
+		Matthias Neubauer <neubauer@informatik.uni-freiburg.de>
+		Stephen J. Turnbull <stephen@xemacs.org>
+Created:	27 Oct 2003
+Updated:	05 Mar 2005 by Stephen J. Turnbull
+
+This file is part of XEmacs.
+
+XEmacs is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+XEmacs is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with XEmacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Synched up with: Not in GNU Emacs. */
+
+/* This module provides the Lisp interface to fonts in X11, including Xft,
+   but (at least at first) not GTK+ or Qt.
+
+   It should be renamed to fonts-x.h.
+
+   Sealevel code should be in ../lwlib/lwlib-fonts.h or
+   ../lwlib/lwlib-colors.h.
+*/
+
+
+#ifndef INCLUDED_font_mgr_h_
+#define INCLUDED_font_mgr_h_
+
+#include "../lwlib/lwlib-fonts.h"
+#include "../lwlib/lwlib-colors.h"
+
+extern Fixnum debug_xft;
+
+/* Standard for fontconfig.  Use a macro to show we're not guessing. */
+#define Qxft_font_name_encoding Qutf_8
+
+#define XE_XLFD_MAKE_LISP_STRING(s) (make_string(s, strlen(s)))
+
+struct fc_pattern
+{
+  struct LCRECORD_HEADER header;
+  FcPattern *fcpatPtr;
+};
+
+typedef struct fc_pattern fc_pattern;
+
+DECLARE_LRECORD(fc_pattern, struct fc_pattern);
+#define XFCPATTERN(x) XRECORD (x, fc_pattern, struct fc_pattern)
+#define wrap_fcpattern(p) wrap_record (p, fc_pattern)
+#define FCPATTERNP(x) RECORDP (x, fc_pattern)
+#define CHECK_FCPATTERN(x) CHECK_RECORD (x, fc_pattern)
+#define CONCHECK_FCPATTERN(x) CONCHECK_RECORD (x, fc_pattern)
+#define XFCPATTERN_PTR(x) (XFCPATTERN(x)->fcpatPtr)
+
+#endif /* INCLUDED_font_mgr_h_ */
--- a/src/inline.c	Sat Apr 22 21:51:52 2006 +0000
+++ b/src/inline.c	Sun Apr 23 16:11:34 2006 +0000
@@ -101,7 +101,7 @@
 #ifdef HAVE_X_WINDOWS
 #include "glyphs-x.h"
 #ifdef USE_XFT
-#include "xft-fonts.h"
+#include "font-mgr.h"
 #endif
 #endif
 
--- a/src/objects-x.c	Sat Apr 22 21:51:52 2006 +0000
+++ b/src/objects-x.c	Sun Apr 23 16:11:34 2006 +0000
@@ -39,7 +39,7 @@
 #include "objects-x-impl.h"
 
 #ifdef USE_XFT
-#include "xft-fonts.h"
+#include "font-mgr.h"
 #endif
 
 int x_handle_non_fully_specified_fonts;
@@ -206,7 +206,7 @@
 /************************************************************************/
 
 #ifdef USE_XFT
-/* #### all these #defines should probably move to xft-fonts.h */
+/* #### all these #defines should probably move to font-mgr.h */
 
 /*
   The format of a fontname (as returned by fontconfig) is not well-documented,
--- a/src/symsinit.h	Sat Apr 22 21:51:52 2006 +0000
+++ b/src/symsinit.h	Sun Apr 23 16:11:34 2006 +0000
@@ -160,7 +160,7 @@
 void syms_of_objects_mswindows (void);
 void syms_of_objects_tty (void);
 void syms_of_objects_x (void);
-void syms_of_xft_fonts (void);
+void syms_of_font_mgr (void);
 EXTERN_C void syms_of_postgresql (void);
 void syms_of_print (void);
 void syms_of_process (void);
@@ -398,8 +398,8 @@
 void vars_of_nt (void);
 void vars_of_number (void);
 void vars_of_objects (void);
-void vars_of_xft_fonts (void);
-void reinit_vars_of_xft_fonts (void);
+void vars_of_font_mgr (void);
+void reinit_vars_of_font_mgr (void);
 void reinit_vars_of_objects (void);
 void vars_of_objects_tty (void);
 void vars_of_objects_mswindows (void);
@@ -484,7 +484,7 @@
 void complex_vars_of_minibuf (void);
 void reinit_complex_vars_of_minibuf (void);
 void complex_vars_of_keymap (void);
-void complex_vars_of_xft_fonts (void);
+void complex_vars_of_font_mgr (void);
 
 /* Late initialization -- stuff pertaining only to interactive usage,
    I/O, or Lisp reading. (Dump-time and run-time, but the code itself
--- a/src/xft-fonts.c	Sat Apr 22 21:51:52 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,823 +0,0 @@
-/* Lisp font handling implementation for X with Xft.
-
-Copyright (C) 2003 Eric Knauel and Matthias Neubauer
-Copyright (C) 2005 Eric Knauel
-Copyright (C) 2004, 2005 Free Software Foundation, Inc.
-
-Authors:	Eric Knauel <knauel@informatik.uni-tuebingen.de>
-		Matthias Neubauer <neubauer@informatik.uni-freiburg.de>
-		Stephen J. Turnbull <stephen@xemacs.org>
-Created:	27 Oct 2003
-Updated:	05 Mar 2005 by Stephen J. Turnbull
-
-This file is part of XEmacs.
-
-XEmacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-XEmacs is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: Not in GNU Emacs. */
-
-/* This module provides the Lisp interface to fonts in X11, including Xft,
-   but (at least at first) not GTK+ or Qt.
-
-   It should be renamed to fonts-x.h.
-
-   Sealevel code should be in ../lwlib/lwlib-fonts.c or
-   ../lwlib/lwlib-colors.c.
-*/
-
-#include <config.h>
-#include "lisp.h"
-#include "device.h"
-#include "device-impl.h"
-#include "console-x-impl.h"
-#include "objects-x.h"
-#include "objects-x-impl.h"
-#include "hash.h"
-#include "xft-fonts.h"
-
-/* #### TO DO ####
-   . The "x-xft-*" and "x_xft_*" nomenclature is mostly redundant, especially
-     if we separate X fonts from Xft fonts, and use fontconfig more generally.
-   . We should support the most recent Xft first, old Xft libraries later.
-   . We may (think about it) wish to use fontconfig generally, even if we're
-     not using Xft.  Either way, names that are really from fontconfig should
-     use the Fc* namespace.
-   . Mule-ize this file.
-   . Separate X Font Struct ops from Xft Font ops; give precedence to Xft but
-     allow fallback to X.
-   . Push decisions about font choice, defaults, fallbacks to Lisp; if we
-     really need efficiency, can reimplement in C later.
-   . Implement symbols interned in this file in the Q* namespace.
-   . Implement FcMatrix (Lisp vector).
-   . Implement FcCharSets (Lisp chartable?  For implementation hints, see
-     FcCharSetFirstPage and FcCharSetNextPage).
-   . Implement FcConfigs.
-   DONE
-   . Fontconfig fontnames are encoded in UTF-8.
-*/
-
-Lisp_Object Qxft_font;
-Lisp_Object Qfc_patternp;
-Lisp_Object Qfc_fontsetp;
-/* Lisp_Object Qfc_result_match; */ 	/* FcResultMatch */
-Lisp_Object Qfc_result_type_mismatch;	/* FcResultTypeMismatch */
-Lisp_Object Qfc_result_no_match; 	/* FcResultNoMatch */
-Lisp_Object Qfc_result_no_id;		/* FcResultNoId */
-Lisp_Object Qfc_internal_error;
-Lisp_Object Vxlfd_font_name_regexp;	/* #### Really needed? */
-Lisp_Object Vxft_version;
-/* Lisp_Object Vfc_version; */		/* #### Should have this, too! */
-Fixnum debug_xft;		/* Set to 1 enables lots of obnoxious messages.
-				   Setting it to 2 or 3 enables even more. */
-
-/****************************************************************
-*                       FcPattern objects                       *
-****************************************************************/
-
-static void
-finalize_fc_pattern (void *header, int UNUSED (for_disksave))
-{
-  struct fc_pattern *p = (struct fc_pattern *) header;
-  if (p->fcpatPtr)
-    {
-      FcPatternDestroy (p->fcpatPtr);
-      p->fcpatPtr = 0;
-    }
-}
-
-static const struct memory_description fcpattern_description [] = {
-  /* #### nothing here, is this right?? */
-  { XD_END }
-};
-
-DEFINE_LRECORD_IMPLEMENTATION("fc-pattern", fc_pattern,
-			      0, 0, 0, finalize_fc_pattern, 0, 0,
-			      fcpattern_description,
-			      struct fc_pattern);
-
-/*
- * Helper Functions
- */
-static Lisp_Object make_xlfd_font_regexp (void);
-static void string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os);
-
-/* 
-   extract the C representation of the Lisp string STR and convert it
-   to the encoding used by the Fontconfig API for property and font
-   names.  I suppose that Qnative is the right encoding, the manual
-   doesn't say much about this topic.  This functions assumes that STR
-   is a Lisp string.
-*/
-#define extract_fcapi_string(str) \
-  ((FcChar8 *) NEW_LISP_STRING_TO_EXTERNAL ((str), Qnative))
-
-/* fontconfig assumes that objects (property names) are statically allocated,
-   and you will get bizarre results if you pass Lisp string data or strings
-   allocated on the stack as objects.  fontconfig _does_ copy values, so we
-   (I hope) don't have to worry about that member.
-
-   Probably these functions don't get called so often that the memory leak
-   due to strdup'ing every time we add a property would matter, but XEmacs
-   _is_ a long-running process.  So we hash them.
-
-   I suspect that using symbol names or even keywords does not provide
-   assurance that the string won't move in memory.  So we hash them
-   ourselves; hash.c hashtables do not interpret the value pointers. */
-static FcChar8 *fc_standard_properties[] = {
-  "antialias", "aspect", "autohint", "charset", "dpi", "family", "file",
-  "foundry", "ftface", "globaladvance", "hinting", "index", "lang",
-  "minspace", "outline", "pixelsize", "rasterizer", "rgba", "scalable",
-  "scale", "size", "slant", "spacing", "style", "verticallayout", "weight",
-  /* obsolete after Xft v. 1 */
-  "charwidth", "charheight", "core", "encoding", "render"
-};
-
-static struct hash_table *fc_property_name_hash_table;
-
-/* #### Maybe fc_intern should be exposed to LISP?  The idea is that
-   fc-pattern-add could warn or error if the property isn't interned. */
-
-static FcChar8 *
-fc_intern (Lisp_Object property)
-{
-  const void *dummy;
-  FcChar8 *prop = extract_fcapi_string (property);
-  const void *val = gethash (prop, fc_property_name_hash_table, &dummy);
-
-  /* extract_fcapi_string returns something alloca'd
-     so we can just drop the old value of prop on the floor */
-  if (val)
-    prop = (FcChar8 *) val;
-  else
-    {
-      prop = FcStrCopy (prop);
-      puthash (prop, NULL, fc_property_name_hash_table);
-    }
-  return prop;
-}
-
-DEFUN("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /*
-Returns t if OBJECT is of type fc-pattern, nil otherwise.
-*/
-      (object))
-{
-  return FCPATTERNP(object) ? Qt : Qnil;
-}
-
-DEFUN("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /* 
-Return a new, empty fc-pattern object.
-*/
-      ())
-{
-  fc_pattern *fcpat =
-    ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
-
-  fcpat->fcpatPtr = FcPatternCreate();
-  return wrap_fcpattern(fcpat);
-}
-
-DEFUN("fc-name-parse", Ffc_name_parse, 1, 1, 0, /*
-Parse an Fc font name and return its representation as a fc pattern object.
-*/
-      (name))
-{
-  struct fc_pattern *fcpat =
-    ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
-
-  CHECK_STRING(name);		/* #### MEMORY LEAK!!  maybe not ... */
-
-  fcpat->fcpatPtr = FcNameParse (extract_fcapi_string (name));
-  return wrap_fcpattern(fcpat);
-}
-
-/* #### Ga-a-ack!  Xft's similar function is actually a different API.
-   We provide both. */
-DEFUN("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /*
-Unparse an fc pattern object to a string.
-*/
-      (pattern))
-{
-  CHECK_FCPATTERN(pattern);
-  {
-  FcChar8 *temp = FcNameUnparse(XFCPATTERN_PTR(pattern));
-  Lisp_Object res = build_ext_string (temp, Qxft_font_name_encoding);
-  free (temp);
-  return res;
-  }
-}
-
-#if 0
-/* #### This seems to not work? */
-DEFUN("xft-name-unparse", Fxft_name_unparse, 1, 1, 0, /*
-Unparse an fc pattern object to a string (using the Xft API).
-*/
-      (pattern))
-{
-  char temp[FCSTRLEN];
-  Bool res;
-
-  CHECK_FCPATTERN(pattern);
-  res = XftNameUnparse(XFCPATTERN_PTR(pattern), temp, FCSTRLEN-1);
-  return res ? build_ext_string (temp, Qxft_font_name_encoding) : Qnil;
-}
-#endif
-
-DEFUN("fc-pattern-duplicate", Ffc_pattern_duplicate, 1, 1, 0, /* 
-Make a copy of the fc pattern object PATTERN and return it.
-*/
-      (pattern))
-{
-  struct fc_pattern *copy = NULL;
-  CHECK_FCPATTERN(pattern);
-
-  copy = ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
-  copy->fcpatPtr = FcPatternDuplicate(XFCPATTERN_PTR(pattern));
-  return wrap_fcpattern(copy);
-}
-
-DEFUN("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /*
-Add attributes to the pattern object PATTERN.  PROPERTY is a string naming
-the attribute to add, VALUE the value for this attribute.
-
-VALUE may be a string, integer, float, or symbol, in which case the value
-will be added as an FcChar8[], int, double, or FcBool respectively.
-*/
-      (pattern, property, value))
-{
-  Bool res = 0;
-  Extbyte *obj;
-  FcPattern *fcpat;
-
-  CHECK_FCPATTERN(pattern);
-  CHECK_STRING(property);
-
-  obj = fc_intern (property);
-  fcpat = XFCPATTERN_PTR (pattern);
-
-  if (STRINGP(value)) 
-    {
-      FcChar8 *str = (FcChar8 *) extract_fcapi_string (value);
-      res = FcPatternAddString (fcpat, obj, str);
-    }
-  else if (INTP(value)) 
-    {
-      res = FcPatternAddInteger (fcpat, obj, XINT(value));
-    }
-  else if (FLOATP(value)) 
-    {
-      res = FcPatternAddDouble (fcpat, obj, (double) XFLOAT_DATA(value));
-    }
-  else if (SYMBOLP(value)) 
-    {
-      res = FcPatternAddBool (fcpat, obj, !NILP(value));
-    }
-  /* else ... maybe we should wta here? */
-
-  return res ? Qt : Qnil;
-}
-
-DEFUN("fc-pattern-del", Ffc_pattern_del, 2, 2, 0, /*
-Remove attribute PROPERTY from fc pattern object OBJECT.
-*/
-      (pattern, property))
-{
-  Bool res;
-
-  CHECK_FCPATTERN(pattern);
-  CHECK_STRING(property);
-
-  res = FcPatternDel(XFCPATTERN_PTR(pattern), 
-		     extract_fcapi_string (property));
-  return res ? Qt : Qnil;
-}
-
-/* Generic interface to FcPatternGet()
- * Don't support the losing symbol-for-property interface.
- */
-DEFUN("fc-pattern-get", Ffc_pattern_get, 2, 4, 0, /*
-From PATTERN, extract PROPERTY for the ID'th member, of type TYPE.
-
-PATTERN is an Xft (fontconfig) pattern object.
-PROPERTY is a string naming an fontconfig font property.
-Optional ID is a nonnegative integer indexing the list of values for PROPERTY
-  stored in PATTERN, defaulting to 0 (the first value).
-Optional TYPE is a symbol, one of 'string, 'boolean, 'integer, 'float,
-  'double, 'matrix, 'charset, or 'void, corresponding to the FcValue types.
-  ('float is an alias for 'double).
-
-The Lisp types returned will conform to TYPE:
-  string		string
-  boolean		`t' or `nil'
-  integer		integer
-  double (float)	float
-  matrix		not implemented
-  charset		not implemented
-  void			not implemented
-
-Symbols with names of the form "fc-result-DESCRIPTION" are returned when
-the desired value is not available.  These are
-
-  fc-result-type-mismatch       the value found has an unexpected type
-  fc-result-no-match            there is no such attribute
-  fc-result-no-id               there is no value for the requested ID
-
-The types of the following standard properties are predefined by fontconfig.
-The symbol 'fc-result-type-mismatch will be returned if the object exists but
-TYPE does not match the predefined type.  It is best not to specify a type
-for predefined properties, as a mistake here ensures error returns on the
-correct type.
-
-Each standard property has a convenience accessor defined in fontconfig.el,
-named in the form "fc-pattern-get-PROPERTY".  The convenience functions are
-preferred to `fc-pattern-get' since a typo in the string naming a property
-will result in a silent null return, while a typo in a function name will
-usually result in a compiler or runtime \"not fboundp\" error.  You may use
-`defsubst' to define convenience functions for non-standard properties.
-
-family         String  Font family name 
-style          String  Font style. Overrides weight and slant 
-slant          Int     Italic, oblique or roman 
-weight         Int     Light, medium, demibold, bold or black 
-size           Double  Point size 
-aspect         Double  Stretches glyphs horizontally before hinting 
-pixelsize      Double  Pixel size 
-spacing        Int     Proportional, monospace or charcell 
-foundry        String  Font foundry name 
-antialias      Bool    Whether glyphs can be antialiased 
-hinting        Bool    Whether the rasterizer should use hinting 
-verticallayout Bool    Use vertical layout 
-autohint       Bool    Use autohinter instead of normal hinter 
-globaladvance  Bool    Use font global advance data 
-file           String  The filename holding the font 
-index          Int     The index of the font within the file 
-ftface         FT_Face Use the specified FreeType face object 
-rasterizer     String  Which rasterizer is in use 
-outline        Bool    Whether the glyphs are outlines 
-scalable       Bool    Whether glyphs can be scaled 
-scale          Double  Scale factor for point->pixel conversions 
-dpi            Double  Target dots per inch 
-rgba           Int     unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry 
-minspace       Bool    Eliminate leading from line spacing 
-charset        CharSet Unicode chars encoded by the font 
-lang           String  List of RFC-3066-style languages this font supports
-
-The FT_Face, Matrix, CharSet types are unimplemented, so the corresponding
-properties are not accessible from Lisp at this time.  If the value of a
-property returned has type FT_Face, FcCharSet, or FcMatrix,
-`fc-result-type-mismatch' is returned.
-
-The following properties which were standard in Xft v.1 are obsolete in
-Xft v.2:  encoding, charwidth, charheight, core, and render. */
-      (pattern, property, id, type))
-{
-  FcChar8 *fc_property;		/* UExtbyte * */
-  FcResult fc_result;
-  FcValue fc_value;
-
-  /*
-    process arguments
-  */
-  CHECK_FCPATTERN (pattern);
-
-#if 0
-  /* Don't support the losing symbol-for-property interface. */
-  property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property;
-#endif
-  if (STRINGP (property))
-    {
-      fc_property = (FcChar8 *) extract_fcapi_string (property);
-    }
-  else
-    {
-      /* if we allow symbols, this would need to be
-	 list3 (Qlambda, list1 (Qobject),
-		  list3 (Qor, list2 (Qstringp, Qobject),
-			      list2 (Qsymbolp, Qobject)))
-	 or something like that? */
-      dead_wrong_type_argument (Qstringp, property);
-    }
-
-  if (!NILP (id)) CHECK_NATNUM (id);
-  if (!NILP (type)) CHECK_SYMBOL (type);
-
-  /* get property */
-  fc_result = FcPatternGet (XFCPATTERN_PTR (pattern),
-			    fc_property,
-			    NILP (id) ? 0 : XINT(id),
-			    &fc_value);
-
-  switch (fc_result)
-    {
-    case FcResultMatch:
-      /* wrap it and return */
-      switch (fc_value.type)
-	{
-	case FcTypeInteger:
-	  return ((!NILP (type) && !EQ (type, Qinteger))
-		  ? Qfc_result_type_mismatch : make_int (fc_value.u.i));
-	case FcTypeDouble:
-	  return ((!NILP (type) && !EQ (type, intern ("double"))
-		   && !EQ (type, Qfloat))
-		  ? Qfc_result_type_mismatch : make_float (fc_value.u.d));
-	case FcTypeString:
-	  return ((!NILP (type) && !EQ (type, Qstring))
-		  ? Qfc_result_type_mismatch
-		  : build_ext_string (fc_value.u.s, Qxft_font_name_encoding));
-	case FcTypeBool:
-	  return ((!NILP (type) && !EQ (type, Qboolean))
-		  ? Qfc_result_type_mismatch : fc_value.u.b ? Qt : Qnil);
-	case FcTypeMatrix:
-	  return Qfc_result_type_mismatch;
-	  /* #### unimplemented
-	  return ((!NILP (type) && !EQ (type, intern ("matrix")))
-		  ? Qfc_result_type_mismatch : make_int (fc_value.u.m));
-	  */
-	case FcTypeCharSet:
-	  return Qfc_result_type_mismatch;
-	  /* #### unimplemented
-	  return ((!NILP (type) && !EQ (type, intern ("charset")))
-		  ? Qfc_result_type_mismatch : make_int (fc_value.u.c));
-	  */
-	}
-    case FcResultTypeMismatch:
-      return Qfc_result_type_mismatch;
-    case FcResultNoMatch:
-      return Qfc_result_no_match;
-    case FcResultNoId:
-      return Qfc_result_no_id;
-    default:
-      return Qfc_internal_error;
-    }
-}
-
-DEFUN("fc-font-match", Ffc_font_match, 2, 2, 0, /*
-Return the font on DEVICE that most closely matches PATTERN.
-
-DEVICE is an X11 device.
-PATTERN is a fontconfig pattern object.
-Returns a fontconfig pattern object representing the closest match to the
-given pattern, or an error code.  Possible error codes are
-`fc-result-no-match' and `fc-result-no-id'. */
-      (device, pattern))
-{
-  Display *dpy;
-  FcResult res;
-
-  struct fc_pattern *res_fcpat =
-    ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
-  CHECK_FCPATTERN(pattern);	/* #### MEMORY LEAKS!!! */
-  if (NILP(device))
-    return Qnil;
-  CHECK_X_DEVICE(device);
-  if (!DEVICE_LIVE_P(XDEVICE(device)))
-    return Qnil;
-
-  dpy = DEVICE_X_DISPLAY(XDEVICE(device));
-  /* More Xft vs fontconfig brain damage? */
-  res_fcpat->fcpatPtr = XftFontMatch(dpy, DefaultScreen (dpy),
-				     XFCPATTERN_PTR(pattern), &res);
-  
-  if (res_fcpat->fcpatPtr == NULL)
-    switch (res) {
-    case FcResultNoMatch:
-      return Qfc_result_no_match;
-    case FcResultNoId:
-      return Qfc_result_no_id;
-    default:
-      return Qfc_internal_error;
-    }
-  else
-    return wrap_fcpattern(res_fcpat);
-}
-
-/* NOTE NOTE NOTE This function destroys the FcFontSet passed to it. */
-static Lisp_Object
-fontset_to_list (FcFontSet *fontset)
-{
-  int idx;
-  Lisp_Object fontlist = Qnil;
-  fc_pattern *fcpat;
-
-  /* #### improve this error message */
-  if (!fontset)
-    Fsignal (Qinvalid_state,
-	     list1 (build_string ("failed to create FcFontSet")));
-  for (idx = 0; idx < fontset->nfont; ++idx)
-    {
-      fcpat = 
-	ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
-      fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]);
-      fontlist = Fcons (wrap_fcpattern(fcpat), fontlist);
-    }
-  FcFontSetDestroy (fontset);
-  return fontlist;
-}
-
-/* #### fix this name to correspond to Ben's new nomenclature */
-DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects,
-      3, 3, 0, /*
-Return a list of fonts on DEVICE that match PATTERN for PROPERTIES.
-Each font is represented by a fontconfig pattern object.
-
-DEVICE is an X11 device.
-PATTERN is a fontconfig pattern to be matched.
-PROPERTIES is a list of property names (strings) that should match.
-
-#### DEVICE is unused, ignored, and may be removed if it's not needed to
-match other font-listing APIs. */
-      (UNUSED (device), pattern, properties))
-{
-  FcObjectSet *os;
-  FcFontSet *fontset;
-
-  CHECK_FCPATTERN (pattern);
-  CHECK_LIST (properties);
-
-  os = FcObjectSetCreate ();
-  string_list_to_fcobjectset (properties, os);
-  /* #### why don't we need to do the "usual substitutions"? */
-  fontset = FcFontList (NULL, XFCPATTERN_PTR (pattern), os);
-  FcObjectSetDestroy (os);
-
-  return fontset_to_list (fontset);
-
-}
-
-/* #### maybe this can/should be folded into fc-list-fonts-pattern-objects? */
-DEFUN("fc-font-sort", Ffc_font_sort, 2, 4, 0, /*
-Return a list of all fonts sorted by proximity to PATTERN.
-Each font is represented by a fontconfig pattern object.
-
-DEVICE is an X11 device.
-PATTERN is a fontconfig pattern to be matched.
-Optional argument TRIM, if non-nil, means to trim trailing fonts that do not
-contribute new characters to the union repertoire.
-
-#### Optional argument NOSUB, if non-nil, suppresses some of the usual
-property substitutions.  DON'T USE THIS in production code, it is intended
-for exploring behavior of fontconfig and will be removed when this code is
-stable.
-
-#### DEVICE is unused, ignored, and may be removed if it's not needed to
-match other font-listing APIs. */
-      (UNUSED (device), pattern, trim, nosub))
-{
-  CHECK_FCPATTERN (pattern);
-
-  {
-    FcConfig *fcc = FcConfigGetCurrent();
-    FcFontSet *fontset;
-    FcPattern *p = XFCPATTERN_PTR (pattern);
-    FcResult fcresult;
-
-    if (NILP(nosub))		/* #### temporary debug hack */
-      FcDefaultSubstitute (p);
-    FcConfigSubstitute (fcc, p, FcMatchPattern);
-    fontset = FcFontSort (fcc, p, !NILP(trim), NULL, &fcresult);
-
-    return fontset_to_list (fontset);
-  }
-}
-
-/* #### this actually is an Xft function, should split those out
-   or get rid of them entirely? */
-/* #### be consistent about argument order. */
-DEFUN("fc-font-real-pattern", Ffc_font_real_pattern, 2, 2, 0, /*
-Temporarily open FONTNAME (a string) and return the actual
-fc pattern matched by the Fc library.	*/
-      (fontname, xdevice))
-{
-  FcPattern *copy;
-  Display *dpy;
-  XftFont *font;
-  struct fc_pattern *fcpat =
-    ALLOC_LCRECORD_TYPE (struct fc_pattern, &lrecord_fc_pattern);
-
-  CHECK_STRING (fontname);	/* #### MEMORY LEAK?!  maybe not ... */
-  if (NILP(xdevice))
-    return Qnil;
-  CHECK_X_DEVICE (xdevice);
-  if (!DEVICE_LIVE_P(XDEVICE(xdevice)))
-    return Qnil;
-
-  /* #### these gymnastics should be unnecessary, just use FcFontMatch */
-  dpy = DEVICE_X_DISPLAY (XDEVICE (xdevice));
-  font = XftFontOpenName (dpy, DefaultScreen(dpy),
-			  extract_fcapi_string (fontname));
-  if (font == NULL)
-    return Qnil;
-  copy = FcPatternDuplicate(font->pattern);
-  XftFontClose(dpy, font);  
-  if (copy == NULL)
-    return Qnil;
-  fcpat->fcpatPtr = copy;
-  return wrap_fcpattern(fcpat);
-}
-
-DEFUN("xlfd-font-name-p", Fxlfd_font_name_p, 1, 1, 0, /*
-Check whether the string FONTNAME is a XLFD font name. */
-      (fontname))
-{
-  CHECK_STRING(fontname);
-  /* #### should bind `case-fold-search' here? */
-  return Fstring_match(Vxlfd_font_name_regexp, fontname, Qnil, Qnil);
-}
-
-/* FcPatternPrint: there is no point in having wrappers fc-pattern-print,
-   Ffc_pattern_print since this function prints to stdout. */
-
-/* Initialization of xft-fonts */
-
-#define XE_XLFD_SEPARATOR	"-"
-      /* XLFD specifies ISO 8859-1 encoding, but we can't handle non-ASCII
-	 in Mule when this function is called.  So use HPC. */
-#if 0
-#define XE_XLFD_PREFIX		"\\(\\+[\040-\176\240-\377]*\\)?-"
-#define XE_XLFD_OPT_TEXT	"\\([\040-\044\046-\176\240-\377]*\\)"
-#define XE_XLFD_TEXT		"\\([\040-\044\046-\176\240-\377]+\\)"
-#else
-#define XE_XLFD_PREFIX		"\\(\\+[\040-\176]*\\)?-"
-#define XE_XLFD_OPT_TEXT	"\\([^-]*\\)"
-#define XE_XLFD_TEXT		"\\([^-]+\\)"
-#endif
-
-#define XE_XLFD_SLANT		"\\([0-9ior?*][iot]?\\)"
-#define XE_XLFD_SPACING		"\\([cmp?*]\\)"
-      /* Hyphen as minus conflicts with use as separator. */
-#define XE_XLFD_OPT_NEGATE      "~?"
-#define XE_XLFD_NUMBER		"\\([0-9?*]+\\)"
-#define XE_XLFD_PSIZE		"\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)"
-  
-/* Call this only from the init code
-   #### This is really horrible, let's get rid of it, please. */
-static Lisp_Object
-make_xlfd_font_regexp (void)
-{
-  struct gcpro gcpro1;
-  unsigned i;
-  Lisp_Object reg = Qnil;
-  const Extbyte *re[] = 	/* #### This could just be catenated by
-				   cpp and passed to build_ext_string. */
-    {
-      /* Regular expression matching XLFDs as defined by XLFD v. 1.5.
-	 Matches must be case-insensitive.
-	 PSIZE is a pixel or point size, which may be a "matrix".  The
-	 syntax of a matrix is not checked, just some lexical properties.
-	 AFAICT none of the TEXT fields except adstyle is optional.
-
-	 NB. It should not be a problem if this matches "too much", since
-	 an "old" server will simply not be able to find a matching font. */
-      "\\`",
-      XE_XLFD_PREFIX,		/* prefix */
-      XE_XLFD_TEXT,		/* foundry */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_TEXT,		/* family */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_TEXT,		/* weight */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_SLANT,		/* slant */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_TEXT,		/* swidth */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_OPT_TEXT,		/* adstyle */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_PSIZE,		/* pixelsize */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_PSIZE,		/* pointsize */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_NUMBER,		/* resx */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_NUMBER,		/* resy */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_SPACING,		/* spacing */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_OPT_NEGATE,	/* avgwidth */
-      XE_XLFD_NUMBER,
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_TEXT,		/* registry */
-      XE_XLFD_SEPARATOR,
-      XE_XLFD_TEXT,		/* encoding */
-      "\\'"
-    };
-  
-  GCPRO1 (reg);  
-  for (i = 0; i < sizeof(re)/sizeof(Extbyte *); i++)
-    {
-      /* #### Currently this is Host Portable Coding, not ISO 8859-1. */
-      reg = concat2(reg, build_ext_string (re[i], Qx_font_name_encoding));
-    }
-
-  RETURN_UNGCPRO (reg);
-}
-#undef XE_XLFD_SEPARATOR
-#undef XE_XLFD_PREFIX
-#undef XE_XLFD_OPT_TEXT
-#undef XE_XLFD_TEXT
-#undef XE_XLFD_OPT_SLANT
-#undef XE_XLFD_OPT_SPACING
-#undef XE_XLFD_OPT_NEGATE
-#undef XE_XLFD_NUMBER
-#undef XE_XLFD_PSIZE
-
-#define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
-		   ? ((unsigned long) (x)) : ((unsigned long) (y)))
-
-static void 
-string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os)
-{
-  EXTERNAL_LIST_LOOP_2 (elt, list)
-    {
-      FcChar8 *s;
-
-      CHECK_STRING (elt);
-      s = fc_intern (elt);
-      fprintf (stderr, "%s\n", s);
-      FcObjectSetAdd (os, s);
-    }
-}
-
-void
-syms_of_xft_fonts (void)
-{
-  INIT_LRECORD_IMPLEMENTATION(fc_pattern);
-
-  DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp);
-
-  DEFSYMBOL(Qfc_result_type_mismatch);
-  DEFSYMBOL(Qfc_result_no_match);
-  DEFSYMBOL(Qfc_result_no_id);
-  DEFSYMBOL(Qfc_internal_error);
-  DEFSYMBOL(Qxft_font);
-
-  DEFSUBR(Ffc_pattern_p);
-  DEFSUBR(Ffc_pattern_create);
-  DEFSUBR(Ffc_name_parse);
-  DEFSUBR(Ffc_name_unparse);
-#if 0
-  DEFSUBR(Fxft_name_unparse);	/* URK! */
-#endif
-  DEFSUBR(Ffc_pattern_duplicate);
-  DEFSUBR(Ffc_pattern_add);
-  DEFSUBR(Ffc_pattern_del);
-  DEFSUBR(Ffc_pattern_get);
-  DEFSUBR(Ffc_list_fonts_pattern_objects);
-  DEFSUBR(Ffc_font_sort);
-  DEFSUBR(Ffc_font_match);
-  DEFSUBR(Ffc_font_real_pattern);
-  DEFSUBR(Fxlfd_font_name_p);
-}
-
-void
-vars_of_xft_fonts (void)
-{
-  /* #### I know, but the right fix is use the generic debug facility. */
-  DEFVAR_INT ("xft-debug-level", &debug_xft /*
-Level of debugging messages to issue to stderr for Xft.
-A nonnegative integer.  Set to 0 to suppress all warnings.
-Default is 1 to ensure a minimum of debugging output at initialization.
-Higher levels give even more information.
-*/ );
-  debug_xft = 1;
-
-  DEFVAR_LISP("xft-version", &Vxft_version /*
-The major version number of the Xft library being used.
-*/ );
-  Vxft_version = make_int(XFT_VERSION);
-
-  Fprovide (intern ("xft"));
-}
-
-void
-complex_vars_of_xft_fonts (void)
-{
-  DEFVAR_LISP("xft-xlfd-font-regexp", &Vxlfd_font_name_regexp /*
-The regular expression used to match XLFD font names. */			       
-	      );
-  Vxlfd_font_name_regexp = make_xlfd_font_regexp();
-}
-
-void
-reinit_vars_of_xft_fonts (void)
-{
-  int i, size = (int) countof (fc_standard_properties);
-  
-  FcInit ();
-
-  fc_property_name_hash_table = make_string_hash_table (size);
-  for (i = 0; i < size; ++i)
-    puthash (fc_standard_properties[i], NULL, fc_property_name_hash_table);
-}
-
--- a/src/xft-fonts.h	Sat Apr 22 21:51:52 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/* Lisp font data structures for X and Xft.
-
-Copyright (C) 2003 Eric Knauel and Matthias Neubauer
-Copyright (C) 2005 Eric Knauel
-Copyright (C) 2004, 2005 Free Software Foundation, Inc.
-
-Authors:	Eric Knauel <knauel@informatik.uni-tuebingen.de>
-		Matthias Neubauer <neubauer@informatik.uni-freiburg.de>
-		Stephen J. Turnbull <stephen@xemacs.org>
-Created:	27 Oct 2003
-Updated:	05 Mar 2005 by Stephen J. Turnbull
-
-This file is part of XEmacs.
-
-XEmacs is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-XEmacs is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with XEmacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* Synched up with: Not in GNU Emacs. */
-
-/* This module provides the Lisp interface to fonts in X11, including Xft,
-   but (at least at first) not GTK+ or Qt.
-
-   It should be renamed to fonts-x.h.
-
-   Sealevel code should be in ../lwlib/lwlib-fonts.h or
-   ../lwlib/lwlib-colors.h.
-*/
-
-
-#ifndef INCLUDED_xft_fonts_h_
-#define INCLUDED_xft_fonts_h_
-
-#include "../lwlib/lwlib-fonts.h"
-#include "../lwlib/lwlib-colors.h"
-
-extern Fixnum debug_xft;
-
-/* Standard for fontconfig.  Use a macro to show we're not guessing. */
-#define Qxft_font_name_encoding Qutf_8
-
-#define XE_XLFD_MAKE_LISP_STRING(s) (make_string(s, strlen(s)))
-
-struct fc_pattern
-{
-  struct LCRECORD_HEADER header;
-  FcPattern *fcpatPtr;
-};
-
-typedef struct fc_pattern fc_pattern;
-
-DECLARE_LRECORD(fc_pattern, struct fc_pattern);
-#define XFCPATTERN(x) XRECORD (x, fc_pattern, struct fc_pattern)
-#define wrap_fcpattern(p) wrap_record (p, fc_pattern)
-#define FCPATTERNP(x) RECORDP (x, fc_pattern)
-#define CHECK_FCPATTERN(x) CHECK_RECORD (x, fc_pattern)
-#define CONCHECK_FCPATTERN(x) CONCHECK_RECORD (x, fc_pattern)
-#define XFCPATTERN_PTR(x) (XFCPATTERN(x)->fcpatPtr)
-
-#endif /* INCLUDED_xft_fonts_h_ */