From 26290fcc37069b55eb26aef84c912d1c2a59e7dc Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Sun, 12 Jun 2016 19:25:28 +0900 Subject: [PATCH] Issue 4866/1: Improve OTC fonts support This commit adds to distinguish font type without filename extension, and to switch font embedding method by font type. OpenType/CFF Collection (OTC) fonts which have filename extension `*.ttc' can be used. --- scm/framework-ps.scm | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 9dc8414bbf..fe7a925d71 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -331,24 +331,17 @@ embed)) (define (font-file-as-ps-string name file-name font-index) - (let* ((downcase-file-name (string-downcase file-name))) + (let ((font-format (ly:get-font-format file-name font-index))) (cond - ((and file-name (string-endswith downcase-file-name ".pfa")) + ((eq? font-format (string->symbol "Type 1")) + ;; Type 1 (PFA and PFB) fonts (ly:type1->pfa file-name)) - ((and file-name (string-endswith downcase-file-name ".pfb")) - (ly:type1->pfa file-name)) - ((and file-name (string-endswith downcase-file-name ".ttf")) - (ly:ttf->pfa file-name)) - ((and file-name (string-endswith downcase-file-name ".ttc")) - ;; TODO: distinguish files which have extension `*.ttc' - ;; whether TrueType Collection (TTC) fonts - ;; or OpenType/CFF Collection (OTC) fonts. - (ly:ttf->pfa file-name font-index)) ;; TTC fonts - ((and file-name (string-endswith downcase-file-name ".otf")) - (ps-embed-cff (ly:otf->cff file-name) name 0)) - ((and file-name (string-endswith downcase-file-name ".otc")) - ;; The files which have the extension `*.otc' are OTC fonts. - (ps-embed-cff (ly:otf->cff file-name font-index) name 0)) ;; OTC fonts + ((eq? font-format 'TrueType) + ;; TrueType fonts (TTF) and TrueType Collection (TTC) + (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)) (else (ly:warning (_ "do not know how to embed ~S=~S") name file-name) "")))) -- 2.39.2