Function: bdf-read-bitmap

bdf-read-bitmap is a byte-compiled function defined in ps-bdf.el.gz.

Signature

(bdf-read-bitmap BDFNAME OFFSET MAXLEN RELATIVE-COMPOSE)

Documentation

Read BDF font file BDFNAME to get bitmap data at file position OFFSET.

BDFNAME is an absolute path name of the font file. MAXLEN specifies how many bytes we should read at least. The value is a list of DWIDTH, BBX, and BITMAP-STRING. 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.

Source Code

;; Defined in /usr/src/emacs/lisp/ps-bdf.el.gz
(defun bdf-read-bitmap (bdfname offset maxlen relative-compose)
  "Read `BDF' font file BDFNAME to get bitmap data at file position OFFSET.
BDFNAME is an absolute path name of the font file.
MAXLEN specifies how many bytes we should read at least.
The value is a list of DWIDTH, BBX, and BITMAP-STRING.
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* ((coding-system-for-read 'no-conversion)
	 (bbx (bdf-info-font-bounding-box (bdf-get-font-info bdfname)))
	 (dwidth (elt bbx 0))
	 (bitmap-string "")
	 height yoff)
    (condition-case nil
	(with-temp-buffer
	  (insert-file-contents bdfname nil offset (+ offset maxlen))
	  (goto-char (point-min))
	  (search-forward "\nDWIDTH")
	  (setq dwidth (read (current-buffer)))
	  (if (= dwidth 0)
	      (setq dwidth 0.1))
	  (goto-char (point-min))
	  (search-forward "\nBBX")
	  (setq bbx (vector (read (current-buffer)) (read (current-buffer))
			    (read (current-buffer)) (read (current-buffer)))
		height (aref bbx 1)
		yoff (aref bbx 3))
	  (search-forward "\nBITMAP")
	  (forward-line 1)
	  (delete-region (point-min) (point))
	  (and (looking-at "\\(0+\n\\)+")
	       (progn
		 (setq height (- height (count-lines (point) (match-end 0))))
		 (delete-region (point) (match-end 0))))
	  (or (looking-at "ENDCHAR")
	      (progn
		(search-forward "ENDCHAR" nil 'move)
		(forward-line -1)
		(while (looking-at "0+$")
		  (setq yoff (1+ yoff)
			height (1- height))
		  (forward-line -1))
		(forward-line 1)))
	  (aset bbx 1 height)
	  (aset bbx 3 yoff)
	  (delete-region (point) (point-max))
	  (goto-char (point-min))
	  (while (not (eobp))
	    (end-of-line)
	    (delete-char 1))
	  (setq bitmap-string (buffer-string)))
      (error nil))
    (vector dwidth (aref bbx 0) (aref bbx 1) (aref bbx 2) (aref bbx 3)
	    (concat "<" bitmap-string ">")
	    (or relative-compose 'false))))