[Fontconfig] How to limit search to outline fonts

depp at moria.us depp at moria.us
Fri Oct 1 00:04:41 PDT 2010


I'd like to search the fonts on a system by family name, but prefer  
outline fonts later on the list over bitmap fonts earlier on the list.  
  For example, for the spec "Courier, DejaVu Sans Mono":

1. Courier (outline)
2. DejaVu Sans Mono (outline)
3. Courier (bitmap)
4. DejaVu Sans Mono (bitmap)
5. Fallback font

Here's what I've tried:

1. I tried figuring out how to do this with a single call to  
FcFontMatch.  It turns out the "best" match is determined by hardcoded  
weights.  If they weren't hardcoded, I could simply increase the  
weight for the "outline" attribute.
2. I tried figuring out how to do this passing each family separately  
to FcFontMatch, then picking the first that has an outline, or falling  
back to the first without an outline.  However, I can't figure out how  
to tell the difference between when FcFontMatch returns a family I  
asked for and when it returns a fallback font.
3. I tried using FcFontList to create a font list containing only  
outline fonts so I could search that first, but I can't tell the  
difference between when it can find a font and when it found a  
fallback font.
4. I tried looking at the source code to FcFontMatch, but it looks  
like it does a lot of peeking inside of structures that are opaque to  
clients.  I'd have to make a lot of API calls to access the required  
information.

What am I missing, or is it really that hard to do this?



More information about the Fontconfig mailing list