6. Listing Available Fonts

Listing available fonts is a fundamentally different operation from trying to find a font fit for a suitable purpose. When listing available fonts, applications are trying to discover the set of different options for a particular parameter -- the list of available families or the styles for a particular font. Fontconfig tries to match this usage with a relatively simple interface.

Applications provide a pattern which is used to match available fonts. The application also provides a set of names. The return value is a list of patterns holding the values associated with the given names from each of the matching fonts. The trick is that elements of this list which are duplicates are removed from the list.

For example, the application provides a pattern which matches all of the available fonts and requests only the family values. The resulting list of patterns will contain a list of the available font families with no duplicate entries. Or have the application provide a pattern matching only Times fonts and request both the weight and slant values. The result will be a list of all available combinations of weight and slant for that particular family.