how to detect `fontconfig needs a long time'

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

 



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




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

  Powered by Linux