Around 23 o'clock on Nov 1, "Braden McDaniel" wrote:

> Are there any relatively simple examples of using fontconfig for font
> discovery? 

Pango uses fontconfig and FreeType for one of it's backends; here's a brief
sample from that:

  sans = FcPatternBuild (NULL,
                         FC_FAMILY, FcTypeString, "sans",
                         FC_SIZE, FcTypeDouble, (double)pango_font_description_!
                         NULL);

  matched = FcFontMatch (0, sans, &result);
  
  if (FcPatternGetString (matched, FC_FILE, 0, &filename2) != FcResultMatch)
    goto bail1;
  
  if (FcPatternGetInteger (matched, FC_INDEX, 0, &id) != FcResultMatch)
    goto bail1;
  
  error = FT_New_Face (_pango_ft2_font_map_get_library (ft2font->fontmap),
                       (char *) filename2, id, &ft2font->face);

  FcPatternDestroy (sans);
  FcPatternDestroy (matched);

You'll want to to use FcFreeTypeCharIndex to map Unicode to glyph ids; 
that handles the vageries of various non-Unicode font mappings which are 
often present in older TrueType and Type1 fonts.

Keith Packard        XFree86 Core Team        HP Cambridge Research Lab


_______________________________________________
Fonts mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/fonts

Reply via email to