chromium/ui/gfx/linux/fontconfig_util.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/gfx/linux/fontconfig_util.h"

#include <fontconfig/fontconfig.h>

#include "base/check_op.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h"
#include "base/task/thread_pool.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/trace_event/trace_event.h"
#include "build/chromeos_buildflags.h"
#include "ui/gfx/font_render_params.h"

#if BUILDFLAG(IS_CHROMEOS)
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#endif

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/check_deref.h"
#include "base/containers/flat_set.h"
#endif

namespace gfx {

namespace {

#if BUILDFLAG(IS_CHROMEOS)
constexpr base::FilePath::CharType kGoogleSansVariablePath[] =
    FILE_PATH_LITERAL("/usr/share/fonts/google-sans/variable");
constexpr base::FilePath::CharType kGoogleSansStaticPath[] =
    FILE_PATH_LITERAL("/usr/share/fonts/google-sans/static");
#endif

#if BUILDFLAG(IS_CHROMEOS_ASH)
// This should match `imageloader::kImageloaderMountBase` from
// //third_party/cros_system_api/constants/imageloader.h.
constexpr base::FilePath::CharType kImageloaderMountBase[] =
    FILE_PATH_LITERAL("/run/imageloader/");
#endif

// A singleton class to wrap a global font-config configuration. The
// configuration reference counter is incremented to avoid the deletion of the
// structure while being used. This class is single-threaded and should only be
// used on the UI-Thread.
class GFX_EXPORT GlobalFontConfig {};

// Converts Fontconfig FC_HINT_STYLE to FontRenderParams::Hinting.
FontRenderParams::Hinting ConvertFontconfigHintStyle(int hint_style) {}

// Converts Fontconfig FC_RGBA to FontRenderParams::SubpixelRendering.
FontRenderParams::SubpixelRendering ConvertFontconfigRgba(int rgba) {}

// Extracts a string property from a font-config pattern (e.g. FcPattern).
std::string GetFontConfigPropertyAsString(FcPattern* pattern,
                                          const char* property) {}

// Extracts an integer property from a font-config pattern (e.g. FcPattern).
int GetFontConfigPropertyAsInt(FcPattern* pattern,
                               const char* property,
                               int default_value) {}

// Extracts an boolean property from a font-config pattern (e.g. FcPattern).
bool GetFontConfigPropertyAsBool(FcPattern* pattern, const char* property) {}

}  // namespace

void InitializeGlobalFontConfigAsync() {}

FcConfig* GetGlobalFontConfig() {}

void OverrideGlobalFontConfigForTesting(FcConfig* config) {}

std::string GetFontName(FcPattern* pattern) {}

std::string GetFilename(FcPattern* pattern) {}

base::FilePath GetFontPath(FcPattern* pattern) {}

int GetFontTtcIndex(FcPattern* pattern) {}

bool IsFontBold(FcPattern* pattern) {}

bool IsFontItalic(FcPattern* pattern) {}

bool IsFontScalable(FcPattern* pattern) {}

std::string GetFontFormat(FcPattern* pattern) {}

void GetFontRenderParamsFromFcPattern(FcPattern* pattern,
                                      FontRenderParams* param_out) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
bool AddAppFontDir(const base::FilePath& dir) {
  return CHECK_DEREF(GlobalFontConfig::GetInstance()).AddAppFontDir(dir);
}
#endif

}  // namespace gfx