Function: woman-change-fonts

woman-change-fonts is a byte-compiled function defined in woman.el.gz.

Signature

(woman-change-fonts)

Documentation

Process font changes.

Source Code

;; Defined in /usr/src/emacs/lisp/woman.el.gz
(defun woman-change-fonts ()
  "Process font changes."
  ;; ***** NEEDS REVISING IF IT WORKS OK *****
  ;; Paragraph .LP/PP/HP/IP/TP and font .B/.BI etc. macros reset font.
  ;; Should .SH/.SS reset font?
  ;; Font size setting macros (?) should reset font.
  (let ((font-alist woman-font-alist) ; for local updating
	(previous-pos (point))
	(previous-font 'default)
	(current-font 'default))
    (while
	;; Find font requests, paragraph macros and font escapes:
	(re-search-forward
	 "^[.'][ \t]*\\(\\(ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)" nil 1)
      (let (font beg notfont fescape)
	;; Match font indicator and leave point at end of sequence:
	(cond ((match-beginning 2)
	       ;; .ft request found
	       (setq beg (match-beginning 0))
	       (skip-chars-forward " \t")
	       (if (eolp)		; default is previous font
		   (setq font previous-font)
		 (looking-at "[^ \t\n]+"))
	       (forward-line))		; end of control line and \n
	      ((match-beginning 3)
	       ;; Macro that resets font found
	       (setq font 'default))
	      ((match-beginning 4)
	       ;; \f escape found
	       (setq beg (match-beginning 0)
                     fescape t)
	       (woman-match-name))
	      (t (setq notfont t)))
	(unless notfont
	  ;; Get font name:
	  (or font
	      (let ((fontstring (match-string 0)))
		(setq font (assoc fontstring font-alist)
		      ;; NB: font-alist contains VARIABLE NAMES.
		      font (if font
			       (cdr font)
			     (WoMan-warn "Unknown font %s." fontstring)
			     ;; Output this message once only per call ...
			     (setq font-alist
				   (cons (cons fontstring 'woman-unknown)
					 font-alist))
			     'woman-unknown)
		      )))
	  ;; Delete font control line or escape sequence:
	  (cond (beg (delete-region beg (point))
		     (if (eq font 'previous) (setq font previous-font))))
          ;; Deal with things like \fB.cvsrc\fR at the start of a line.
          ;; After removing the font control codes, this would
          ;; otherwise match woman-request-regexp. The "\\&" which is
          ;; inserted to prevent this is removed by woman2-process-escapes.
          (and fescape
               (looking-at woman-request-regexp)
               (insert "\\&"))
	  (woman-set-face previous-pos (point) current-font)
	  (if beg
	      ;; Explicit font control
	      (setq previous-pos (point)
		    previous-font current-font)
	    ;; Macro that resets font
	    ;; (forward-line)		; DOES NOT WORK!  but unnecessary?
	    ;; Must process font changes in any paragraph tag!
	    (setq previous-pos (point)
		  previous-font 'default))
	  (setq current-font font)
	  )))
    ;; Set font after last request up to eob:
    (woman-set-face previous-pos (point) current-font)))