Please add <assemble> → <merge> → <match> → <best> and <fallback>
This is a follow-up of: #187
This issue documents a solution that was mulled in the past on the fontconfig and fonts mailing list. I find it overly complex and unnecessary. So, adding it here for completeness reasons if someone disagrees with me, but not endorsing it in any way.
History has proven that using a single priority list in fontconfig is essentially unmaintainable, because making any change requires synchronizing all the declarations inside the list.
Therefore, add best
and fallback
containers inside merge
-
best
for elements, that should be considered before all others, in priority order -
fallback
for low quality font blocks, that should only used if nothing else is available.
The priority resolution mecanism becomes:
- all the blocks, entered in
best
by declaration order (higher priority declared first) - all the blocks, in the general list, in no particular order (fontconfig can choose whichever it likes best). General list is anything not contained in
best
orfallback
- at last resort, the blocks in fallback, in no particular order
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- SPDX-License-Identifier: MIT -->
<fontconfig>
<assemble>
<family>@canonical_name@</family>
<merge>
<family></family>
<match>
<best> <!-- Good high quality font blocks -->
<family></family>
<family></family>
</best>
<family></family>
<family></family>
<fallback> <!-- Low quality last resort font blocks -->
<family></family>
<family></family>
</fallback>
</match>
</merge>
</assemble>
</fontconfig>
Application example (complete example)
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- SPDX-License-Identifier: MIT -->
<fontconfig>
<assemble>
<family>Foo</family>
<merge>
<best>
<family>Foo New</family> <!-- Better and newer font files, partial coverage to start up -->
</best>
<family>Foo Math</family>
<match>
<family>Foo Condensed</family>
<prefix>Condensed</prefix>
</match>
<match>
<family>Broken FooBar</family>
<style>Default</style>
<to>Regular</to>
</match>
<fallback>
<match>
<fullname>Broken Foo</fullname>
</match>
<family>Foo Fallback</family> <!-- High-coverage low-quality font files -->
</fallback>
</merge>
</assemble>
</fontconfig>
Application example (just the best
and fallback
parts)
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- SPDX-License-Identifier: MIT -->
<fontconfig>
<assemble>
<family>Foo</family>
<merge>
<best>
<family>Foo New</family> <!-- Better and newer font files, partial coverage to start up -->
</best>
<fallback>
<family>Foo Fallback</family> <!-- High-coverage low-quality font files -->
</fallback>
</merge>
</assemble>
</fontconfig>