#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
#include <unicode/utf16.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/memory/ptr_util.h"
#include "base/numerics/byte_conversions.h"
#include "build/build_config.h"
#include "skia/ext/font_utils.h"
#include "third_party/blink/renderer/platform/font_family_names.h"
#include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/fonts/opentype/open_type_baseline_metrics.h"
#include "third_party/blink/renderer/platform/fonts/opentype/open_type_vertical_data.h"
#include "third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.h"
#include "third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.h"
#include "third_party/blink/renderer/platform/wtf/allocator/partitions.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/character_names.h"
#include "third_party/blink/renderer/platform/wtf/text/unicode.h"
#include "third_party/freetype_buildflags.h"
#include "third_party/skia/include/core/SkFont.h"
#include "third_party/skia/include/core/SkFontMetrics.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "third_party/skia/include/core/SkTypes.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "v8/include/v8.h"
#if !BUILDFLAG(USE_SYSTEM_FREETYPE)
#include "third_party/freetype/src/src/autofit/afws-decl.h"
#endif
namespace blink {
constexpr float kSmallCapsFontSizeMultiplier = …;
constexpr float kEmphasisMarkFontSizeMultiplier = …;
#if !BUILDFLAG(USE_SYSTEM_FREETYPE)
constexpr int32_t kFontObjectsMemoryConsumption = …;
#else
constexpr int32_t kFontObjectsMemoryConsumption = 2128;
#endif
SimpleFontData::SimpleFontData(const FontPlatformData* platform_data,
const CustomFontData* custom_data,
bool subpixel_ascent_descent,
const FontMetricsOverride& metrics_override)
: … { … }
SimpleFontData::~SimpleFontData() { … }
void SimpleFontData::PlatformInit(bool subpixel_ascent_descent,
const FontMetricsOverride& metrics_override) { … }
void SimpleFontData::PlatformGlyphInit() { … }
const SimpleFontData* SimpleFontData::FontDataForCharacter(UChar32) const { … }
Glyph SimpleFontData::GlyphForCharacter(UChar32 codepoint) const { … }
bool SimpleFontData::IsSegmented() const { … }
SimpleFontData* SimpleFontData::SmallCapsFontData(
const FontDescription& font_description) const { … }
SimpleFontData* SimpleFontData::EmphasisMarkFontData(
const FontDescription& font_description) const { … }
SimpleFontData* SimpleFontData::CreateScaledFontData(
const FontDescription& font_description,
float scale_factor) const { … }
SimpleFontData* SimpleFontData::MetricsOverriddenFontData(
const FontMetricsOverride& metrics_override) const { … }
FontHeight SimpleFontData::NormalizedTypoAscentAndDescent(
FontBaseline baseline_type) const { … }
LayoutUnit SimpleFontData::NormalizedTypoAscent(
FontBaseline baseline_type) const { … }
LayoutUnit SimpleFontData::NormalizedTypoDescent(
FontBaseline baseline_type) const { … }
static std::pair<int16_t, int16_t> TypoAscenderAndDescender(
SkTypeface* typeface) { … }
void SimpleFontData::ComputeNormalizedTypoAscentAndDescent() const { … }
bool SimpleFontData::TrySetNormalizedTypoAscentAndDescent(float ascent,
float descent) const { … }
LayoutUnit SimpleFontData::VerticalPosition(
FontVerticalPositionType position_type,
FontBaseline baseline_type) const { … }
const std::optional<float>& SimpleFontData::IdeographicAdvanceWidth() const { … }
const std::optional<float>& SimpleFontData::IdeographicAdvanceHeight() const { … }
const std::optional<float>& SimpleFontData::IdeographicInlineSize() const { … }
const HanKerning::FontData& SimpleFontData::HanKerningData(
const LayoutLocale& locale,
bool is_horizontal) const { … }
gfx::RectF SimpleFontData::PlatformBoundsForGlyph(Glyph glyph) const { … }
void SimpleFontData::BoundsForGlyphs(const Vector<Glyph, 256>& glyphs,
Vector<SkRect, 256>* bounds) const { … }
float SimpleFontData::WidthForGlyph(Glyph glyph) const { … }
}