#include "ui/gfx/platform_font_skia.h"
#include <algorithm>
#include <string>
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "skia/ext/font_utils.h"
#include "third_party/skia/include/core/SkFont.h"
#include "third_party/skia/include/core/SkFontMetrics.h"
#include "third_party/skia/include/core/SkFontStyle.h"
#include "third_party/skia/include/core/SkString.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/font_render_params.h"
#include "ui/gfx/text_utils.h"
#if BUILDFLAG(IS_WIN)
#include "ui/gfx/system_fonts_win.h"
#endif
#if BUILDFLAG(IS_LINUX)
#include "ui/linux/linux_ui.h"
#endif
namespace gfx {
namespace {
#if BUILDFLAG(IS_ANDROID)
const char kFallbackFontFamilyName[] = "serif";
#else
const char kFallbackFontFamilyName[] = …;
#endif
constexpr SkGlyphID kUnsupportedGlyph = …;
base::LazyInstance<scoped_refptr<PlatformFontSkia>>::Leaky g_default_font = …;
sk_sp<SkTypeface> CreateSkTypeface(bool italic,
gfx::Font::Weight weight,
std::string* family,
bool* out_success) { … }
}
std::string* PlatformFontSkia::default_font_description_ = …;
PlatformFontSkia::PlatformFontSkia() { … }
PlatformFontSkia::PlatformFontSkia(const std::string& font_name,
int font_size_pixels) { … }
PlatformFontSkia::PlatformFontSkia(
sk_sp<SkTypeface> typeface,
int font_size_pixels,
const std::optional<FontRenderParams>& params) { … }
void PlatformFontSkia::EnsuresDefaultFontIsInitialized() { … }
void PlatformFontSkia::ReloadDefaultFont() { … }
void PlatformFontSkia::SetDefaultFontDescription(
const std::string& font_description) { … }
Font PlatformFontSkia::DeriveFont(int size_delta,
int style,
Font::Weight weight) const { … }
int PlatformFontSkia::GetHeight() { … }
Font::Weight PlatformFontSkia::GetWeight() const { … }
int PlatformFontSkia::GetBaseline() { … }
int PlatformFontSkia::GetCapHeight() { … }
int PlatformFontSkia::GetExpectedTextWidth(int length) { … }
int PlatformFontSkia::GetStyle() const { … }
const std::string& PlatformFontSkia::GetFontName() const { … }
std::string PlatformFontSkia::GetActualFontName() const { … }
int PlatformFontSkia::GetFontSize() const { … }
const FontRenderParams& PlatformFontSkia::GetFontRenderParams() { … }
sk_sp<SkTypeface> PlatformFontSkia::GetNativeSkTypeface() const { … }
PlatformFontSkia::PlatformFontSkia(sk_sp<SkTypeface> typeface,
const std::string& family,
int size_pixels,
int style,
Font::Weight weight,
const FontRenderParams& render_params) { … }
PlatformFontSkia::~PlatformFontSkia() { … }
void PlatformFontSkia::InitFromDetails(sk_sp<SkTypeface> typeface,
const std::string& font_family,
int font_size_pixels,
int style,
Font::Weight weight,
const FontRenderParams& render_params) { … }
void PlatformFontSkia::InitFromPlatformFont(const PlatformFontSkia* other) { … }
void PlatformFontSkia::ComputeMetricsIfNecessary() { … }
PlatformFont* PlatformFont::CreateDefault() { … }
PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
int font_size) { … }
PlatformFont* PlatformFont::CreateFromSkTypeface(
sk_sp<SkTypeface> typeface,
int font_size_pixels,
const std::optional<FontRenderParams>& params) { … }
}