Function: ps-mule-plot-string

ps-mule-plot-string is a byte-compiled function defined in ps-mule.el.gz.

Signature

(ps-mule-plot-string FROM TO &optional BG-COLOR)

Documentation

Generate PostScript code for plotting characters in the region FROM and TO.

Optional argument BG-COLOR is ignored.

Returns the value:

(ENDPOS . RUN-WIDTH)

Where ENDPOS is the end position of the sequence and RUN-WIDTH is the width of the sequence.

Source Code

;; Defined in /usr/src/emacs/lisp/ps-mule.el.gz
(defun ps-mule-plot-string (from to &optional _bg-color)
  "Generate PostScript code for plotting characters in the region FROM and TO.

Optional argument BG-COLOR is ignored.

Returns the value:

	(ENDPOS . RUN-WIDTH)

Where ENDPOS is the end position of the sequence and RUN-WIDTH is the width of
the sequence."
  (let* ((average-width (ps-avg-char-width 'ps-font-for-text))
	 (point (point))
	 (composition (find-composition from to nil t))
	 (stop (if (and composition
			(not (vectorp (aref (nth 2 composition) 0))))
		   (car composition)
		 to))
	 (ascii-or-latin-1 "[\000-ÿ]+")
	 (run-width 0)
	 (endpos nil)
	 (font-spec-table (aref ps-mule-font-spec-tables
				(aref ps-mule-font-number-to-type
				      ps-current-font)))
	 width)
    (goto-char from)
    (while (not endpos)
      (cond ((>= (point) stop)
	     (if (= stop to)
		 (setq endpos stop)
	       (when (< from stop)
		 (ps-output-string (ps-mule-encode-region from (point)
							  font-spec-table))
		 (ps-output " S\n"))
	       (setq width (* (nth 5 composition) average-width))
	       (if (< ps-width-remaining (+ run-width width))
		   (setq endpos stop)
		 (ps-mule-plot-composition composition font-spec-table)
		 (setq run-width (+ run-width width)
		       from (nth 1 composition))
		 (goto-char from)
		 (setq composition (find-composition (point) to nil t))
		 (setq stop (if composition (car composition) to)))))

            ;; We fold lines that contain ASCII or Latin-1.
	    ((looking-at ascii-or-latin-1)
	     (let ((nchars (- (min (match-end 0) stop) (point))))
	       (setq width (* average-width nchars))
	       (if (< ps-width-remaining (+ run-width width))
		   (setq nchars (truncate (- ps-width-remaining run-width)
					  average-width)
			 run-width (+ run-width (* nchars average-width))
			 endpos (+ (point) nchars))
		 (setq run-width (+ run-width width))
		 (forward-char nchars))))

            ;; Don't fold other lines.  (But why?)
	    (t
	     (while (and (< (point) stop) (not endpos))
	       (setq width (char-width (following-char)))
	       (if (< ps-width-remaining (+ run-width width))
		   (setq endpos (point))
		 (setq run-width (+ run-width width))
		 (forward-char 1))))))

    (when (< from endpos)
      (ps-output-string (ps-mule-encode-region from endpos font-spec-table))
      (ps-output " S\n"))
    (goto-char point)
    (cons endpos run-width)))