chromium/ui/gfx/platform_font_skia.cc

// Copyright 2012 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/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 {

// The font family name which is used when a user's application font for
// GNOME/KDE is a non-scalable one. The name should be listed in the
// IsFallbackFontAllowed function in skia/ext/SkFontHost_fontconfig_direct.cpp.
#if BUILDFLAG(IS_ANDROID)
const char kFallbackFontFamilyName[] = "serif";
#else
const char kFallbackFontFamilyName[] =;
#endif

constexpr SkGlyphID kUnsupportedGlyph =;

// The default font, used for the default constructor.
base::LazyInstance<scoped_refptr<PlatformFontSkia>>::Leaky g_default_font =;

// Creates a SkTypeface for the passed-in Font::FontStyle and family. If a
// fallback typeface is used instead of the requested family, |family| will be
// updated to contain the fallback's family name.
sk_sp<SkTypeface> CreateSkTypeface(bool italic,
                                   gfx::Font::Weight weight,
                                   std::string* family,
                                   bool* out_success) {}

}  // namespace

std::string* PlatformFontSkia::default_font_description_ =;

////////////////////////////////////////////////////////////////////////////////
// PlatformFontSkia, public:

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) {}

////////////////////////////////////////////////////////////////////////////////
// PlatformFontSkia, PlatformFont implementation:

// static
void PlatformFontSkia::EnsuresDefaultFontIsInitialized() {}

// static
void PlatformFontSkia::ReloadDefaultFont() {}

// static
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, private:

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, public:

// static
PlatformFont* PlatformFont::CreateDefault() {}

// static
PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
                                                  int font_size) {}

// static
PlatformFont* PlatformFont::CreateFromSkTypeface(
    sk_sp<SkTypeface> typeface,
    int font_size_pixels,
    const std::optional<FontRenderParams>& params) {}

}  // namespace gfx