#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/gfx/font_fallback_linux.h"
#include <fontconfig/fontconfig.h>
#include <map>
#include <memory>
#include <string>
#include <string_view>
#include "base/containers/lru_cache.h"
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/no_destructor.h"
#include "base/trace_event/trace_event.h"
#include "skia/ext/font_utils.h"
#include "third_party/icu/source/common/unicode/uchar.h"
#include "third_party/icu/source/common/unicode/utf16.h"
#include "third_party/skia/include/core/SkFontMgr.h"
#include "ui/gfx/font.h"
#include "ui/gfx/font_fallback.h"
#include "ui/gfx/linux/fontconfig_util.h"
#include "ui/gfx/platform_font.h"
namespace gfx {
namespace {
const char kFontFormatTrueType[] = …;
const char kFontFormatCFF[] = …;
bool IsValidFontFromPattern(FcPattern* pattern) { … }
class TypefaceCacheKey { … };
sk_sp<SkTypeface> GetSkTypefaceFromPathAndIndex(const base::FilePath& font_path,
int ttc_index) { … }
class FallbackFontKey { … };
class FallbackFontEntry { … };
FallbackFontEntries;
FallbackFontEntriesCache;
FallbackFontEntriesCache* GetFallbackFontEntriesCacheInstance() { … }
FallbackFontList;
FallbackFontListCache;
FallbackFontListCache* GetFallbackFontListCacheInstance() { … }
}
size_t GetFallbackFontEntriesCacheSizeForTesting() { … }
size_t GetFallbackFontListCacheSizeForTesting() { … }
void ClearAllFontFallbackCachesForTesting() { … }
bool GetFallbackFont(const Font& font,
const std::string& locale,
std::u16string_view text,
Font* result) { … }
std::vector<Font> GetFallbackFonts(const Font& font) { … }
namespace {
class CachedFont { … };
class CachedFontSet { … };
FontSetCache;
base::LazyInstance<FontSetCache>::Leaky g_font_sets_by_locale = …;
}
FallbackFontData::FallbackFontData() = default;
FallbackFontData::FallbackFontData(const FallbackFontData& other) = default;
FallbackFontData& FallbackFontData::operator=(const FallbackFontData& other) =
default;
bool GetFallbackFontForChar(UChar32 c,
const std::string& locale,
FallbackFontData* fallback_font) { … }
}