;;; ps-bdf.el --- BDF font file handler for ps-print.
-;; Copyright (C) 1998 Electrotechnical Laboratory, JAPAN.
+;; Copyright (C) 1998, 1999 Electrotechnical Laboratory, JAPAN.
;; Licensed to the Free Software Foundation.
-;; Keywords: BDF, font, PostScript
+;; Keywords: wp, BDF, font, PostScript
;; Maintainer: Kenichi Handa <handa@etl.go.jp>
-;; Time-stamp: <98/11/26 15:09:23 kenichi>
+;; Time-stamp: <99/02/27 11:14:07 kenichi>
;; This file is part of GNU Emacs.
;;;###autoload
(defvar bdf-directory-list
- nil
- "*List of directories to search for `BDF' font files.")
+ (if (eq system-type 'ms-dos)
+ (list (expand-file-name "fonts/bdf" installation-directory))
+ '("/usr/local/share/emacs/fonts/bdf"))
+ "*List of directories to search for `BDF' font files.
+The default value is '(\"/usr/local/share/emacs/fonts/bdf\").")
+
+;; MS-DOS users like to move the binary around after it's built, but
+;; the value above is computed at loadup time.
+(and (eq system-type 'ms-dos)
+ (setq bdf-directory-list
+ (list (expand-file-name "fonts/bdf" installation-directory))))
(defun bdf-expand-file-name (bdfname)
"Return an abosolute path name of a `BDF' font file BDFNAME.
(insert-file-contents file-name)
buf)))))
-(defvar bdf-cache-file "~/.bdfcache.el"
+(defvar bdf-cache-file (convert-standard-filename "~/.bdfcache.el")
"Name of cache file which contains information of `BDF' font files.")
(defvar bdf-cache nil
(bdf-set-cache font-info)))
font-info))
+(defun bdf-find-font-info (bdfnames)
+ "Return information about `BDF' font file with alternative names BDFNAMES.
+
+If BDFNAMES is a list of file names, this function finds the first file
+in the list which exists and is readable, then calls `bdf-get-font-info'
+on that file name."
+ (let ((fnlist bdfnames)
+ (fname bdfnames))
+ (if (consp fnlist)
+ (while (and fnlist
+ (progn
+ (setq fname (car fnlist))
+ (null (bdf-expand-file-name fname))))
+ (setq fname nil
+ fnlist (cdr fnlist))))
+ (bdf-get-font-info (or fname (car bdfnames)))))
+
(defun bdf-read-bitmap (bdfname offset maxlen)
"Read `BDF' font file BDFNAME to get bitmap data at file poistion OFFSET.
BDFNAME is an abosolute path name of the font file.
DWIDTH is a pixel width of a glyph.
BBX is a bounding box of the glyph.
BITMAP-STRING is a string representing bits by hexadecimal digits."
- (let* ((font-info (bdf-get-font-info bdfname))
+ (let* ((font-info (bdf-find-font-info bdfname))
(absolute-path (bdf-info-absolute-path font-info))
(font-bounding-box (bdf-info-font-bounding-box font-info))
(maxlen (bdf-info-maxlen font-info))
;; Called from ps-mule-generate-font.
(defun bdf-generate-font (charset font-spec)
(let* ((font-name (ps-mule-font-spec-name font-spec))
- (font-info (bdf-get-font-info font-name)))
+ (font-info (bdf-find-font-info font-name))
+ (font-name (if (consp font-name) (car font-name) font-name)))
(ps-mule-generate-bitmap-font font-name
(ps-mule-font-spec-bytes font-spec)
(charset-width charset)
(defun bdf-generate-glyphs (font-spec code-list bytes)
(let ((font-name (ps-mule-font-spec-name font-spec)))
(mapcar '(lambda (x)
- (apply 'ps-mule-generate-bitmap-glyph font-name x))
+ (apply 'ps-mule-generate-bitmap-glyph
+ (if (consp font-name) (car font-name) font-name)
+ x))
(bdf-get-bitmaps font-name code-list))))
(provide 'ps-bdf)