1 ;;; ps-def.el --- Emacs definitions for ps-print -*- lexical-binding: t -*-
3 ;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
5 ;; Author: Vinicius Jose Latorre <viniciusjl.gnu@gmail.com>
6 ;; Kenichi Handa <handa@gnu.org> (multi-byte characters)
7 ;; Keywords: wp, print, PostScript
8 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
28 ;; See ps-print.el for documentation.
32 (declare-function ps-plot-with-face
"ps-print" (from to face
))
33 (declare-function ps-plot-string
"ps-print" (string))
35 (defvar ps-bold-faces
) ; in ps-print.el
36 (defvar ps-italic-faces
)
41 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 (defun ps-mark-active-p ()
50 (defun ps-face-foreground-name (face)
51 (face-foreground face nil t
))
54 (defun ps-face-background-name (face)
55 (face-background face nil t
))
58 (defalias 'ps-frame-parameter
'frame-parameter
)
60 ;; Return t if the device (which can be changed during an emacs session) can
61 ;; handle colors. This function is not yet implemented for GNU emacs.
62 (defun ps-color-device ()
63 (if (fboundp 'color-values
)
64 (funcall 'color-values
"Green")
68 (defun ps-color-values (x-color)
70 ((fboundp 'color-values
)
71 (funcall 'color-values x-color
))
72 ((fboundp 'x-color-values
)
73 (funcall 'x-color-values x-color
))
75 (error "No available function to determine X color values"))))
78 (defun ps-face-bold-p (face)
79 (or (face-bold-p face
)
80 (memq face ps-bold-faces
)))
83 (defun ps-face-italic-p (face)
84 (or (face-italic-p face
)
85 (memq face ps-italic-faces
)))
88 (defun ps-face-strikeout-p (face)
89 (eq (face-attribute face
:strike-through
) t
))
92 (defun ps-face-overline-p (face)
93 (eq (face-attribute face
:overline
) t
))
96 (defun ps-face-box-p (face)
97 (not (memq (face-attribute face
:box
) '(nil unspecified
))))
100 ;; Emacs understands the %f format; we'll use it to limit color RGB values
101 ;; to three decimals to cut down some on the size of the PostScript output.
102 (defvar ps-color-format
"%0.3f %0.3f %0.3f")
103 (defvar ps-float-format
"%0.3f ")
106 (defun ps-generate-postscript-with-faces1 (from to
)
107 ;; Generate some PostScript.
108 (let ((face 'default
)
111 (property-change from
)
112 (overlay-change from
)
113 before-string after-string
)
115 (and (< property-change to
) ; Don't search for property change
116 ; unless previous search succeeded.
117 (setq property-change
(next-property-change from nil to
)))
118 (and (< overlay-change to
) ; Don't search for overlay change
119 ; unless previous search succeeded.
120 (setq overlay-change
(min (next-overlay-change from
)
122 (setq position
(min property-change overlay-change
)
126 (cond ((invisible-p from
)
127 'emacs--invisible--face
)
128 ((get-char-property from
'face
))
130 ;; Plot up to this record.
132 (ps-plot-string before-string
))
133 (ps-plot-with-face from position face
)
135 (ps-plot-string after-string
))
136 (setq from position
))
137 (ps-plot-with-face from to face
)))
140 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144 ;;; ps-def.el ends here