font_util.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ui/gfx/font_util.h"
  5. #include "build/build_config.h"
  6. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  7. #include <fontconfig/fontconfig.h>
  8. #include "ui/gfx/linux/fontconfig_util.h"
  9. #endif
  10. #if BUILDFLAG(IS_WIN)
  11. #include "ui/gfx/win/direct_write.h"
  12. #endif
  13. namespace gfx {
  14. void InitializeFonts() {
  15. // Implicit initialization can cause a long delay on the first rendering if
  16. // the font cache has to be regenerated for some reason. Doing it explicitly
  17. // here helps in cases where the browser process is starting up in the
  18. // background (resources have not yet been granted to cast) since it prevents
  19. // the long delay the user would have seen on first rendering.
  20. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  21. // Ensures the config is created on this thread.
  22. FcConfig* config = GetGlobalFontConfig();
  23. DCHECK(config);
  24. #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  25. #if BUILDFLAG(IS_WIN)
  26. gfx::win::InitializeDirectWrite();
  27. #endif // BUILDFLAG(IS_WIN)
  28. }
  29. } // namespace gfx