(define-fonts paper ps-define-font ps-define-pango-pf)
(output-variables paper)))
+(define never-embed-font-list (list))
+
(define (cff-font? font)
(let* ((cff-string (ly:otf-font-table-data font "CFF ")))
(> (string-length cff-string) 0)))
(footer "\n%%EndData
%%EndResource
%%EndResource\n"))
- (string-append header
- binary-data
- footer)))
+ (begin
+ (set! never-embed-font-list
+ (append never-embed-font-list (list font-set-name)))
+ (string-append header
+ binary-data
+ footer))))
(define check-conflict-and-embed-cff
(let ((font-list '()))
(define (load-font-via-GS font-name-filename)
(define (is-collection-font? file-name)
- (let ((port (open-file file-name "rb")))
- (if (eq? (read-char port) #\t)
- (if (eq? (read-char port) #\t)
- (if (eq? (read-char port) #\c)
- (if (eq? (read-char port) #\f)
- #t
- #f)
- #f)
- #f)
- #f)))
+ (let* ((port (open-file file-name "rb"))
+ (retval
+ (if (eq? (read-char port) #\t)
+ (if (eq? (read-char port) #\t)
+ (if (eq? (read-char port) #\c)
+ (if (eq? (read-char port) #\f)
+ #t
+ #f)
+ #f)
+ #f)
+ #f)))
+ (close-port port)
+ retval))
(define (ps-load-file file-name)
(if (string? file-name)
((and (string? bare-file-name)
(eq? (ly:get-font-format bare-file-name font-index) 'CFF)
(is-collection-font? bare-file-name))
- (ly:warning (_ "Font ~a cannot be loaded via Ghostscript because it is an OpenType/CFF (OTC) font.")
+ (ly:warning (_ "Font ~a cannot be loaded via Ghostscript because it is an OpenType/CFF Collection (OTC) font.")
name)
(load-font font-name-filename))
((and (string? bare-file-name)
(cond
((eq? font-format (string->symbol "Type 1"))
;; Type 1 (PFA and PFB) fonts
- (ly:type1->pfa file-name))
+ (begin (set! never-embed-font-list
+ (append never-embed-font-list (list name)))
+ (ly:type1->pfa file-name)))
((eq? font-format 'TrueType)
;; TrueType fonts (TTF) and TrueType Collection (TTC)
(ly:ttf->pfa file-name font-index))
port
"/lilypond-datadir where {pop} {userdict /lilypond-datadir (~a) put } ifelse"
(ly:get-option 'datadir))
+ (set! never-embed-font-list (list))
(if load-fonts?
(for-each (lambda (f)
(format port "\n%%BeginFont: ~a\n" (car f))
(display (cdr f) port)
(display "%%EndFont\n" port))
(load-fonts paper)))
+ (if (ly:get-option 'gs-never-embed-fonts)
+ (begin
+ (display "\nsystemdict /DEVICE known\n" port)
+ (display " { systemdict /DEVICE get (pdfwrite) eq {\n" port)
+ (display ".setpdfwrite << /NeverEmbed [" port)
+ (display (string-concatenate
+ (map (lambda (f) (string-append " /" f))
+ never-embed-font-list)) port)
+ (display " ] >> setdistillerparams\n" port)
+ (display " } if } if\n" port)))
(if (ly:bigpdfs)
(display (procset "encodingdefs.ps") port))
(display (setup-variables paper) port)