lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to determine if a font is a fallback font?


From: Cynthia Karl
Subject: Re: How to determine if a font is a fallback font?
Date: Tue, 28 Apr 2015 09:50:41 -0500

> Message: 6
> Date: Tue, 28 Apr 2015 09:48:51 +0200
> From: Urs Liska <address@hidden>
> To: Werner LEMBERG <address@hidden>
> Subject: Re: How to determine if a font is a fallback font?
> 
> Am 28.04.2015 um 09:38 schrieb Werner LEMBERG:
>>> Is there a function to retrieve the "font name" from a given file
>>> name?  It would be a viable approach if I could compare the result
>>> of that request with the original font name.
>> For TTFs and TTCs (either with TrueType outlines or embedded CFFs) you
>> can use `ly:ttf-ps-name'.
> 
> Thanks that seems to work perfectly. Try
> 
> \version  "2.19.19"
> 
> fontExists =
> #(define-void-function  (parser location font-name)(string?)
>    (let*  ((font-file (ly:font-config-get-font-file  font-name))
>           (reverse-font-name (ly:ttf-ps-name  font-file))
>           (font-exists (string=?  font-name reverse-font-name)))
>      (ly:message  (format  "\nGiven font name: ~a"  font-name))
>      (ly:message  (format  "Determined font file: ~a"  font-file))
>      (ly:message  (format  "Actual font in that file: ~a"  reverse-font-name))
>      (ly:message  (format  "Given font is present: ~a"  font-exists))))
> 
> \fontExists  "Emmentaler-13"
> \fontExists  "Fancy-Font"
> 
> 
>> 
>> Looking into lilypond's code, however, I don't see why this shouldn't
>> work for Type1 fonts (or even pure CFFs) also.  It's worth a try ? and
>> if it works, we should provide an alias name for `ly:ttf-ps-name'.
> 
> I don't know how to proceed with this.
> 
> However, in the context of my current patch I will add a variant of the 
> above function to font.scm.

I tried the above snippet with:

\fontExists  "Emmentaler-13"
\fontExists  "Fancy-Font"
\fontExists "Ariel"
\fontExists "Ariel Black"
\fontExists "LucindaGrande"
\fontExists "Feta-13"
\fontExists "Minion Pro"
\fontExists "Century Schoolbook"
\fontExists “Avenir”

In each case, even for the case “LucindaGrande”, I get (with the correct Given 
font name):

Given font name: LucindaGrande
Determined font file: /System/Library/Fonts/LucidaGrande.ttc
Actual font in that file: LucidaGrande
Given font is present: #f

That doesn’t seem right.  Any clues?  Or is it right?


> Re: How to determine if a fon
> 
> Urs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]