[Fontconfig] Finding a font but without fallback

Sairus Patel sppatel at adobe.com
Tue Apr 15 14:51:22 PDT 2008


I'd like to ask FontConfig to find a font but *not* do font fallback 
if a precise match isn't found.

Is there a way I can tell FcFontMatch to do this (see below) or is 
there another API I should be using?

The FC documentation says:
 > Font configuration is separate from font matching; applications 
needing to do their own matching can access the available fonts from 
the library and perform private matching.

Does this means that there is no explicit findfont API and I should 
be using FcFontList and managing things myself?


     FcPattern* pattern = FcPatternBuild(0,
                             FC_SCALABLE, FcTypeBool, 1,
                             FC_FAMILY, FcTypeString, familyUtf8,
                             FC_WEIGHT, FcTypeInteger, weight,
                             FC_SLANT, FcTypeInteger, slant,
                             (char *)0);
     if (pattern) {
         FcResult result;
         FcPattern* match;

         /* These *must* be called before FcFontMatch or the results 
won't be correct: */
         FcConfigSubstitute(0, pattern, FcMatchPattern);
         FcDefaultSubstitute(pattern); /* Add default values for 
other attribs */

         /* FcFontMatch substitutes a fallback font if not found; can 
we suppress this? */
         match = FcFontMatch(0, pattern, &result);
         if (match) {

More information about the Fontconfig mailing list