Re: how to detect `fontconfig needs a long time'

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

 



well, updating caches will be done inside APIs. unfortunately there
are no interfaces to monitor it so far. the caches will be only
updated when 1) there are no corresponding caches available in the
certain font cache dirs 2) the mtime of font dirs was updated 3) font
itself was updated, unless the force-update is performed through API.

On Fri, Jul 15, 2016 at 6:55 PM, Werner LEMBERG <wl@xxxxxxx> wrote:
>
> Folks,
>
>
> I have two questions.
>
> (1) How can an application detect whether a call to building the font
>     cache (or updating the cache) takes a long time?
>
>     Or to ask differently: What is the correct code sequence in
>     calling fontconfig functions to get this information so that the
>     application can show a message, or, even better, a progress bar or
>     something similar?  This would need registering a callback
>     function, I presume, but I don't find anything related to this in
>     the documentation.
>
>     For example, we are experiencing very long start-up delays if
>     lilypond is called the first time on Windows – usually, there is
>     no global fontconfig cache already existing, so it has to be built
>     from scratch.
>
>     I could imagine that fontconfig first scans all directories for
>     the number of font files, returning a total number of files to
>     process, then it calls the callback every time a file has been
>     processed.
>
> (2) Below is the C++ code lilypond uses to set up fontconfig.  Does
>     `FcConfigBuildFonts' update an existing cache, or does it
>     regenerate it from scratch?  This is not documented...
>
>
>     Werner
>
>
> ======================================================================
>
>
>   FcInitLoadConfig ();
>
>   /* Create an empty configuration */
>   font_config_global = FcConfigCreate ();
>
>   /* fontconfig conf files */
>   vector<string> confs;
>
>   /* LilyPond local fontconfig conf file 00
>      This file is loaded *before* fontconfig's default conf. */
>   confs.push_back (lilypond_datadir + "/fonts/00-lilypond-fonts.conf");
>
>   /* fontconfig's default conf file */
>   void *default_conf = FcConfigFilename (NULL);
>   confs.push_back (static_cast<char*>(default_conf));
>   FcStrFree(static_cast<FcChar8*>(default_conf));
>
>   /* LilyPond local fontconfig conf file 99
>      This file is loaded *after* fontconfig's default conf. */
>   confs.push_back (lilypond_datadir + "/fonts/99-lilypond-fonts.conf");
>
>   /* Load fontconfig conf files */
>   for (vector<string>::const_iterator it = confs.begin ();
>        it != confs.end ();
>        it++)
>     {
>       if (!FcConfigParseAndLoad (font_config_global,
>                                  (FcChar8 *)it->c_str (),
>                                  FcFalse))
>         error (_f ("failed to add fontconfig configuration file `%s'",
>                    it->c_str ()));
>       else
>         debug_output (_f ("Adding fontconfig configuration file: %s",
>                           it->c_str ()));
>     }
>
>   /* Extra trailing slash suddenly breaks fontconfig (fc-cache 2.5.0)
>      on windows.  */
>   string dir (lilypond_datadir + "/fonts/otf");
>
>   if (!FcConfigAppFontAddDir (font_config_global, (FcChar8 *)dir.c_str ()))
>     error (_f ("failed adding font directory: %s", dir.c_str ()));
>   else
>     debug_output (_f ("Adding font directory: %s", dir.c_str ()));
>
>   debug_output (_ ("Building font database..."));
>
>   FcConfigBuildFonts (font_config_global);
>   FcConfigSetCurrent (font_config_global);
> _______________________________________________
> Fontconfig mailing list
> Fontconfig@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/fontconfig



-- 
Akira TAGOH
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux