[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Add ly:get-font-format to get the font format (issue 296350043 by ad
From: |
trueroad |
Subject: |
Re: Add ly:get-font-format to get the font format (issue 296350043 by address@hidden) |
Date: |
Sat, 04 Jun 2016 03:31:47 -0700 |
LGTM, but note that FreeType's `FT_Get_Font_Format` doesn't really
return the
font format but the name of the module used to handle a font. In
particular, it
doesn't make a difference between PFA and PFB.
My main purpose was the distinction between the TTC and OTC.
So this patch cannot distinguish between the PFA and PFB.
Such a function could be then used to rewrite `font-file-as-ps-string`
to avoid
any dependency on the file extension.
I'm trying the following `font-file-as-ps-string' with this Patch Set 2.
```
(define (font-file-as-ps-string name file-name font-index)
(let* ((downcase-file-name (string-downcase file-name)))
(cond
((and file-name (string-endswith downcase-file-name ".pfa"))
(embed-document file-name))
((and file-name (string-endswith downcase-file-name ".pfb"))
(ly:pfb->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
(else
(ly:warning (_ "do not know how to embed ~S=~S") name file-name)
""))))
```
Wouldn't it be better to return a symbol instead?
I've uploaded Patch Set 2 that uses a symbol instead of a string.
https://codereview.appspot.com/296350043/