Accessing fontconfig objs in gdb

Caolán McNamara caolan.mcnamara at collabora.com
Tue Sep 10 11:46:16 UTC 2024


On Tue, 2024-09-10 at 13:01 +0200, Julien Nabet wrote:
> I'm trying to understand fontconfig use in LO for tdf#108243
> (semicolon separated fonts substitution not working (bug in Linux
> FontConfig integration code)

It's probable that on the platforms that use fontconfig that we just
split the list of font candidates at ; and ask fontconfig for a
replacement based off that first entry if the first one is not
available, so that debugging fontconfig itself likely doesn't matter
too much. In the sense that it's too late when fontconfig is asked its
opinion about a replacement[*]

PhysicalFontCollection::FindFontFamily has the comment about

// if the first font was not available find the next available font in
// the semicolon separated list of font names

but that is after the

"mpPreMatchHook && mpPreMatchHook->FindFontSubstitute" which asks
fontconfig about the first candidate I think. So the ; list is ignored
for fontconfig platforms.

If you wanted to change that, it would be something like looping over
the list of ';' delineated fonts first in
PhysicalFontCollection::FindFontFamily before then trying fontconfig if
that didn't find any of those candidates.

But, IIRC, the idea of a list of fonts is also a thing for the default
fonts to use for documents too, so I think it might be that this is
also called with mega-strings like
"Arial Unicode MS;DejaVu Sans;Lucida Sans Unicode;Tahoma;Albany AMT..."
during startup/new documents to pick something good to use, where the
idea so far has been that fontconfig likely has a far better idea of
what is a good available font similar to the first suggestion for the
user's language, etc.

Whatever about the case of a document/user explicitly using ";" to
suggests fallbacks where the first one that really exists might be a
good idea, I feel the other case where LibreOffice is just asking for
"something good" probably should continue to just feed fontconfig the
first entry and accept that result.

[*] though see
https://www.freedesktop.org/software/fontconfig/fontconfig-user.html
for FC_DEBUG which might be helpful if you do want to debug how
fontconfig decided its replacement.


More information about the LibreOffice mailing list