-;;; fontset.el --- Commands for handling fontset.
+;;; fontset.el --- commands for handling fontset
;; Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
;; Licensed to the Free Software Foundation.
+;; Copyright (C) 2001 Free Software Foundation, Inc.
;; Keywords: mule, multilingual, fontset
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
+;;; Commentary:
+
;;; Code:
;; Set standard fontname specification of characters in the default
backward compatibility."
(concat "-" (mapconcat (lambda (x) (or x "*")) fields "-")))
+
+(defun x-must-resolve-font-name (xlfd-fields)
+ "Like `x-resolve-font-name', but always return a font name.
+XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
+If no font matching XLFD-FIELDS is available, successively replace
+parts of the font name pattern with \"*\" until some font is found.
+Value is name of that font."
+ (let ((ascii-font nil) (index 0))
+ (while (and (null ascii-font) (<= index xlfd-regexp-encoding-subnum))
+ (let ((pattern (x-compose-font-name xlfd-fields)))
+ (condition-case nil
+ (setq ascii-font (x-resolve-font-name pattern))
+ (error
+ (message "Warning: no fonts matching `%s' available" pattern)
+ (aset xlfd-fields index "*")
+ (setq index (1+ index))))))
+ (unless ascii-font
+ (error "No fonts founds"))
+ ascii-font))
+
+
(defun x-complement-fontset-spec (xlfd-fields fontlist)
"Complement FONTLIST for charsets based on XLFD-FIELDS and return it.
XLFD-FIELDS is a vector of XLFD (X Logical Font Description) fields.
If a font specifid for ASCII supports the other charsets (see the
variable `x-font-name-charset-alist'), add that information to FONTLIST."
- (let ((ascii-font (cdr (assq 'ascii fontlist))))
-
- ;; If font for ASCII is not specified, add it.
- (unless ascii-font
+ (let* ((slot (assq 'ascii fontlist))
+ (ascii-font (cdr slot))
+ ascii-font-spec)
+ (if ascii-font
+ (setcdr slot (setq ascii-font (x-resolve-font-name ascii-font)))
+ ;; If font for ASCII is not specified, add it.
(aset xlfd-fields xlfd-regexp-registry-subnum "iso8859")
(aset xlfd-fields xlfd-regexp-encoding-subnum "1")
- (setq ascii-font (x-compose-font-name xlfd-fields))
+ (setq ascii-font (x-must-resolve-font-name xlfd-fields))
(setq fontlist (cons (cons 'ascii ascii-font) fontlist)))
;; If the font for ASCII also supports the other charsets, and
;; they are not specified in FONTLIST, add them.
+ (setq xlfd-fields (x-decompose-font-name ascii-font))
+ (if (not xlfd-fields)
+ (setq ascii-font-spec ascii-font)
+ (setq ascii-font-spec
+ (cons (format "%s-%s"
+ (aref xlfd-fields xlfd-regexp-foundry-subnum)
+ (aref xlfd-fields xlfd-regexp-family-subnum))
+ (format "%s-%s"
+ (aref xlfd-fields xlfd-regexp-registry-subnum)
+ (aref xlfd-fields xlfd-regexp-encoding-subnum)))))
(let ((tail x-font-name-charset-alist)
elt)
(while tail
(setq charset (car charsets) charsets (cdr charsets))
(or (assq charset fontlist)
(setq fontlist
- (cons (cons charset ascii-font) fontlist))))))))
+ (cons (cons charset ascii-font-spec) fontlist))))))))
fontlist))
(if (charsetp charset)
(setq fontlist (cons (cons charset (match-string 2 fontset-spec))
fontlist))))
+ (setq ascii-font (cdr (assq 'ascii fontlist)))
;; Complement FONTLIST.
(setq fontlist (x-complement-fontset-spec xlfd-fields fontlist))
(cons (cons name alias) fontset-alias-alist)))))
;; Define the ASCII font name alias.
- (setq ascii-font (cdr (assq 'ascii fontlist)))
+ (or ascii-font
+ (setq ascii-font (cdr (assq 'ascii fontlist))))
(or (rassoc ascii-font fontset-alias-alist)
(setq fontset-alias-alist
(cons (cons name ascii-font)