[Fontconfig] fontconfig match question

Stephen C. North north at research.att.com
Tue Jul 18 18:43:49 PDT 2006


I'm forwarding this due to problems Behdad had in posting to the list.

His solution is clever.

Behdad Esfahbod wrote:

>On Mon, 2006-07-17 at 12:22 -0400, Owen Taylor wrote:
>  
>
>>On Mon, 2006-07-17 at 12:05 -0400, Stephen C. North wrote:
>>    
>>
>>>OK, "fail over to a default font" may not be quite the right way to describe
>>>what happens.  At the end of the day, when fontconfig can't resolve a request
>>>like "Cursive-Script-Like-Don-Knuth's-Handwriting at 12 pt" to anything
>>>better, its rule of last resort substitutes a system default like "Sans".
>>>In our world, we would consider this worth a runtime warning.  So, how can
>>>I tell if the last resort rule was matched?  Just check if the family
>>>is "Sans" when we didn't ask for "Sans"?
>>>      
>>>
>>Basically, what you want to do is detect whether the resulting font
>>matches:
>>
>> A) The family that was originally specified
>> B) A family that was added by an alias rule, except for families
>>    resulting indirectly from the rule in the default config:
>>   
>>    "If the font still has no generic name, add sans-serif"
>>
>>But that's hard to do. An approximation might be:
>>    
>>
>
>What about this:  match font for "YourFamily,sans", and
>"YourFamily,serif".  If they return the same family, it's a match, if
>they don't, it's junk fallback.
>
>[behdad at home ~]$ fc-match "Helvetica,serif"
>n019003l.pfb: "Nimbus Sans L" "Regular"
>[behdad at home ~]$ fc-match "Helvetica,sans"
>n019003l.pfb: "Nimbus Sans L" "Regular"
>[behdad at home ~]$ fc-match "NonExistant,serif"
>VeraSe.ttf: "Bitstream Vera Serif" "Roman"
>[behdad at home ~]$ fc-match "NonExistant,sans"
>Vera.ttf: "Bitstream Vera Sans" "Roman"
>
>  
>



More information about the Fontconfig mailing list