freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] How to use FreeType with FontConfig?


From: Lawrence D'Oliveiro
Subject: Re: [ft] How to use FreeType with FontConfig?
Date: Wed, 18 Feb 2015 10:13:01 +1300

On Tue, 17 Feb 2015 20:37:04 +0200, John Found wrote:

> Recently I am working on text rendering with FreeType.
> 
> The FreeType function FT_New_Face uses the filename of the font, but
> I want more flexible approach with font substitution and suggesting
> fonts by some pattern, for example "serif", "monospaced", "bold", etc.

There is a sequence of Fontconfig calls I use as standard. For
a C version, see the load_sub_face routine here
<https://github.com/ldo/dvdauthor/blob/master/src/subfont.c>. The steps
are:

    * call FcNameParse to parse the user-provided string into an
      FcPattern
    * Do an FcConfigSubstitute on the pattern to apply a user-default
      configuration
    * Also call FcDefaultSubstitute on the pattern to apply a
      hard-coded default configuration
    * Call FcFontMatch to actually find a matching font
    * Then FcPatternGetString(... FC_FILE ...) on the match to get the
      pathname of the font file.

For a Python equivalent, see the Face.find_face method here
<https://github.com/ldo/python_freetype/blob/master/freetype.py>.

Fontconfig pattern strings can take such useful forms as
“palatino:style=italic:weight=1000"”, “sans-serif:slant=500” etc.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]