[Fontconfig] Font match quality score?

mathog mathog at caltech.edu
Fri Oct 26 13:08:55 PDT 2012


Fontconfig will always match a font name with something, and it would 
in some instances be
extremely helpful for the program using it to know how good or bad a 
match was found.  In
my case I ran into this when trying to reassemble complex text that had 
been broken down into
chunk1,chunk2, chunk3, etc. with only the start position on the page, 
font name, and font size known.  If the
match was good then the rules for figuring out that the chunks 
"E","=mc","2" are supposed to be
"E=mc2" (that is supposed to be a superscript 2) are pretty 
straightforward.  However, when
the match is bad the chunks either overlap each other too much or are 
too short.  In brief, it
is not worth the effort trying to reassemble complex text fif the font 
match is poor.

Consider three cases:

1.  Arial
2.  Arial Narrow
3.  Random2347937

Because (1) is such a common font pretty much every system has a good 
match.
If there is an actual Arial Narrow then (2) will match exactly, 
otherwise the match
   will generally be terrible.
For (3) the match could only be good by pure chance, since fontconfig 
knows nothing about this
"font".

The application cannot know the preceding 3 facts, unless fontconfig 
somehow tells it.

Is there currently some way to get fontconfig to reveal how good a 
match was found?  If not,
could it please be enhanced to return some sort of quality score?  For 
instance "10" for
"Arial" matching "Arial", or "Arial Narrow" matching  "Arial Narrow", 
vs. 3 for "Arial Narrow"
matching some other condensed font, or 1 for "Random2347937" which 
Fontconfig cannot identify?

Thank you,

David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech


More information about the Fontconfig mailing list