Re: How to determine if a font is a fallback font?
Am 29.04.2015 um 02:14 schrieb David Nalesnik: I tried this out on my VM (Ubuntu 10.04.4 -- yes, I need to update to the most recent LilyDev...) Should it work for any font that's listed by ly:font-config-display-fonts? It works for most of the names I've tried, though not all. For example. Kedage returns #f. AFAICS it should, What is the font name of Kedage? Here is a part of the output of (display (ly:font-config-display-fonts): family DejaVu Sans Mono DejaVu Sans Mono:style=Book family DejaVu Sans Mono DejaVu Sans Mono:style=Bold family Century Schoolbook L Century Schoolbook L:style=BoldItalic family Liberation Serif Liberation Serif:style=Italic family Umpush Umpush:style=BoldOblique family Kedage Kedage:style=Normal family Lohit Bengali Lohit Bengali:style=Regular I simply used the family name, so \fontExists Kedage Doing so with this list, all return #t except Kedage and Umpush. Both (display (ly:font-config-get-font-file Kedage)) and (display (ly:font-config-get-font-file Umpush)) return /usr/share/fonts/truetype/thai/TlwgTypo.ttf so I presume I am using the right name for the two fonts. You could try out with my version from the second-to-last post, which returns the plain result of the fontconfig lookup. OK, here with both Umpush and Kedage I get Tlwg Typo \fontExists Tlwg Typo does in fact return #t with the later patch. but then one of the entries from ly:font-config-display-fonts is family Tlwg Typo Tlwg Typo:style=Oblique ...so I'm pretty sure I understand nothing of what is going on here :( I assume this has to do with fontconfig not handling these special fonts. I just installed the ttf-thai-tlwg package (which installs fonts in a slightly different location on my system) which contains Umpush and the Tlwg fonts but no Kedage. Umpush and Tlwg Typo are shown in ly:font-config-display-fonts; family Umpush Umpush:style=LightOblique family Tlwg Typo Tlwg Typo:style=Bold while ly:font-config-get-font-file Umpush returns the fallback file, in my case the emmentaler-11 font file. fc-match (on the command line) correctly locates both fonts. I conclude that the lookup function used in ly:font-config-get-font-file is not absolutely correct, but has never been so. So I tend to ignore this for now and open an issue about it so it could be handled separately *if* someone has the knowledge to do so. Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 29.04.2015 um 09:42 schrieb Urs Liska: I conclude that the lookup function used in ly:font-config-get-font-file is not absolutely correct, but has never been so. So I tend to ignore this for now and open an issue about it so it could be handled separately *if* someone has the knowledge to do so. Urs Sorry, forgot to ask: Can you use these fonts the default way at all? ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
On Wed, Apr 29, 2015 at 2:45 AM, Urs Liska u...@openlilylib.org wrote: Am 29.04.2015 um 09:42 schrieb Urs Liska: I conclude that the lookup function used in ly:font-config-get-font-file is not absolutely correct, but has never been so. So I tend to ignore this for now and open an issue about it so it could be handled separately *if* someone has the knowledge to do so. Urs Sorry, forgot to ask: Can you use these fonts the default way at all? Yes--the following works just fine for me: \version 2.19.19 \paper { #(define fonts (set-global-fonts #:roman Kedage)) } \markup { \char ##x0CE7 \char ##x0CE8 \char ##x0CE9 \char ##x0CEA \char ##x0CEB \char ##x0CEC } DN ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 12:18 schrieb Werner LEMBERG: On my openSuSE GNU/Linux box, I get different results. Given font name: Emmentaler-13 Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Emmentaler-13 Determined font file: /usr/local/share/lilypond/2.19.16/fonts/otf/emmentaler-13.otf Actual font in that file: Emmentaler-13 Given font is present: #t/usr/local/share/lilypond/2.19.16/fonts/otf/emmentaler-13.otf Emmentaler-13 Given font name: Alegreya Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Alegreya Determined font file: /usr/share/fonts/truetype/Alegreya-Regular.ttf Actual font in that file: Alegreya-Regular Given font is present: #f/usr/share/fonts/truetype/Alegreya-Regular.ttf Alegreya-Regular Note that `ly:ttf-ps-name' returns the font's *PostScript* name. This is *not* what fontconfig normally operates on (but see below). Given font name: DejaVu Sans Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f/usr/share/fonts/TTF/mplus-1c-medium.ttf mplus-1c-medium Given font name: DejaVu Sans Determined font file: /usr/share/fonts/truetype/DejaVuSans.ttf Actual font in that file: DejaVuSans Given font is present: #f/usr/share/fonts/truetype/DejaVuSans.ttf DejaVuSans Same as above: `DejaVuSans' != `DejaVu Sans'. Since FontConfig version 2.11 (released October 2013), however, it is possible to search for PostScript names also. Example: $ fc-match Alegreya Alegreya-Regular.ttf: Alegreya Regular $ fc-match AlegreyaRegular arial.ttf: Arial Normal $ fc-match :postscriptname=AlegreyaRegular Alegreya-Regular.ttf: Alegreya Regular Maybe lilypond's `display_fontset' function (in font-config-scheme.cc) can be extended to display PS names also. And perhaps it makes sense to extend lilypond's font loading function to accept a font's PS name – or to provide a Scheme function wrapper for FontConfig to access a given font's PS name. As it stands I can't use this comparison either to determine if a given font is present on the user's system. I think in any case it would be good to have a pair of functions that can reliably perform the step name-file-name and return the original input as its result. Currently the input is a font name and the output is a PostScript name (just to repeat that.) From starting to look at the font- C++ files and searching the net for approaches I can think of the following possibilities: 1) Add a companion to ly:ttf-ps-name that returns the file name. Unfortunately there seems to be no equivalent to FT_Get_Postscript_Name, and from what I've seen one would have to somehow retrieve the information from FT_Get_Sfnt_Name (which clearly is over my head). 2) Modify ly:font-config-get-font-file so its return value is predictable if the font is not found. I don't fully understand what happens in that function (also because available documentation on the Freetype commands seems even harder to grasp than LilyPond's internals ...), but wouldn't it be possible to modify this so that it doesn't perform that seemingly random font If that's possible I would suggest this second approach and would like to get opinions on possible side-effects that I don't see yet. I think that in most of the cases it is very undesirable to use an arbitrary font instead of the requested font. So what I'm proposing is to change this function so that it returns #f or an empty string if the requested font doesn't exist. A modification in font.scm will then take care of handling that case properly by printing a warning and providing a proper (i.e. predictable) fallback font. In \setMusicFont (these functions are new in what I'm preparing) it would fallback to Emmentaler, in \setTextFont to the appropriate default text font. What do you think? Urs Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
On Tue, Apr 28, 2015 at 1:43 PM, Urs Liska u...@openlilylib.org wrote: Am 28.04.2015 um 20:16 schrieb David Nalesnik: Hi Urs, On Tue, Apr 28, 2015 at 11:38 AM, Urs Liska u...@openlilylib.org wrote: Am 28.04.2015 um 18:14 schrieb Urs Liska: Am 28.04.2015 um 17:53 schrieb Urs Liska: I think I have found something. After some experimenting with a copy of font-config-get-font-file and trying different approaches I could guess from the documentations available I found that replacing an item in the FcPatternGetString call this function returns the font name and not the Postscript name or the font file. The following preliminary function (if added to font-config-scheme.cc) returns either the Font Name (if the font exists) or Emmentaler-11 (on my system) if it doesn't exist. I assume it would return other names on other systems: LY_DEFINE (ly_font_config_font_exists, ly:font-config-font-exists, 1, 0, 0, ... Best Urs Wrapping this Scheme function around that: fontExists = #(define-scheme-function (parser location font-name)(string?) (string=? font-name (ly:font-config-font-exists font-name))) shows that my idea is right: The C++ function returns the family name of either the given font or the (system-dependent) fallback font. Now all there would be to it is moving the comparison of the latter Scheme function to the C++ function . Urs Last one for this working session: The following function ly:font-config-font-exists will return true or false depending on whether the given font is available. I tried this out on my VM (Ubuntu 10.04.4 -- yes, I need to update to the most recent LilyDev...) Should it work for any font that's listed by ly:font-config-display-fonts? It works for most of the names I've tried, though not all. For example. Kedage returns #f. AFAICS it should, What is the font name of Kedage? Here is a part of the output of (display (ly:font-config-display-fonts): family DejaVu Sans Mono DejaVu Sans Mono:style=Book family DejaVu Sans Mono DejaVu Sans Mono:style=Bold family Century Schoolbook L Century Schoolbook L:style=BoldItalic family Liberation Serif Liberation Serif:style=Italic family Umpush Umpush:style=BoldOblique family Kedage Kedage:style=Normal family Lohit Bengali Lohit Bengali:style=Regular I simply used the family name, so \fontExists Kedage Doing so with this list, all return #t except Kedage and Umpush. Both (display (ly:font-config-get-font-file Kedage)) and (display (ly:font-config-get-font-file Umpush)) return /usr/share/fonts/truetype/thai/TlwgTypo.ttf so I presume I am using the right name for the two fonts. You could try out with my version from the second-to-last post, which returns the plain result of the fontconfig lookup. OK, here with both Umpush and Kedage I get Tlwg Typo \fontExists Tlwg Typo does in fact return #t with the later patch. but then one of the entries from ly:font-config-display-fonts is family Tlwg Typo Tlwg Typo:style=Oblique ...so I'm pretty sure I understand nothing of what is going on here :( The only drawback (yet) is that now the comparison is case sensitive. But *that* should be easy now? I don't find anything convenient. I suppose you could just convert both strings to lower- or uppercase and then compare. An Unicode/utf8 things to consider here? Yes, there's that. I find this link: http://stackoverflow.com/questions/11635/case-insensitive-string-comparison-in-c Maybe there's something useful there. But is this desirable? I mean, is LilyPond ever case-insensitive? Well, when calling *text* fonts it has always been case insensitive. And I would like to keep that because you can't really look into the fonts to know how they are capitalized. So I'd be happy if we can make music fonts case insensitive too instead of the other way round. Makes sense to me. David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
On Tue, 28 Apr 2015 10:32:29 +0200 Thomas Morley thomasmorle...@gmail.com wrote: 2015-04-28 10:18 GMT+02:00 Urs Liska u...@openlilylib.org: Am 28.04.2015 um 10:16 schrieb Thomas Morley: - WaltDisneyScript Should I type rofl or :((( Probably a rude complaint towards the Ubuntu maintainers ;-) Given font name: Emmentaler-13 Determined font file: /usr/share/fonts/mscore/mscore-MuseJazz.ttf Actual font in that file: MuseJazz-Medium Given font is present: #f At least I get a *music* related font :) . Given font name: MuseJazz-Medium Determined font file: /usr/share/fonts/mscore/mscore-MuseJazz.ttf Actual font in that file: MuseJazz-Medium Given font is present: #t It seems that the font is present info is relevant. -- Johan ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
On 2015-04-28 12:18, Werner LEMBERG wrote: On my openSuSE GNU/Linux box, I get different results. Given font name: Emmentaler-13 Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Emmentaler-13 Determined font file: /usr/local/share/lilypond/2.19.16/fonts/otf/emmentaler-13.otf Actual font in that file: Emmentaler-13 Given font is present: #t/usr/local/share/lilypond/2.19.16/fonts/otf/emmentaler-13.otf Emmentaler-13 Given font name: Alegreya Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Alegreya Determined font file: /usr/share/fonts/truetype/Alegreya-Regular.ttf Actual font in that file: Alegreya-Regular Given font is present: #f/usr/share/fonts/truetype/Alegreya-Regular.ttf Alegreya-Regular Note that `ly:ttf-ps-name' returns the font's *PostScript* name. This is *not* what fontconfig normally operates on (but see below). I see. It's the same situation when I ask for Alegreya-Regular or DejaVuSans, though. No change at all. Also, I wonder why M+ is offered in my case; because of akobel@lap-11-06 ~/test % fc-match FOOBAR DejaVuSans.ttf: DejaVu Sans Book akobel@lap-11-06 ~/test % fc-list --version fontconfig version 2.11.1 BTW, on my Debian stable, I get: ~/test % fc-match FOOBAR Vera.ttf: Bitstream Vera Sans Roman ~/test % fc-list --version fontconfig version 2.9.0 while the test.ly offers KanjiStrokeOrders as a substitute for what it cannot find. Since FontConfig version 2.11 (released October 2013), however, it is possible to search for PostScript names also. Example: $ fc-match Alegreya Alegreya-Regular.ttf: Alegreya Regular $ fc-match AlegreyaRegular arial.ttf: Arial Normal $ fc-match :postscriptname=AlegreyaRegular Alegreya-Regular.ttf: Alegreya Regular Ditto (on Arch, with FC 2.11.1). Alexander ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 12:18 schrieb Werner LEMBERG: On my openSuSE GNU/Linux box, I get different results. Given font name: Emmentaler-13 Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Emmentaler-13 Determined font file: /usr/local/share/lilypond/2.19.16/fonts/otf/emmentaler-13.otf Actual font in that file: Emmentaler-13 Given font is present: #t/usr/local/share/lilypond/2.19.16/fonts/otf/emmentaler-13.otf Emmentaler-13 Given font name: Alegreya Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Alegreya Determined font file: /usr/share/fonts/truetype/Alegreya-Regular.ttf Actual font in that file: Alegreya-Regular Given font is present: #f/usr/share/fonts/truetype/Alegreya-Regular.ttf Alegreya-Regular Note that `ly:ttf-ps-name' returns the font's *PostScript* name. This is *not* what fontconfig normally operates on (but see below). Given font name: DejaVu Sans Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f/usr/share/fonts/TTF/mplus-1c-medium.ttf mplus-1c-medium Given font name: DejaVu Sans Determined font file: /usr/share/fonts/truetype/DejaVuSans.ttf Actual font in that file: DejaVuSans Given font is present: #f/usr/share/fonts/truetype/DejaVuSans.ttf DejaVuSans Same as above: `DejaVuSans' != `DejaVu Sans'. Since FontConfig version 2.11 (released October 2013), however, it is possible to search for PostScript names also. Example: $ fc-match Alegreya Alegreya-Regular.ttf: Alegreya Regular $ fc-match AlegreyaRegular arial.ttf: Arial Normal $ fc-match :postscriptname=AlegreyaRegular Alegreya-Regular.ttf: Alegreya Regular Maybe lilypond's `display_fontset' function (in font-config-scheme.cc) can be extended to display PS names also. And perhaps it makes sense to extend lilypond's font loading function to accept a font's PS name – or to provide a Scheme function wrapper for FontConfig to access a given font's PS name. Werner I think I have found something. After some experimenting with a copy of font-config-get-font-file and trying different approaches I could guess from the documentations available I found that replacing an item in the FcPatternGetString call this function returns the font name and not the Postscript name or the font file. The following preliminary function (if added to font-config-scheme.cc) returns either the Font Name (if the font exists) or Emmentaler-11 (on my system) if it doesn't exist. I assume it would return other names on other systems: LY_DEFINE (ly_font_config_font_exists, ly:font-config-font-exists, 1, 0, 0, (SCM name), Determing if font @var{name} exists.) { LY_ASSERT_TYPE (scm_is_string, name, 1); FcPattern *pat = FcPatternCreate (); FcValue val; val.type = FcTypeString; val.u.s = (const FcChar8 *)ly_scm2string (name).c_str (); // FC_SLANT_ITALIC; FcPatternAdd (pat, FC_FAMILY, val, FcFalse); FcResult result; SCM scm_result = SCM_BOOL_F; FcConfigSubstitute (NULL, pat, FcMatchFont); FcDefaultSubstitute (pat); pat = FcFontMatch (NULL, pat, result); FcChar8 *str = 0; if (FcPatternGetString (pat, FC_FAMILY, 0, str) == FcResultMatch) scm_result = scm_from_utf8_string ((char const *)str); FcPatternDestroy (pat); return scm_result; } Now I get stuck with C++ basics, namely types, references and pointers, but it should be possible to achieve something with the following approach: In the line scm_result = scm_from_utf ... str holds the result from this match. If this matches the originally passed name argument the return value should be set to SCM_BOOL_T. This should be dead easy, but I don't know to perform this comparison. If someone gives me a helping hand here we would get a function ly:font-config-font-exists that returns #t or #f depending on the existence of the font. Please ... Best Urs set the return value to SCM_BOOL_T if ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 13:36 schrieb Alexander Kobel: BTW, on my Debian stable, I get: ~/test % fc-match FOOBAR Vera.ttf: Bitstream Vera Sans Roman ~/test % fc-list --version fontconfig version 2.9.0 Sorry if I ask stupid questions, but: fc-match gives a list of - file name (without path) - font name - family How would it be possible to access these (particularly the second item) from a C++ function that could complement ly:ttf-ps-name? Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 16:50 schrieb Cynthia Karl: Message: 6 Date: Tue, 28 Apr 2015 09:48:51 +0200 From: Urs Liska u...@openlilylib.org To: Werner LEMBERG w...@gnu.org 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? I see that you give LucindaGrande and the retrieved font name is LucidaGrande without the *n*. Therefore the comparison returns #f. But anyway this appraoch is flawed as its input is a font name and its output the Postscript name. Currently I'm trying to wrap my head around this and try to convince Freetype/fontconfig (or C++) to determine if there is actually a non-replaced font available and to modify the return value accordingly. Urs Re: How to determine if a fon Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 17:53 schrieb Urs Liska: I think I have found something. After some experimenting with a copy of font-config-get-font-file and trying different approaches I could guess from the documentations available I found that replacing an item in the FcPatternGetString call this function returns the font name and not the Postscript name or the font file. The following preliminary function (if added to font-config-scheme.cc) returns either the Font Name (if the font exists) or Emmentaler-11 (on my system) if it doesn't exist. I assume it would return other names on other systems: LY_DEFINE (ly_font_config_font_exists, ly:font-config-font-exists, 1, 0, 0, (SCM name), Determing if font @var{name} exists.) { LY_ASSERT_TYPE (scm_is_string, name, 1); FcPattern *pat = FcPatternCreate (); FcValue val; val.type = FcTypeString; val.u.s = (const FcChar8 *)ly_scm2string (name).c_str (); // FC_SLANT_ITALIC; FcPatternAdd (pat, FC_FAMILY, val, FcFalse); FcResult result; SCM scm_result = SCM_BOOL_F; FcConfigSubstitute (NULL, pat, FcMatchFont); FcDefaultSubstitute (pat); pat = FcFontMatch (NULL, pat, result); FcChar8 *str = 0; if (FcPatternGetString (pat, FC_FAMILY, 0, str) == FcResultMatch) scm_result = scm_from_utf8_string ((char const *)str); FcPatternDestroy (pat); return scm_result; } Now I get stuck with C++ basics, namely types, references and pointers, but it should be possible to achieve something with the following approach: In the line scm_result = scm_from_utf ... str holds the result from this match. If this matches the originally passed name argument the return value should be set to SCM_BOOL_T. This should be dead easy, but I don't know to perform this comparison. If someone gives me a helping hand here we would get a function ly:font-config-font-exists that returns #t or #f depending on the existence of the font. Please ... Best Urs Wrapping this Scheme function around that: fontExists = #(define-scheme-function (parser location font-name)(string?) (string=? font-name (ly:font-config-font-exists font-name))) shows that my idea is right: The C++ function returns the family name of either the given font or the (system-dependent) fallback font. Now all there would be to it is moving the comparison of the latter Scheme function to the C++ function . Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 18:14 schrieb Urs Liska: Am 28.04.2015 um 17:53 schrieb Urs Liska: I think I have found something. After some experimenting with a copy of font-config-get-font-file and trying different approaches I could guess from the documentations available I found that replacing an item in the FcPatternGetString call this function returns the font name and not the Postscript name or the font file. The following preliminary function (if added to font-config-scheme.cc) returns either the Font Name (if the font exists) or Emmentaler-11 (on my system) if it doesn't exist. I assume it would return other names on other systems: LY_DEFINE (ly_font_config_font_exists, ly:font-config-font-exists, 1, 0, 0, ... Best Urs Wrapping this Scheme function around that: fontExists = #(define-scheme-function (parser location font-name)(string?) (string=? font-name (ly:font-config-font-exists font-name))) shows that my idea is right: The C++ function returns the family name of either the given font or the (system-dependent) fallback font. Now all there would be to it is moving the comparison of the latter Scheme function to the C++ function . Urs Last one for this working session: The following function ly:font-config-font-exists will return true or false depending on whether the given font is available. The only drawback (yet) is that now the comparison is case sensitive. But *that* should be easy now? Urs LY_DEFINE (ly_font_config_font_exists, ly:font-config-font-exists, 1, 0, 0, (SCM name), Determine if font @var{name} exists.) { LY_ASSERT_TYPE (scm_is_string, name, 1); string in_name = ly_scm2string (name).c_str (); FcPattern *pat = FcPatternCreate (); FcValue val; val.type = FcTypeString; val.u.s = (const FcChar8 *)ly_scm2string (name).c_str (); // FC_SLANT_ITALIC; FcPatternAdd (pat, FC_FAMILY, val, FcFalse); FcResult result; SCM scm_result = SCM_BOOL_F; FcConfigSubstitute (NULL, pat, FcMatchFont); FcDefaultSubstitute (pat); pat = FcFontMatch (NULL, pat, result); FcChar8 *str = 0; if ((FcPatternGetString (pat, FC_FAMILY, 0, str) == FcResultMatch) (in_name.compare((char const *)str) == 0)) scm_result = SCM_BOOL_T; FcPatternDestroy (pat); return scm_result; } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 10:28 schrieb Thomas Morley: But that shouldn't make a difference. At least we can't accept that it makes a difference. What is the result of ly:ttf-ps-name when you pass it the full path to a real emmentaler file (I can't see where they are on your system of course)? #(display (ly:font-config-get-font-file /home/harm/lilydevel/usr/share/lilypond/current/fonts/otf/emmentaler-13.otf)) -/home/harm/.fonts/wds052801.ttf This should have been #(display (ly:ttf-ps-name /home/harm/lilydevel/usr/share/lilypond/current/fonts/otf/emmentaler-13.otf)) #(display (ly:ttf-ps-name (ly:font-config-get-font-file /home/harm/lilydevel/usr/share/lilypond/current/fonts/otf/emmentaler-13.otf))) -WaltDisneyScript This is expected from the above. ... ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
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'. 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'. Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
2015-04-28 9:23 GMT+02:00 Urs Liska u...@openlilylib.org: Hi all, #(ly:font-config-get-font-file Emmentaler-13) gives me the full path to the font file used by the Emmentaler-13 font. If I use a non-existent font name, say #(ly:font-config-get-font-file SomeFont) I get a reference to emmentaler-11.otf, which is obviously used as fallback font by fontconfig. However, a Windows user reported that the same references marlett.ttf on his system. On my very old and outdated Ubuntu-system #(display (ly:font-config-get-font-file emmentaler-13.otf)) in a lily-file returns: /home/harm/.fonts/wds052801.ttf which is surely not what I'd expect. Cheers, Harm Btw, none of the fallbacks in the file you sent privately works for me. I wanted to use this approach to determine if a requested font exists on the user's system, but now I'm not sure anymore if that's a reliable approach. Of course I can simply add the check for marlett.ttf, but I have the impression that the returned fallback font isn't hard-coded but can vary with the user's installation or font availability. So: 1) Does anyone know of another approach to determine if a given font is visible to fontconfig? (I can't check for the file name because this doesn't necessarily match the font name) or 2) 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. TIA Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 10:16 schrieb Thomas Morley: - WaltDisneyScript Should I type rofl or :((( Probably a rude complaint towards the Ubuntu maintainers ;-) ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
2015-04-28 10:16 GMT+02:00 Urs Liska u...@openlilylib.org: Am 28.04.2015 um 10:12 schrieb Thomas Morley: 2015-04-28 9:48 GMT+02:00 Urs Liska u...@openlilylib.org: 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 For me this returns: Given font name: Emmentaler-13 Determined font file: /home/harm/.fonts/wds052801.ttf Actual font in that file: WaltDisneyScript Given font is present: #f Given font name: Fancy-Font Determined font file: /home/harm/.fonts/wds052801.ttf Actual font in that file: WaltDisneyScript Given font is present: #f OMG! Again, on an outdated Ubuntu. But that shouldn't make a difference. At least we can't accept that it makes a difference. What is the result of ly:ttf-ps-name when you pass it the full path to a real emmentaler file (I can't see where they are on your system of course)? #(display (ly:font-config-get-font-file /home/harm/lilydevel/usr/share/lilypond/current/fonts/otf/emmentaler-13.otf)) -/home/harm/.fonts/wds052801.ttf #(display (ly:ttf-ps-name (ly:font-config-get-font-file /home/harm/lilydevel/usr/share/lilypond/current/fonts/otf/emmentaler-13.otf))) -WaltDisneyScript ... ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 10:55 schrieb Alexander Kobel: On 2015-04-28 10:16, Urs Liska wrote: Am 28.04.2015 um 10:12 schrieb Thomas Morley: 2015-04-28 9:48 GMT+02:00 Urs Liska u...@openlilylib.org: Am 28.04.2015 um 09:38 schrieb Werner LEMBERG: For TTFs and TTCs (either with TrueType outlines or embedded CFFs) you can use `ly:ttf-ps-name'. [...] Again, on an outdated Ubuntu. But that shouldn't make a difference. At least we can't accept that it makes a difference. What is the result of ly:ttf-ps-name when you pass it the full path to a real emmentaler file (I can't see where they are on your system of course)? Hi, FWIW attached are the results on an up-to-date Arch. I'm not surprised that the Emmentaler is not found; it is not in the default search path. Hm, on my system (up-to-date Debian stable) #(display (ly:font-config-get-font-file Emmentaler-13)) -/home/uliska/git/lilypond/lilypond-builds/current/out/share/lilypond/current/fonts/otf/emmentaler-13.otf And this works with any of the LilyPond installation (means: I haven't done anything to add the directories to fontconfig's search path. These differing reports look strange to me, and I'm not happy with it. What I need is a function that returns the full path to a font file (retrieved from its font name) or #f if that font isn't present in the system. This makes it possible to let fonts fall back to Emmentaler or the default text fonts, print a warning and avoid aborting the compilation with a file-not-found error. Urs ttf-ps-name works (as Werner suspected) also for the Alegreya-OTF; but neither the DejaVu TTF nor any other font seems to be found via ly:font-config-get-font-file. BTW, appending a design size does not help. Best, Alexander ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Hi Urs, On Tue, Apr 28, 2015 at 11:38 AM, Urs Liska u...@openlilylib.org wrote: Am 28.04.2015 um 18:14 schrieb Urs Liska: Am 28.04.2015 um 17:53 schrieb Urs Liska: I think I have found something. After some experimenting with a copy of font-config-get-font-file and trying different approaches I could guess from the documentations available I found that replacing an item in the FcPatternGetString call this function returns the font name and not the Postscript name or the font file. The following preliminary function (if added to font-config-scheme.cc) returns either the Font Name (if the font exists) or Emmentaler-11 (on my system) if it doesn't exist. I assume it would return other names on other systems: LY_DEFINE (ly_font_config_font_exists, ly:font-config-font-exists, 1, 0, 0, ... Best Urs Wrapping this Scheme function around that: fontExists = #(define-scheme-function (parser location font-name)(string?) (string=? font-name (ly:font-config-font-exists font-name))) shows that my idea is right: The C++ function returns the family name of either the given font or the (system-dependent) fallback font. Now all there would be to it is moving the comparison of the latter Scheme function to the C++ function . Urs Last one for this working session: The following function ly:font-config-font-exists will return true or false depending on whether the given font is available. I tried this out on my VM (Ubuntu 10.04.4 -- yes, I need to update to the most recent LilyDev...) Should it work for any font that's listed by ly:font-config-display-fonts? It works for most of the names I've tried, though not all. For example. Kedage returns #f. The only drawback (yet) is that now the comparison is case sensitive. But *that* should be easy now? I don't find anything convenient. I suppose you could just convert both strings to lower- or uppercase and then compare. But is this desirable? I mean, is LilyPond ever case-insensitive? Thanks for working on this! David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 20:16 schrieb David Nalesnik: Hi Urs, On Tue, Apr 28, 2015 at 11:38 AM, Urs Liska u...@openlilylib.org mailto:u...@openlilylib.org wrote: Am 28.04.2015 um 18:14 schrieb Urs Liska: Am 28.04.2015 um 17:53 schrieb Urs Liska: I think I have found something. After some experimenting with a copy of font-config-get-font-file and trying different approaches I could guess from the documentations available I found that replacing an item in the FcPatternGetString call this function returns the font name and not the Postscript name or the font file. The following preliminary function (if added to font-config-scheme.cc) returns either the Font Name (if the font exists) or Emmentaler-11 (on my system) if it doesn't exist. I assume it would return other names on other systems: LY_DEFINE (ly_font_config_font_exists, ly:font-config-font-exists, 1, 0, 0, ... Best Urs Wrapping this Scheme function around that: fontExists = #(define-scheme-function (parser location font-name)(string?) (string=? font-name (ly:font-config-font-exists font-name))) shows that my idea is right: The C++ function returns the family name of either the given font or the (system-dependent) fallback font. Now all there would be to it is moving the comparison of the latter Scheme function to the C++ function . Urs Last one for this working session: The following function ly:font-config-font-exists will return true or false depending on whether the given font is available. I tried this out on my VM (Ubuntu 10.04.4 -- yes, I need to update to the most recent LilyDev...) Should it work for any font that's listed by ly:font-config-display-fonts? It works for most of the names I've tried, though not all. For example. Kedage returns #f. AFAICS it should, What is the font name of Kedage? You could try out with my version from the second-to-last post, which returns the plain result of the fontconfig lookup. The only drawback (yet) is that now the comparison is case sensitive. But *that* should be easy now? I don't find anything convenient. I suppose you could just convert both strings to lower- or uppercase and then compare. An Unicode/utf8 things to consider here? But is this desirable? I mean, is LilyPond ever case-insensitive? Well, when calling *text* fonts it has always been case insensitive. And I would like to keep that because you can't really look into the fonts to know how they are capitalized. So I'd be happy if we can make music fonts case insensitive too instead of the other way round. Urs Thanks for working on this! David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
I think I have found something. [...] Looks promising! Thanks for working on that. Note that I can help with FreeType details, but not with FontConfig issues. However, the maintainers on fontconfig's e-mail list are very responsive in case you have difficulties. Werner PS: I suggest that you move this discussion to lilypond-devel. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
How to determine if a font is a fallback font?
Hi all, #(ly:font-config-get-font-file Emmentaler-13) gives me the full path to the font file used by the Emmentaler-13 font. If I use a non-existent font name, say #(ly:font-config-get-font-file SomeFont) I get a reference to emmentaler-11.otf, which is obviously used as fallback font by fontconfig. However, a Windows user reported that the same references marlett.ttf on his system. I wanted to use this approach to determine if a requested font exists on the user's system, but now I'm not sure anymore if that's a reliable approach. Of course I can simply add the check for marlett.ttf, but I have the impression that the returned fallback font isn't hard-coded but can vary with the user's installation or font availability. So: 1) Does anyone know of another approach to determine if a given font is visible to fontconfig? (I can't check for the file name because this doesn't necessarily match the font name) or 2) 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. TIA Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
On my openSuSE GNU/Linux box, I get different results. Given font name: Emmentaler-13 Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Emmentaler-13 Determined font file: /usr/local/share/lilypond/2.19.16/fonts/otf/emmentaler-13.otf Actual font in that file: Emmentaler-13 Given font is present: #t/usr/local/share/lilypond/2.19.16/fonts/otf/emmentaler-13.otf Emmentaler-13 Given font name: Alegreya Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Alegreya Determined font file: /usr/share/fonts/truetype/Alegreya-Regular.ttf Actual font in that file: Alegreya-Regular Given font is present: #f/usr/share/fonts/truetype/Alegreya-Regular.ttf Alegreya-Regular Note that `ly:ttf-ps-name' returns the font's *PostScript* name. This is *not* what fontconfig normally operates on (but see below). Given font name: DejaVu Sans Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f/usr/share/fonts/TTF/mplus-1c-medium.ttf mplus-1c-medium Given font name: DejaVu Sans Determined font file: /usr/share/fonts/truetype/DejaVuSans.ttf Actual font in that file: DejaVuSans Given font is present: #f/usr/share/fonts/truetype/DejaVuSans.ttf DejaVuSans Same as above: `DejaVuSans' != `DejaVu Sans'. Since FontConfig version 2.11 (released October 2013), however, it is possible to search for PostScript names also. Example: $ fc-match Alegreya Alegreya-Regular.ttf: Alegreya Regular $ fc-match AlegreyaRegular arial.ttf: Arial Normal $ fc-match :postscriptname=AlegreyaRegular Alegreya-Regular.ttf: Alegreya Regular Maybe lilypond's `display_fontset' function (in font-config-scheme.cc) can be extended to display PS names also. And perhaps it makes sense to extend lilypond's font loading function to accept a font's PS name – or to provide a Scheme function wrapper for FontConfig to access a given font's PS name. Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
What is the result of ly:ttf-ps-name when you pass it the full path to a real emmentaler file (I can't see where they are on your system of course)? #(display (ly:font-config-get-font-file /home/harm/lilydevel/usr/share/lilypond/current/fonts/otf/emmentaler-13.otf)) -/home/harm/.fonts/wds052801.ttf What does lilypond -dshow-available-fonts report? For example, I find family Emmentaler-13 Emmentaler\-13:style=13 in the list. Is your lilypond font directory listed at all at the end of the output? Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
On 2015-04-28 10:16, Urs Liska wrote: Am 28.04.2015 um 10:12 schrieb Thomas Morley: 2015-04-28 9:48 GMT+02:00 Urs Liska u...@openlilylib.org: Am 28.04.2015 um 09:38 schrieb Werner LEMBERG: For TTFs and TTCs (either with TrueType outlines or embedded CFFs) you can use `ly:ttf-ps-name'. [...] Again, on an outdated Ubuntu. But that shouldn't make a difference. At least we can't accept that it makes a difference. What is the result of ly:ttf-ps-name when you pass it the full path to a real emmentaler file (I can't see where they are on your system of course)? Hi, FWIW attached are the results on an up-to-date Arch. I'm not surprised that the Emmentaler is not found; it is not in the default search path. ttf-ps-name works (as Werner suspected) also for the Alegreya-OTF; but neither the DejaVu TTF nor any other font seems to be found via ly:font-config-get-font-file. BTW, appending a design size does not help. Best, Alexander /usr/share/fonts/OTF/Alegreya-Regular.otf: Alegreya:style=Regular /usr/share/fonts/TTF/DejaVuSans.ttf: DejaVu Sans:style=Book # nope, no Emmentaler in here... \version 2.19.18 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 #(display (ly:font-config-get-font-file Emmentaler-13)) #(newline) #(display (ly:ttf-ps-name (ly:font-config-get-font-file Emmentaler-13))) #(newline) #(newline) \fontExists Alegreya #(display (ly:font-config-get-font-file Alegreya)) #(newline) #(display (ly:ttf-ps-name (ly:font-config-get-font-file Alegreya))) #(newline) #(display (ly:ttf-ps-name /usr/share/fonts/OTF/Alegreya-Regular.otf)) \fontExists DejaVu Sans #(display (ly:font-config-get-font-file DejaVu Sans)) #(newline) #(display (ly:ttf-ps-name (ly:font-config-get-font-file DejaVu Sans))) #(newline) #(display (ly:ttf-ps-name /usr/share/fonts/TTF/DejaVuSans.ttf)) GNU LilyPond 2.19.18 Processing `test.ly' Parsing... Given font name: Emmentaler-13 Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: Alegreya Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f Given font name: DejaVu Sans Determined font file: /usr/share/fonts/TTF/mplus-1c-medium.ttf Actual font in that file: mplus-1c-medium Given font is present: #f/usr/share/fonts/TTF/mplus-1c-medium.ttf mplus-1c-medium /usr/share/fonts/TTF/mplus-1c-medium.ttf mplus-1c-medium Alegreya-Regular/usr/share/fonts/TTF/mplus-1c-medium.ttf mplus-1c-medium DejaVuSans Success: compilation successfully completed ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
On 2015-04-28 10:51, Werner LEMBERG wrote: What is the result of ly:ttf-ps-name when you pass it the full path to a real emmentaler file (I can't see where they are on your system of course)? #(display (ly:font-config-get-font-file /home/harm/lilydevel/usr/share/lilypond/current/fonts/otf/emmentaler-13.otf)) -/home/harm/.fonts/wds052801.ttf What does lilypond -dshow-available-fonts report? For example, I find family Emmentaler-13 Emmentaler\-13:style=13 in the list. Is your lilypond font directory listed at all at the end of the output? akobel@lap-11-06 ~ % lilypond -dshow-available-fonts 21 GNU LilyPond 2.19.18 snip/ family Alegreya Alegreya:style=Regular snip/ family DejaVu Sans DejaVu Sans:style=Book snip/ family Emmentaler-11 Emmentaler\-11:style=11 family Emmentaler-13 Emmentaler\-13:style=13 family Emmentaler-14 Emmentaler\-14:style=14 family Emmentaler-16 Emmentaler\-16:style=16 family Emmentaler-18 Emmentaler\-18:style=18 family Emmentaler-20 Emmentaler\-20:style=20 family Emmentaler-23 Emmentaler\-23:style=23 family Emmentaler-26 Emmentaler\-26:style=26 family Emmentaler-Brace Emmentaler\-Brace:style=Brace snip/ Hmm... Best, Alexander ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
On 2015-04-28 11:45, Urs Liska wrote: Am 28.04.2015 um 11:41 schrieb Werner LEMBERG: family Alegreya Alegreya:style=Regular snip/ family DejaVu Sans DejaVu Sans:style=Book snip/ family Emmentaler-11 Emmentaler\-11:style=11 [...] Hmm... No `hmm' here :-) Lilypond adds its own font directories to the list of directories searched by fontconfig. I see. Not a surprise, on a second though. The hmm refers to the fact that (ly:font-config-get-font-file) doesn't find the fonts Saved me... ;-) Alexander ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
family Alegreya Alegreya:style=Regular snip/ family DejaVu Sans DejaVu Sans:style=Book snip/ family Emmentaler-11 Emmentaler\-11:style=11 [...] Hmm... No `hmm' here :-) Lilypond adds its own font directories to the list of directories searched by fontconfig. Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 11:41 schrieb Werner LEMBERG: family Alegreya Alegreya:style=Regular snip/ family DejaVu Sans DejaVu Sans:style=Book snip/ family Emmentaler-11 Emmentaler\-11:style=11 [...] Hmm... No `hmm' here :-) Lilypond adds its own font directories to the list of directories searched by fontconfig. The hmm refers to the fact that (ly:font-config-get-font-file) doesn't find the fonts Urs Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
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. Urs Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 10:07 schrieb Thomas Morley: 2015-04-28 9:23 GMT+02:00 Urs Liska u...@openlilylib.org: Hi all, #(ly:font-config-get-font-file Emmentaler-13) gives me the full path to the font file used by the Emmentaler-13 font. If I use a non-existent font name, say #(ly:font-config-get-font-file SomeFont) I get a reference to emmentaler-11.otf, which is obviously used as fallback font by fontconfig. However, a Windows user reported that the same references marlett.ttf on his system. On my very old and outdated Ubuntu-system #(display (ly:font-config-get-font-file emmentaler-13.otf)) in a lily-file returns: /home/harm/.fonts/wds052801.ttf which is surely not what I'd expect. And what about #(display (ly:font-config-get-font-file Emmentaler-13)) ? (it expects the font name and not the file name (actually that's the point of the function)) But it shows that my assumption was correct that the approach isn't reliably enough. What's the output of #(display (ly:ttf-ps-name (ly:font-config-get-font-file Emmentaler-13))) ? Urs Cheers, Harm Btw, none of the fallbacks in the file you sent privately works for me. Which is clear from the above. I wanted to use this approach to determine if a requested font exists on the user's system, but now I'm not sure anymore if that's a reliable approach. Of course I can simply add the check for marlett.ttf, but I have the impression that the returned fallback font isn't hard-coded but can vary with the user's installation or font availability. So: 1) Does anyone know of another approach to determine if a given font is visible to fontconfig? (I can't check for the file name because this doesn't necessarily match the font name) or 2) 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. TIA Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
2015-04-28 9:48 GMT+02:00 Urs Liska u...@openlilylib.org: 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 For me this returns: Given font name: Emmentaler-13 Determined font file: /home/harm/.fonts/wds052801.ttf Actual font in that file: WaltDisneyScript Given font is present: #f Given font name: Fancy-Font Determined font file: /home/harm/.fonts/wds052801.ttf Actual font in that file: WaltDisneyScript Given font is present: #f Again, on an outdated Ubuntu. Cheers, Harm 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. Urs Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Am 28.04.2015 um 10:12 schrieb Thomas Morley: 2015-04-28 9:48 GMT+02:00 Urs Liska u...@openlilylib.org: 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 For me this returns: Given font name: Emmentaler-13 Determined font file: /home/harm/.fonts/wds052801.ttf Actual font in that file: WaltDisneyScript Given font is present: #f Given font name: Fancy-Font Determined font file: /home/harm/.fonts/wds052801.ttf Actual font in that file: WaltDisneyScript Given font is present: #f OMG! Again, on an outdated Ubuntu. But that shouldn't make a difference. At least we can't accept that it makes a difference. What is the result of ly:ttf-ps-name when you pass it the full path to a real emmentaler file (I can't see where they are on your system of course)? Urs Cheers, Harm 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. Urs Werner ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
2015-04-28 10:12 GMT+02:00 Urs Liska u...@openlilylib.org: Am 28.04.2015 um 10:07 schrieb Thomas Morley: 2015-04-28 9:23 GMT+02:00 Urs Liska u...@openlilylib.org: Hi all, #(ly:font-config-get-font-file Emmentaler-13) gives me the full path to the font file used by the Emmentaler-13 font. If I use a non-existent font name, say #(ly:font-config-get-font-file SomeFont) I get a reference to emmentaler-11.otf, which is obviously used as fallback font by fontconfig. However, a Windows user reported that the same references marlett.ttf on his system. On my very old and outdated Ubuntu-system #(display (ly:font-config-get-font-file emmentaler-13.otf)) in a lily-file returns: /home/harm/.fonts/wds052801.ttf which is surely not what I'd expect. And what about #(display (ly:font-config-get-font-file Emmentaler-13)) - /home/harm/.fonts/wds052801.ttf ? (it expects the font name and not the file name (actually that's the point of the function)) But it shows that my assumption was correct that the approach isn't reliably enough. What's the output of #(display (ly:ttf-ps-name (ly:font-config-get-font-file Emmentaler-13))) - WaltDisneyScript Should I type rofl or :((( Cheers, Harm ? Urs Cheers, Harm Btw, none of the fallbacks in the file you sent privately works for me. Which is clear from the above. I wanted to use this approach to determine if a requested font exists on the user's system, but now I'm not sure anymore if that's a reliable approach. Of course I can simply add the check for marlett.ttf, but I have the impression that the returned fallback font isn't hard-coded but can vary with the user's installation or font availability. So: 1) Does anyone know of another approach to determine if a given font is visible to fontconfig? (I can't check for the file name because this doesn't necessarily match the font name) or 2) 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. TIA Urs ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
2015-04-28 10:18 GMT+02:00 Urs Liska u...@openlilylib.org: Am 28.04.2015 um 10:16 schrieb Thomas Morley: - WaltDisneyScript Should I type rofl or :((( Probably a rude complaint towards the Ubuntu maintainers ;-) I told you, it's an outdated system. I really should upgarde or use another Linux OS Atm I can't test anymore, will be off for work soon ... Cheers, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: How to determine if a font is a fallback font?
Message: 6 Date: Tue, 28 Apr 2015 09:48:51 +0200 From: Urs Liska u...@openlilylib.org To: Werner LEMBERG w...@gnu.org 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 ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user