Jerry James writes:
I think I found the problem. I'm looking at the function
x-font-create-object, in lisp/font.el. In the second conditional from
the top of the function, it checks
(if (and (stringp fontname)
(string-match font-xft-font-regexp fontname))
;; Return an XFT font.
(xft-font-create-object fontname)
But that's not right, is it?
Shouldn't we also check that Xft is even available?
Actually, it is right, and the check is counterproductive. A basic
problem is that Emacs, and especially our Xft support, confound font
specification with implementation of font objects.
But all of the standard font naming systems encapsulate similar sets
of font properties. There is no reason why an X font shouldn't be
returned on X11 for a MSFT font spec, or vice versa. Of course to
"really get it right", you'd need some auxiliary stuff like mapping
Arial to Helvetica, etc. But even without that it is at least
possible to parse out stuff like the size and often properties like
weight or slant.
That's what the currently unused lisp/font-mgr.el is aimed at.
AFAICS, fontconfig can handle anything that any other font
specification system can handle, so I plan to emulate its API.
What about something like this:
(if (and (stringp fontname)
(featurep 'xft-fonts)
(string-match font-xft-font-regexp fontname))
;; Return an XFT font.
(xft-font-create-object fontname)
This is a hangover from the original patch. The comment is wrong;
what is returned is a font.el-internal font object (NOT an XEmacs font
instance!) whose properties correspond to parsing the name as a
fontconfig name.
I would prefer the patch below (untested, and actually needs work on
the documentation but I don't have time to regenerate now).
What actually addresses the bug report is the change to
font-xft-font-regexp.
diff -r 891381effa11 lisp/font-mgr.el
--- a/lisp/font-mgr.el Tue Aug 18 12:34:34 2009 +0100
+++ b/lisp/font-mgr.el Tue Aug 25 17:04:44 2009 +0900
@@ -39,7 +39,8 @@
;; #### should we wrap the world in `(unless (featurep 'font-mgr) ... )'?
-(provide 'font-mgr)
+;; #### implementation is incomplete
+;; (provide 'font-mgr)
(defvar xft-xlfd-font-regexp
(concat
diff -r 891381effa11 lisp/font.el
--- a/lisp/font.el Tue Aug 18 12:34:34 2009 +0100
+++ b/lisp/font.el Tue Aug 25 17:04:44 2009 +0900
@@ -753,14 +753,22 @@
(defvar font-xft-font-regexp
(concat "\\`"
- #r"\(\\-\|\\:\|\\,\|[^:-]\)*" ; optional foundry and family
+ #r"\(\\[-,]|[^-:,*]\)*" ; optional foundry and family
; (allows for escaped colons,
- ; dashes, commas)
+ ; dashes, commas, asterisks)
"\\(-[0-9]*\\(\\.[0-9]*\\)?\\)?" ; optional size (points)
"\\(:[^:]*\\)*" ; optional properties
; not necessarily key=value!!
"\\'"
- ))
+ )
+ "Regexp matching fontconfig font names.
+Unfortunately, there is no explicit standard specifying these. We disallow
+hyphen and comma in family names unless escaped, because they have a syntactic
+role in fontconfig names. We disallow colon because it is part of fontconfig
+name syntax, and asterisk because of the potential for confusion with an XLFD.
+We do not allow escapes for colon and asterisk because the fontconfig
+documentation doesn't specify whether they can be escaped, or how a redundant
+escape character is treated.
+#### The name of this variable is subject to change.")
(defvar font-xft-family-mappings
;; #### FIXME this shouldn't be needed or used for Xft
@@ -799,6 +807,8 @@
"Return a font descriptor object for FONTNAME, appropriate for Xft.
Optional DEVICE defaults to `default-x-device'."
+ (unless (featurep 'font-mgr)
+ (error 'unimplemented 'font-mgr "fontconfig-style font names"))
(let* ((name fontname)
(device (or device (default-x-device)))
(pattern (fc-font-match device (fc-name-parse name)))
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta