Folks, we have a problem within lilypond. This is probably a pango question also, but let''s start here :-) Is there a way for fontconfig to signal that it has found a fallback font instead of the requested one? Or to say it differently: How can an application find out whether fontconfig returns an exact match, a user-defined alias (counting probably as an exact match), a good match, and bad match, and no match at all? Werner
On 08/22/2012 10:57 AM, Werner LEMBERG wrote:> > Folks, > > we have a problem within lilypond. This is probably a pango question > also, but let''s start here :-)I''d like to hear more about the problem.> Is there a way for fontconfig to signal that it has found a fallback > font instead of the requested one? Or to say it differently: How can > an application find out whether fontconfig returns an exact match, a > user-defined alias (counting probably as an exact match), a good > match, and bad match, and no match at all?Hard. One way I have suggested to people in the past is to load a font for the following two patters: "SomeFamilyName,sans" and "SomeFamilyName,serif". If the two fonts have the same family name, you got a match, otherwise a fallback. But hearing lilypond, I smell you want to load a font you are shipping yourself. I assume lilypond uses Unicode-encoded musical symbols and pango to render them? That''s really cool. There are ways to force pangofc to load the font you want, they are just not documented. I''ll be happy to explain those. behdad> > Werner > _______________________________________________ > Fontconfig mailing list > Fontconfig at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/fontconfig >
>> we have a problem within lilypond. This is probably a pango >> question also, but let''s start here :-) > > I''d like to hear more about the problem.Actually, we have two problems: (1) The fallback font problem mentioned in the previous mail; you can find the full report here, together with a proposed fix (which doesn''t work as expected, thus writing to this list): http://code.google.com/p/lilypond/issues/detail?id=2761 (2) For some unknown reasons yet, we get different output for the same font on GNU/Linux and Windows. While the former contains ligatures (like `fi'') and kerning, the latter doesn''t have this. We suspect a Pango problem since I/O snooping has shown that the same fonts are used on both platforms. The kerning problem is reported here: http://code.google.com/p/lilypond/issues/detail?id=2657 but the discussion mainly happens here because the ligature problem has the same origin, we believe: http://code.google.com/p/lilypond/issues/detail?id=2656 Note that we distribute special versions of the CenturySchL fonts as part of the lilypond bundle; we convert the Type1 fonts to OTF with FontForge, stripping off some ligatures (like `i+j->ij'') which shouldn''t be active by default.> One way I have suggested to people in the past is to load a font for > the following two patters: "SomeFamilyName,sans" and > "SomeFamilyName,serif". If the two fonts have the same family name, > you got a match, otherwise a fallback.Nice idea!> But hearing lilypond, I smell you want to load a font you are > shipping yourself.Yes. We have two font interfaces: For music and musical symbols, lilypond itself manages the font processing, using fontconfig to locate the font $(Q#|(B we simply add lilypond''s font directory to get exact matches. For text strings (including musical symbols if part of the text), we delegate everything to pango.> I assume lilypond uses Unicode-encoded musical symbols and pango to > render them? That''s really cool.It works without problems, at least on GNU/Linux. Our problems are with standard fonts, more or less.> There are ways to force pangofc to load the font you want, they are > just not documented. I''ll be happy to explain those.This sounds *very* interesting! Werner
On 08/22/2012 12:06 PM, Werner LEMBERG wrote:> > (2) For some unknown reasons yet, we get different output for the > same font on GNU/Linux and Windows. While the former contains > ligatures (like `fi'') and kerning, the latter doesn''t have this. > We suspect a Pango problem since I/O snooping has shown that the > same fonts are used on both platforms.Incidentally I was checking the basic-win32.c Pango module today and noticed that it shortcircuits calling into Uniscribe if !ScriptIsComplex(). That would explain what you are seeing. I like to remove that hack and always call Uniscribe unconditionally... Who knows, soon I may even remove the Uniscribe module and rely on HarfBuzz Uniscribe backend on Windows. If someone wants to try my hypothesis I''d be happy to help.>> There are ways to force pangofc to load the font you want, they are >> just not documented. I''ll be happy to explain those. > > This sounds *very* interesting!Create a FcConfig, don''t add any font directories to it, add the font file you want using FcConfigAppFontAddFile. Then create a PangoFcFontMap solely for use with this configuration. Install/uninstall your FcConfig whenever calling Pango using your fontmap. Eventually I''ll add API to attach FcConfig''s to PangoFcFontMap. I even remember Owen had a draft patch for that. HTH, behdad> Werner
On Wed, Aug 22, 2012 at 12:19:53PM -0400, Behdad Esfahbod wrote:> On 08/22/2012 12:06 PM, Werner LEMBERG wrote: > > > > (2) For some unknown reasons yet, we get different output for the > > same font on GNU/Linux and Windows. While the former contains > > ligatures (like `fi'') and kerning, the latter doesn''t have this. > > We suspect a Pango problem since I/O snooping has shown that the > > same fonts are used on both platforms. > > Incidentally I was checking the basic-win32.c Pango module today and noticed > that it shortcircuits calling into Uniscribe if !ScriptIsComplex(). That > would explain what you are seeing. I like to remove that hack and always call > Uniscribe unconditionally... > > Who knows, soon I may even remove the Uniscribe module and rely on HarfBuzz > Uniscribe backend on Windows.Since Uniscribe now hardly provides any advantage over HarfBuzz, I''d be in favour of that (it would also help users using old Windows systems with ancient versions of Uniscribe). Regards, Khaled