]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4866/1: Improve OTC fonts support
authorMasamichi Hosoda <trueroad@trueroad.jp>
Sun, 12 Jun 2016 10:25:28 +0000 (19:25 +0900)
committerMasamichi Hosoda <trueroad@trueroad.jp>
Sat, 18 Jun 2016 10:52:54 +0000 (19:52 +0900)
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

index 9dc8414bbfe608e16d7871c40ee16a07bf611d05..fe7a925d7196593f427c624c71d9e47b71e24169 100644 (file)
       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)
         ""))))