Function: ps-mule-begin-job

ps-mule-begin-job is an autoloaded and byte-compiled function defined in ps-mule.el.gz.

Signature

(ps-mule-begin-job FROM TO)

Documentation

Start printing job for multi-byte chars between FROM and TO.

It checks if all multi-byte characters in the region are printable or not.

Source Code

;; Defined in /usr/src/emacs/lisp/ps-mule.el.gz
;;;###autoload
(defun ps-mule-begin-job (from to)
  "Start printing job for multi-byte chars between FROM and TO.
It checks if all multi-byte characters in the region are printable or not."
  (if (and (not (find-composition from to))
	   (save-excursion
	     (goto-char from)
	     (= (skip-chars-forward "\x00-\x7F" to) to)))
      ;; All characters can be printed by normal PostScript fonts.
      (setq ps-basic-plot-string-function #'ps-basic-plot-string
            ;; FIXME: Doesn't ps-encode-header-string-function take 2 args?
	    ps-encode-header-string-function #'identity)
    (setq ps-basic-plot-string-function #'ps-mule-plot-string
	  ps-encode-header-string-function #'ps-mule-encode-header-string
	  ps-mule-font-info-database
	  (pcase ps-multibyte-buffer
	    ('non-latin-printer     ps-mule-font-info-database-ps)
	    ('bdf-font              ps-mule-font-info-database-bdf)
	    ('bdf-font-except-latin ps-mule-font-info-database-ps-bdf)
	    (_                      ps-mule-font-info-database-default)))

    ;; Be sure to have font information for Latin-1.
    (or (assq 'iso-8859-1 ps-mule-font-info-database)
	(setq ps-mule-font-info-database
	      (cons '(iso-8859-1 (normal nil nil))
		    ps-mule-font-info-database)))

    ;; Generate ps-mule-font-spec-tables.
    (let ((font-spec-alist (make-vector 4 nil))
	  (id-max 0)
	  (font-id 0)
	  font-info-list)
      ;; Generate properly ordered font-info-list from
      ;; ps-mule-font-info-database.
      (let ((charset-list
	     (copy-sequence (get-language-info current-language-environment
					       'charset))))
	(setq charset-list (cons 'iso-8859-1 (delq 'iso-8859-1 charset-list)))
	(dolist (charset charset-list)
	  (let ((font-info (assq charset ps-mule-font-info-database)))
	    (and font-info
		 (setq font-info-list (cons font-info font-info-list)))))
	(dolist (font-info ps-mule-font-info-database)
	  (or (memq (car font-info) charset-list)
	      (setq font-info-list (cons font-info font-info-list))))
	(setq font-info-list (nreverse font-info-list)))

      ;; Now font-info-list is an alist ordered by charset priority.
      ;; Store FONT-SPECs in each element of font-spec-alist.
      (dolist (font-info font-info-list)
	(let ((font-spec-vec (make-vector 4 nil))
	      (charset (car font-info))
	      encoding bytes font-spec)
	  (dolist (e (cdr font-info))
	    (setq encoding (nth 3 e) bytes (nth 4 e))
	    (unless encoding
	      (setq encoding charset bytes (charset-dimension charset)))
	    (setq font-spec (vector id-max charset font-id
				    (nth 1 e) (nth 2 e) encoding
				    (or bytes 1) nil)
		  id-max (1+ id-max))
	    (if (ps-mule-check-font font-spec)
		(aset font-spec-vec
		      (pcase (car e)
			('normal 0)
			('bold   1)
			('italic 2)
			(_       3))
		      font-spec)))
	  (when (aref font-spec-vec 0)
	    (or (aref font-spec-vec 3)
		(aset font-spec-vec 3 (or (aref font-spec-vec 1)
					  (aref font-spec-vec 2)
					  (aref font-spec-vec 0))))
	    (or (aref font-spec-vec 1)
		(aset font-spec-vec 1 (aref font-spec-vec 0)))
	    (or (aref font-spec-vec 2)
		(aset font-spec-vec 2 (aref font-spec-vec 1)))
	    (dotimes (i 4)
	      (aset font-spec-alist i
		    (nconc (aref font-spec-alist i)
			   (list (cons charset (aref font-spec-vec i))))))
	    (setq font-id (1+ font-id)))))

      ;; Make four FONT-SPEC-TABLEs and set them in
      ;; ps-mule-font-spec-tables.  Each char table has one extra slot
      ;; whose value is an element of font-spec-alist.
      (setq ps-mule-font-spec-tables (make-vector 4 nil))
      (put 'font-spec-table 'char-table-extra-slots 1)
      (dotimes (i 4)
	(let ((table (make-char-table 'font-spec-table)))
	  (aset ps-mule-font-spec-tables i table)
	  (set-char-table-extra-slot table 0 (aref font-spec-alist i))
	  ;; Be sure to have glyphs for "0123456789/" in advance for
	  ;; page numbering.
	  (let ((str " 0123456789/"))
	    (dotimes (i (length str))
	      (or (vectorp (ps-mule-get-font-spec (aref str i) table nil))
		  (error "ASCII font not available")))))))

    (ps-mule-prologue-generated)
    (if (find-composition from to)
	(ps-mule-composition-prologue-generated))))