annotate lisp/ps-bdf.el @ 28511:7a9707590ccd

(make_fontset_for_ascii_face): Use XINT on return value. (Fset_fontset_font): Use EQ to compare lisp objects.
author Ken Raeburn <raeburn@raeburn.org>
date Sat, 08 Apr 2000 19:33:36 +0000
parents 9eb84d5ffd61
children b5810f23b1b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
1 ;;; ps-bdf.el --- BDF font file handler for ps-print.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
2
26116
9eb84d5ffd61 Doc fix.
Kenichi Handa <handa@m17n.org>
parents: 24467
diff changeset
3 ;; Copyright (C) 1998, 1999 Electrotechnical Laboratory, JAPAN.
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
4 ;; Licensed to the Free Software Foundation.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
5
26116
9eb84d5ffd61 Doc fix.
Kenichi Handa <handa@m17n.org>
parents: 24467
diff changeset
6 ;; Keywords: wp, BDF, font, PostScript
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
7 ;; Maintainer: Kenichi Handa <handa@etl.go.jp>
24416
3d446442b6a0 (bdf-directory-list): Initialize it to '("/usr/local/share/emacs/fonts/bdf").
Kenichi Handa <handa@m17n.org>
parents: 24087
diff changeset
8 ;; Time-stamp: <99/02/27 11:14:07 kenichi>
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
9
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
10 ;; This file is part of GNU Emacs.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
11
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
15 ;; any later version.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
16
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
20 ;; GNU General Public License for more details.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
21
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
22 ;; You should have received a copy of the GNU General Public License
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
25 ;; Boston, MA 02111-1307, USA.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
26
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
27 ;;; Commentary:
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
28
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
29 ;; Functions for getting bitmap information from X's BDF font file are
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
30 ;; provided.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
31
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
32 ;;; Code:
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
33
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
34 (eval-when-compile (require 'ps-mule))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
35
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
36 ;;;###autoload
24449
2428731823fd (bdf-directory-list): Different value for ms-dos.
Eli Zaretskii <eliz@gnu.org>
parents: 24416
diff changeset
37 (defvar bdf-directory-list
2428731823fd (bdf-directory-list): Different value for ms-dos.
Eli Zaretskii <eliz@gnu.org>
parents: 24416
diff changeset
38 (if (eq system-type 'ms-dos)
24450
60d1fad41645 (bdf-directory-list): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 24449
diff changeset
39 (list (expand-file-name "fonts/bdf" installation-directory))
24449
2428731823fd (bdf-directory-list): Different value for ms-dos.
Eli Zaretskii <eliz@gnu.org>
parents: 24416
diff changeset
40 '("/usr/local/share/emacs/fonts/bdf"))
24416
3d446442b6a0 (bdf-directory-list): Initialize it to '("/usr/local/share/emacs/fonts/bdf").
Kenichi Handa <handa@m17n.org>
parents: 24087
diff changeset
41 "*List of directories to search for `BDF' font files.
24467
4d5aae556ba8 (bdf-directory-list): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 24450
diff changeset
42 The default value is '(\"/usr/local/share/emacs/fonts/bdf\").")
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
43
24450
60d1fad41645 (bdf-directory-list): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 24449
diff changeset
44 ;; MS-DOS users like to move the binary around after it's built, but
60d1fad41645 (bdf-directory-list): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 24449
diff changeset
45 ;; the value above is computed at loadup time.
60d1fad41645 (bdf-directory-list): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 24449
diff changeset
46 (and (eq system-type 'ms-dos)
60d1fad41645 (bdf-directory-list): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 24449
diff changeset
47 (setq bdf-directory-list
60d1fad41645 (bdf-directory-list): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 24449
diff changeset
48 (list (expand-file-name "fonts/bdf" installation-directory))))
60d1fad41645 (bdf-directory-list): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 24449
diff changeset
49
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
50 (defun bdf-expand-file-name (bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
51 "Return an abosolute path name of a `BDF' font file BDFNAME.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
52 It searches directories listed in the variable `bdf-directory-list'
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
53 for BDFNAME."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
54 (if (file-name-absolute-p bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
55 (and (file-readable-p bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
56 bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
57 (let ((dir-list bdf-directory-list)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
58 dir)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
59 (while (and dir-list
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
60 (progn
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
61 (setq dir (expand-file-name bdfname (car dir-list)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
62 (not (file-readable-p dir))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
63 (setq dir nil
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
64 dir-list (cdr dir-list)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
65 dir)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
66
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
67 (defsubst bdf-file-mod-time (filename)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
68 "Return modification time of FILENAME.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
69 The value is a list of two integers, the first integer has high-order
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
70 16 bits, the second has low 16 bits."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
71 (nth 5 (file-attributes filename)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
72
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
73 (defun bdf-file-newer-than-time (filename mod-time)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
74 "Return non-nil if and only if FILENAME is newer than MOD-TIME.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
75 MOD-TIME is a modification time as a list of two integers, the first
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
76 integer has high-order 16 bits, the second has low 16 bits."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
77 (let ((file-name (bdf-expand-file-name filename)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
78 (and file-name
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
79 (let* ((new-mod-time (bdf-file-mod-time file-name))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
80 (new-time (car new-mod-time))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
81 (time (car mod-time)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
82 (or (> new-time time)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
83 (and (= new-time time)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
84 (> (nth 1 new-mod-time) (nth 1 mod-time))))))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
85
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
86 (defun bdf-find-file (bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
87 "Return a buffer visiting a bdf file BDFNAME.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
88 If BDFNAME is not an absolute path, directories listed in
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
89 `bdf-directory-list' is searched.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
90 If BDFNAME doesn't exist, return nil."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
91 (let ((file-name (bdf-expand-file-name bdfname)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
92 (and file-name
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
93 (let ((buf (generate-new-buffer " *bdf-work*"))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
94 (coding-system-for-read 'no-conversion))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
95 (save-excursion
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
96 (set-buffer buf)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
97 (insert-file-contents file-name)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
98 buf)))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
99
24087
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
100 (defvar bdf-cache-file (convert-standard-filename "~/.bdfcache.el")
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
101 "Name of cache file which contains information of `BDF' font files.")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
102
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
103 (defvar bdf-cache nil
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
104 "Cached information of `BDF' font files. It is a list of FONT-INFO.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
105 FONT-INFO is a list of the following format:
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
106 (BDFFILE ABSOLUTE-PATH MOD-TIME SIZE FONT-BOUNDING-BOX
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
107 RELATIVE-COMPOSE BASELINE-OFFSET CODE-RANGE MAXLEN OFFSET-VECTOR)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
108 See the documentation of the function `bdf-read-font-info' for more detail.")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
109
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
110 (defun bdf-read-cache ()
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
111 "Return a cached information about `BDF' font files from a cache file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
112 The variable `bdf-cache-file' holds the cache file name.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
113 If the cache file is not readable, this return nil."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
114 (setq bdf-cache nil)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
115 (condition-case nil
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
116 (and (file-readable-p bdf-cache-file)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
117 (progn
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
118 (load-file bdf-cache-file)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
119 (if (listp bdf-cache)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
120 bdf-cache
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
121 (setq bdf-cache nil))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
122 (error nil)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
123
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
124 (defun bdf-write-cache ()
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
125 "Write out cached information of `BDF' font file to a file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
126 The variable `bdf-cache-file' holds the cache file name.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
127 The file is written if and only if the file alreay exists and writable."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
128 (and bdf-cache
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
129 (file-exists-p bdf-cache-file)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
130 (file-writable-p bdf-cache-file)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
131 (write-region (format "(setq bdf-cache '%S)\n" bdf-cache)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
132 nil bdf-cache-file)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
133
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
134 (defun bdf-set-cache (font-info)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
135 "Cache FONT-INFO as information about one `BDF' font file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
136 FONT-INFO is a list of the following format:
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
137 (BDFFILE ABSOLUTE-PATH MOD-TIME SIZE FONT-BOUNDING-BOX
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
138 RELATIVE-COMPOSE BASELINE-OFFSET CODE-RANGE MAXLEN OFFSET-VECTOR)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
139 See the documentation of the function `bdf-read-font-info' for more detail."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
140 (let ((slot (assoc (car font-info) bdf-cache)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
141 (if slot
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
142 (setcdr slot (cdr font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
143 (setq bdf-cache (cons font-info bdf-cache)))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
144
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
145 (defun bdf-initialize ()
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
146 "Initialize `bdf' library."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
147 (and (bdf-read-cache)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
148 (add-hook 'kill-emacs-hook 'bdf-write-cache)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
149
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
150 (defun bdf-compact-code (code code-range)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
151 (if (or (< code (aref code-range 4))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
152 (> code (aref code-range 5)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
153 (setq code (aref code-range 6)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
154 (+ (* (- (lsh code -8) (aref code-range 0))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
155 (1+ (- (aref code-range 3) (aref code-range 2))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
156 (- (logand code 255) (aref code-range 2))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
157
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
158 (defun bdf-expand-code (code code-range)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
159 (let ((code0-range (1+ (- (aref code-range 3) (aref code-range 2)))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
160 (+ (* (+ (/ code code0-range) (aref code-range 0)) 256)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
161 (+ (% code code0-range) (aref code-range 2)))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
162
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
163 (defun bdf-search-and-read (match limit)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
164 (goto-char (point-min))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
165 (and (search-forward match limit t)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
166 (progn
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
167 (goto-char (match-end 0))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
168 (read (current-buffer)))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
169
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
170 (defun bdf-read-font-info (bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
171 "Read `BDF' font file BDFNAME and return information (FONT-INFO) of the file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
172 FONT-INFO is a list of the following format:
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
173 (BDFFILE ABSOLUTE-PATH MOD-TIME FONT-BOUNDING-BOX
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
174 RELATIVE-COMPOSE BASELINE-OFFSET CODE-RANGE MAXLEN OFFSET-VECTOR)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
175
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
176 BDFFILE is a name of a font file (excluding directory part).
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
177
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
178 ABSOLUTE-PATH is an absolute path of the font file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
179
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
180 MOD-TIME is last modification time as a list of two integers, the
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
181 first integer has high-order 16 bits, the second has low 16 bits.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
182
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
183 SIZE is a size of the font. This value is got from SIZE record of the
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
184 font.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
185
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
186 FONT-BOUNDING-BOX is the font bounding box as a list of four integers,
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
187 BBX-WIDTH, BBX-HEIGHT, BBX-XOFF, and BBX-YOFF.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
188
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
189 RELATIVE-COMPOSE is an integer value of the font's property
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
190 `_MULE_RELATIVE_COMPOSE'. If the font doesn't have this property, the
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
191 value is 0.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
192
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
193 BASELINE-OFFSET is an integer value of the font's property
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
194 `_MULE_BASELINE_OFFSET'. If the font doesn't have this property, the
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
195 value is 0.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
196
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
197 CODE-RANGE is a vector of minimum 1st byte, maximum 1st byte, minimum
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
198 2nd byte, maximum 2nd byte, minimum code, maximum code, and default
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
199 code. For 1-byte fonts, the first two elements are 0.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
200
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
201 MAXLEN is a maximum bytes of one glyph informaion in the font file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
202
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
203 OFFSET-VECTOR is a vector of a file position which starts bitmap data
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
204 of the glyph in the font file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
205
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
206 Nth element of OFFSET-VECTOR is a file position for the glyph of code
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
207 CODE, where N and CODE are in the following relation:
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
208 (bdf-compact-code CODE) => N, (bdf-expand-code N) => CODE"
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
209 (let* ((absolute-path (bdf-expand-file-name bdfname))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
210 (buf (and absolute-path (bdf-find-file absolute-path)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
211 (maxlen 0)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
212 (relative-compose 'false)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
213 (baseline-offset 0)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
214 size
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
215 font-bounding-box
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
216 default-char
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
217 code-range
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
218 offset-vector)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
219 (if buf
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
220 (message "Reading %s..." bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
221 (error "BDF file %s doesn't exist" bdfname))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
222 (unwind-protect
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
223 (save-excursion
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
224 (set-buffer buf)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
225 (goto-char (point-min))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
226 (search-forward "\nFONTBOUNDINGBOX")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
227 (setq font-bounding-box
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
228 (vector (read (current-buffer)) (read (current-buffer))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
229 (read (current-buffer)) (read (current-buffer))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
230 ;; The following kludgy code is to avoid bugs of fonts
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
231 ;; jiskan16.bdf and jiskan24.bdf distributed with X.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
232 ;; They contain wrong FONTBOUNDINGBOX.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
233 (and (> (aref font-bounding-box 3) 0)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
234 (string-match "jiskan\\(16\\|24\\)" bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
235 (aset font-bounding-box 3
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
236 (- (aref font-bounding-box 3))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
237
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
238 (goto-char (point-min))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
239 (search-forward "\nSIZE ")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
240 (setq size (read (current-buffer)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
241 ;; The following kludgy code is t avoid bugs of several
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
242 ;; fonts which have wrong SIZE record.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
243 (and (<= size (/ (aref font-bounding-box 1) 2))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
244 (setq size (aref font-bounding-box 1)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
245
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
246 (setq default-char (bdf-search-and-read "\nDEFAULT_CHAR" nil))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
247
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
248 (search-forward "\nSTARTCHAR")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
249 (forward-line -1)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
250 (let ((limit (point)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
251 (setq relative-compose
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
252 (or (bdf-search-and-read "\n_MULE_RELATIVE_COMPOSE" limit)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
253 'false)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
254 baseline-offset
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
255 (or (bdf-search-and-read "\n_MULE_BASELINE_OFFSET" limit)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
256 0)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
257
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
258 (let ((min-code0 256) (min-code1 256) (min-code 65536)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
259 (max-code0 0) (max-code1 0) (max-code 0)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
260 glyph glyph-list code0 code1 code bbx offset)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
261
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
262 (while (search-forward "\nSTARTCHAR" nil t)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
263 (setq offset (line-beginning-position))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
264 (search-forward "\nENCODING")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
265 (setq code (read (current-buffer))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
266 code0 (lsh code -8)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
267 code1 (logand code 255)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
268 min-code (min min-code code)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
269 max-code (max max-code code)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
270 min-code0 (min min-code0 code0)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
271 max-code0 (max max-code0 code0)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
272 min-code1 (min min-code1 code1)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
273 max-code1 (max max-code1 code1))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
274 (search-forward "ENDCHAR")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
275 (setq maxlen (max maxlen (- (point) offset))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
276 glyph-list (cons (cons code offset) glyph-list)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
277
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
278 (setq code-range
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
279 (vector min-code0 max-code0 min-code1 max-code1
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
280 min-code max-code (or default-char min-code))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
281 offset-vector
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
282 (make-vector (1+ (bdf-compact-code max-code code-range))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
283 nil))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
284
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
285 (while glyph-list
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
286 (setq glyph (car glyph-list)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
287 glyph-list (cdr glyph-list))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
288 (aset offset-vector
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
289 (bdf-compact-code (car glyph) code-range)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
290 (cdr glyph)))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
291
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
292 (kill-buffer buf))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
293 (message "Reading %s...done" bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
294 (list bdfname absolute-path (bdf-file-mod-time absolute-path)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
295 size font-bounding-box relative-compose baseline-offset
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
296 code-range maxlen offset-vector)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
297
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
298 (defsubst bdf-info-absolute-path (font-info) (nth 1 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
299 (defsubst bdf-info-mod-time (font-info) (nth 2 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
300 (defsubst bdf-info-size (font-info) (nth 3 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
301 (defsubst bdf-info-font-bounding-box (font-info) (nth 4 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
302 (defsubst bdf-info-relative-compose (font-info) (nth 5 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
303 (defsubst bdf-info-baseline-offset (font-info) (nth 6 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
304 (defsubst bdf-info-code-range (font-info) (nth 7 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
305 (defsubst bdf-info-maxlen (font-info) (nth 8 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
306 (defsubst bdf-info-offset-vector (font-info) (nth 9 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
307
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
308 (defun bdf-get-font-info (bdfname)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
309 "Return information about `BDF' font file BDFNAME.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
310 The value FONT-INFO is a list of the following format:
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
311 (BDFFILE ABSOLUTE-PATH MOD-TIME SIZE FONT-BOUNDING-BOX
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
312 RELATIVE-COMPOSE BASELINE-OFFSET CODE-RANGE MAXLEN OFFSET-VECTOR)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
313 See the documentation of the function `bdf-read-font-info' for more detail."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
314 (or bdf-cache
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
315 (bdf-read-cache))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
316 (let ((font-info (assoc bdfname bdf-cache)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
317 (if (or (not font-info)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
318 (not (file-readable-p (bdf-info-absolute-path font-info)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
319 (bdf-file-newer-than-time bdfname (bdf-info-mod-time font-info)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
320 (progn
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
321 (setq font-info (bdf-read-font-info bdfname))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
322 (bdf-set-cache font-info)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
323 font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
324
24087
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
325 (defun bdf-find-font-info (bdfnames)
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
326 "Return information about `BDF' font file with alternative names BDFNAMES.
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
327
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
328 If BDFNAMES is a list of file names, this function finds the first file
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
329 in the list which exists and is readable, then calls `bdf-get-font-info'
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
330 on that file name."
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
331 (let ((fnlist bdfnames)
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
332 (fname bdfnames))
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
333 (if (consp fnlist)
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
334 (while (and fnlist
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
335 (progn
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
336 (setq fname (car fnlist))
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
337 (null (bdf-expand-file-name fname))))
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
338 (setq fname nil
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
339 fnlist (cdr fnlist))))
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
340 (bdf-get-font-info (or fname (car bdfnames)))))
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
341
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
342 (defun bdf-read-bitmap (bdfname offset maxlen)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
343 "Read `BDF' font file BDFNAME to get bitmap data at file poistion OFFSET.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
344 BDFNAME is an abosolute path name of the font file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
345 MAXLEN specifies how many bytes we should read at least.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
346 The value is a list of DWIDTH, BBX, and BITMAP-STRING.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
347 DWIDTH is a pixel width of a glyph.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
348 BBX is a bounding box of the glyph.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
349 BITMAP-STRING is a string representing bits by hexadecimal digits."
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
350 (let ((coding-system-for-read 'no-conversion)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
351 dwidth bbx height yoff bitmap-string)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
352 (condition-case nil
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
353 (with-temp-buffer
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
354 (insert-file-contents bdfname nil offset (+ offset maxlen))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
355 (goto-char (point-min))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
356 (search-forward "\nDWIDTH")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
357 (setq dwidth (read (current-buffer)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
358 (goto-char (point-min))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
359 (search-forward "\nBBX")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
360 (setq bbx (vector (read (current-buffer)) (read (current-buffer))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
361 (read (current-buffer)) (read (current-buffer)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
362 height (aref bbx 1) yoff (aref bbx 3))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
363 (search-forward "\nBITMAP")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
364 (forward-line 1)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
365 (delete-region (point-min) (point))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
366 (and (looking-at "\\(0+\n\\)+")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
367 (progn
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
368 (setq height (- height (count-lines (point) (match-end 0))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
369 (delete-region (point) (match-end 0))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
370 (or (looking-at "ENDCHAR")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
371 (progn
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
372 (search-forward "ENDCHAR" nil 'move)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
373 (forward-line -1)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
374 (while (looking-at "0+$")
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
375 (setq yoff (1+ yoff)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
376 height (1- height))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
377 (forward-line -1))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
378 (forward-line 1)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
379 (aset bbx 1 height)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
380 (aset bbx 3 yoff)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
381 (delete-region (point) (point-max))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
382 (goto-char (point-min))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
383 (while (not (eobp))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
384 (end-of-line)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
385 (delete-char 1))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
386 (setq bitmap-string (buffer-string)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
387 (error nil))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
388 (list dwidth bbx bitmap-string)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
389
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
390 (defun bdf-get-bitmaps (bdfname codes)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
391 "Return bitmap information of glyphs of CODES in `BDF' font file BDFNAME.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
392 CODES is a list of encoding number of glyphs in the file.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
393 The value is a list of CODE, DWIDTH, BBX, and BITMAP-STRING.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
394 DWIDTH is a pixel width of a glyph.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
395 BBX is a bounding box of the glyph.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
396 BITMAP-STRING is a string representing bits by hexadecimal digits."
24087
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
397 (let* ((font-info (bdf-find-font-info bdfname))
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
398 (absolute-path (bdf-info-absolute-path font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
399 (font-bounding-box (bdf-info-font-bounding-box font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
400 (maxlen (bdf-info-maxlen font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
401 (code-range (bdf-info-code-range font-info))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
402 (offset-vector (bdf-info-offset-vector font-info)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
403 (mapcar '(lambda (x)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
404 (cons x (bdf-read-bitmap
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
405 absolute-path
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
406 (aref offset-vector (bdf-compact-code x code-range))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
407 maxlen)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
408 codes)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
409
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
410 ;;; Interface to ps-print.el
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
411
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
412 ;; Called from ps-mule-init-external-library.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
413 (defun bdf-generate-prologue ()
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
414 (or bdf-cache
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
415 (bdf-initialize))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
416 (ps-mule-generate-bitmap-prologue))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
417
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
418 ;; Called from ps-mule-generate-font.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
419 (defun bdf-generate-font (charset font-spec)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
420 (let* ((font-name (ps-mule-font-spec-name font-spec))
24087
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
421 (font-info (bdf-find-font-info font-name))
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
422 (font-name (if (consp font-name) (car font-name) font-name)))
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
423 (ps-mule-generate-bitmap-font font-name
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
424 (ps-mule-font-spec-bytes font-spec)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
425 (charset-width charset)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
426 (bdf-info-size font-info)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
427 (bdf-info-relative-compose font-info)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
428 (bdf-info-baseline-offset font-info)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
429 (bdf-info-font-bounding-box font-info))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
430
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
431 ;; Called from ps-mule-generate-glyphs.
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
432 (defun bdf-generate-glyphs (font-spec code-list bytes)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
433 (let ((font-name (ps-mule-font-spec-name font-spec)))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
434 (mapcar '(lambda (x)
24087
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
435 (apply 'ps-mule-generate-bitmap-glyph
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
436 (if (consp font-name) (car font-name) font-name)
dd3bd06af523 (bdf-cache-file): Use convert-standard-filename.
Eli Zaretskii <eliz@gnu.org>
parents: 23896
diff changeset
437 x))
23896
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
438 (bdf-get-bitmaps font-name code-list))))
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
439
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
440 (provide 'ps-bdf)
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
441
c0c441b28347 File name changed from bdf.el. Provide ps-bdf
Kenichi Handa <handa@m17n.org>
parents: 23895
diff changeset
442 ;;; ps-bdf.el ends here