summaryrefslogtreecommitdiff
path: root/scm
diff options
context:
space:
mode:
authorMasamichi Hosoda <trueroad@trueroad.jp>2016-06-28 18:44:49 +0900
committerMasamichi Hosoda <trueroad@trueroad.jp>2016-07-04 21:47:36 +0900
commiteda66de049d33031a3230dfbf5735399bf2c1d60 (patch)
treeb4733f69b3924e20479d1367ba3e137b5b9320dd /scm
parent2291f61e0d7acd637cd003c8c50cc82af4336273 (diff)
Issue 4909/2: Add checking conflicts between CFF flavored fonts
This commit adds checking conflicts between fonts which have same name in 'CFF' table but different name in 'name' table.
Diffstat (limited to 'scm')
-rw-r--r--scm/framework-ps.scm27
1 files changed, 26 insertions, 1 deletions
diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm
index 36c4dda9cb..8221e5eab3 100644
--- a/scm/framework-ps.scm
+++ b/scm/framework-ps.scm
@@ -245,6 +245,31 @@
binary-data
footer)))
+(define check-conflict-and-embed-cff
+ (let ((font-list '()))
+ (lambda (name file-name font-index)
+ (let* ((name-symbol (string->symbol name))
+ (args-filename-offset
+ (cons file-name (ly:get-cff-offset file-name font-index)))
+ (found-filename-offset (assq name-symbol font-list)))
+ (if found-filename-offset
+ (begin
+ (if (equal? args-filename-offset (cdr found-filename-offset))
+ (ly:debug
+ (_ "CFF font `~a' already embedded, skipping.")
+ name)
+ (ly:warning
+ (_ "Different CFF fonts which have the same name `~a' has been detected. The font cannot be embedded.")
+ name))
+ "")
+ (begin
+ (ly:debug
+ (_ "Embedding CFF font `~a'")
+ name)
+ (set! font-list
+ (acons name-symbol args-filename-offset font-list))
+ (ps-embed-cff (ly:otf->cff file-name font-index) name 0)))))))
+
(define (write-preamble paper load-fonts? port)
(define (internal-font? font-name-filename)
(let* ((font (car font-name-filename))
@@ -373,7 +398,7 @@
(ly:ttf->pfa file-name font-index))
((eq? font-format 'CFF)
;; OpenType/CFF fonts (OTF) and OpenType/CFF Collection (OTC)
- (ps-embed-cff (ly:otf->cff file-name font-index) name 0))
+ (check-conflict-and-embed-cff name file-name font-index))
(else
(ly:warning (_ "do not know how to embed ~S=~S") name file-name)
""))))