[Fontconfig] Another proposal for saving custom fonts in fontconfig

Peng Wu peng.e.wu at gmail.com
Tue Jul 2 08:27:44 UTC 2019


Hi,

On Thu, 2019-06-27 at 17:06 +0900, Akira TAGOH wrote:
> No such features in fontconfig so far. and XML can be written by the
> hand. managing such things with API isn't that easy nor simple IMHO.
> So my possible counter proposal may be to add APIs to
> add/modify/remove things to/from caches directly and a command line
> tool to do it with those APIs easily for users who like doing from
> command line perhaps. because FcFontSet is basically a reference from
> caches. no drastic changes is needed in core code, but some only when
> scanning.
> 
> Assuming that proposed XML contains all of information what you
> need..
> so APIs might be:
> 
> FcBool
> FcDirCacheAddStyle (const FcConfig *config, const FcChar8 *file,
> const
> FcChar8 *stylename, const FcChar8 *variations);
> 
> FcBool
> FcDirCacheRemoveStyle (const FcConfig *config, const FcChar8 *file,
> const FcChar8 *stylename);
> 

  Based on this proposal, I propose some small modifications in the
API.

FcBool
FcDirCacheAddStyle (const FcConfig *config, const FcChar8 *file,
const unsigned int index, const FcChar8 *stylename, FcPattern *custom);

The file is for the font file path,
the index is for the font index if this font is TTC font,
the stylename is for the custom style name.

The FcPattern *custom will contains all the properties to be
overridden.

fontconfig can maintain a white list of allowed overridden properties,
and initially it only allows style name and font variations.

FcBool
FcDirCacheRemoveStyle (const FcConfig *config, const FcChar8 *file,
const unsigned int index, const FcChar8 *stylename);

To remove the saved custom style name.

Feel free to comment it.

Thanks,
  Peng



More information about the Fontconfig mailing list