[Fontconfig] Another proposal for saving custom fonts in fontconfig

Akira TAGOH akira at tagoh.org
Thu Jun 27 08:06:11 UTC 2019


On Thu, Jun 27, 2019 at 3:59 PM Peng Wu <peng.e.wu at gmail.com> wrote:
> > Are you expecting to input/output from/to file in fontconfig?
> > I'm not yet fully understanding what exactly you want with it though,
> > is it created/modified/removed by users and happens so often?
> > What exactly the use case is it?
> >
>
> These API is used to create/remove the custom font file, I just think
> it is easier to handle it in fontconfig.

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);


>
> It is also okay for me to create/remove the custom font file
> in other library.
>
> FcConfigCreateCustomFont will create the custom font file,
> FcPattern *origin will create the below content:
> '''
>         <origin>
>                 <family>Variable Font Family</family>
>                 <style>Style Name</style>
>         </origin>
> '''
> FcPattern *custom will create the below content:
> '''
>         <custom>
>                 <family>Variable Font Family</family>
>                 <style>Custom Style Name</style>
>                 <fontvariations>AXIS1=VALUE;AXIS2=VALUE</fontvariations
> >
>         </custom>
> '''
>
> FcConfigRemoveCustomFont will remove the matched custom font file.
> FcPattern *custom will try to match family name and custom style name.
>
>
> > > After fontconfig finish font loading, the "origin" element will
> > > match
> > > the existing fonts, and the "custom" element will copy and modify
> > > the
> > > matched font,
> > > then save the new font as normal font pattern into FcFontSet.
> >
> > What you said the above can be done without any changes even at this
> > point, with FcFontMatch(). but FcFontList(). you can't expect any
> > operations to rebuild the list with some modifications in
> > FcFontList()
> > like FcFontMatch() does. that will affects a lot to the performance.
> > "custom" you said in your mail must be extracted prior to add to the
> > list. what you can expect on FcFontList() is only filtering.
> >
> > Anyway, please elaborate more on use cases and requirements for
> > input/output through fontconfig API.
> >
>
> Sorry, pango prefers to use FcFontList.
>
> And the custom fonts information will only run once after fontconfig
> finish loading the XML and font files.
>
> After fontconfig finish loading, each custom font style information
> will go through the FcFontSet, and match the font, copy, modify and
> insert back the font into FcFontSet.
> Then FcFontList will return the fonts with custom font style together
> for pango.
>
> This approach will only affect the loading time of fontconfig
> depending on how many custom font style are defined.
>
> Thanks,
>   Peng
>
> > > I will think about how to re-use the current fontconfig XML syntax,
> > > and propose another XML syntax soon.
> > >
> > > Feel free to comment it.
> > >
> > > Thanks,
> > >   Peng
> > >
> > > _______________________________________________
> > > Fontconfig mailing list
> > > Fontconfig at lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/fontconfig
> >
> >
>


-- 
Akira TAGOH


More information about the Fontconfig mailing list