#include "third_party/blink/renderer/platform/fonts/web_font_typeface_factory.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "skia/ext/font_utils.h"
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
#include "third_party/blink/renderer/platform/fonts/opentype/font_format_check.h"
#include "third_party/skia/include/core/SkStream.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "third_party/skia/include/ports/SkTypeface_fontations.h"
#if BUILDFLAG(IS_WIN)
#include "third_party/blink/renderer/platform/fonts/win/dwrite_font_format_support.h"
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE)
#include "third_party/skia/include/ports/SkFontMgr_empty.h"
#endif
#include <functional>
namespace blink {
namespace {
bool IsWin() { … }
bool IsApple() { … }
bool IsFreeTypeSystemRasterizer() { … }
sk_sp<SkTypeface> MakeTypefaceDefaultFontMgr(sk_sp<SkData> data) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE)
sk_sp<SkTypeface> MakeTypefaceFallback(sk_sp<SkData> data) {
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_APPLE)
if (RuntimeEnabledFeatures::FontationsFontBackendEnabled()) {
std::unique_ptr<SkStreamAsset> stream(new SkMemoryStream(data));
return SkTypeface_Make_Fontations(std::move(stream), SkFontArguments());
}
#endif
return SkFontMgr_New_Custom_Empty()->makeFromData(data, 0);
}
#endif
sk_sp<SkTypeface> MakeTypefaceFontations(sk_sp<SkData> data) { … }
sk_sp<SkTypeface> MakeVariationsTypeface(
sk_sp<SkData> data,
const WebFontTypefaceFactory::FontInstantiator& instantiator) { … }
sk_sp<SkTypeface> MakeSbixTypeface(
sk_sp<SkData> data,
const WebFontTypefaceFactory::FontInstantiator& instantiator) { … }
sk_sp<SkTypeface> MakeColrV0Typeface(
sk_sp<SkData> data,
const WebFontTypefaceFactory::FontInstantiator& instantiator) { … }
sk_sp<SkTypeface> MakeColrV0VariationsTypeface(
sk_sp<SkData> data,
const WebFontTypefaceFactory::FontInstantiator& instantiator) { … }
sk_sp<SkTypeface> MakeUseFallbackIfNeeded(
sk_sp<SkData> data,
const WebFontTypefaceFactory::FontInstantiator& instantiator) { … }
sk_sp<SkTypeface> MakeFontationsFallbackPreferred(
sk_sp<SkData> data,
const WebFontTypefaceFactory::FontInstantiator& instantiator) { … }
}
bool WebFontTypefaceFactory::CreateTypeface(sk_sp<SkData> data,
sk_sp<SkTypeface>& typeface) { … }
bool WebFontTypefaceFactory::CreateTypeface(
sk_sp<SkData> data,
sk_sp<SkTypeface>& typeface,
const FontFormatCheck& format_check,
const FontInstantiator& instantiator) { … }
void WebFontTypefaceFactory::ReportInstantiationResult(
InstantiationResult result) { … }
}