#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/fonts/font.h"
#include "cc/paint/paint_canvas.h"
#include "cc/paint/paint_flags.h"
#include "third_party/blink/renderer/platform/fonts/character_range.h"
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
#include "third_party/blink/renderer/platform/fonts/font_fallback_list.h"
#include "third_party/blink/renderer/platform/fonts/font_fallback_map.h"
#include "third_party/blink/renderer/platform/fonts/shaping/caching_word_shaper.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_bloberizer.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_view.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
#include "third_party/blink/renderer/platform/fonts/text_fragment_paint_info.h"
#include "third_party/blink/renderer/platform/fonts/text_run_paint_info.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
#include "third_party/blink/renderer/platform/text/bidi_paragraph.h"
#include "third_party/blink/renderer/platform/text/character.h"
#include "third_party/blink/renderer/platform/text/text_run.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_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/skia/include/core/SkTextBlob.h"
#include "ui/gfx/geometry/rect_f.h"
namespace blink {
namespace {
FontFallbackList* GetOrCreateFontFallbackList(
const FontDescription& font_description,
FontSelector* font_selector) { … }
}
Font::Font() = default;
Font::Font(const FontDescription& fd) : … { … }
Font::Font(const FontDescription& font_description, FontSelector* font_selector)
: … { … }
FontFallbackList* Font::EnsureFontFallbackList() const { … }
bool Font::operator==(const Font& other) const { … }
namespace {
void DrawBlobs(cc::PaintCanvas* canvas,
const cc::PaintFlags& flags,
const ShapeResultBloberizer::BlobBuffer& blobs,
const gfx::PointF& point,
cc::NodeId node_id = cc::kInvalidNodeId) { … }
}
void Font::DrawText(cc::PaintCanvas* canvas,
const TextRunPaintInfo& run_info,
const gfx::PointF& point,
const cc::PaintFlags& flags,
DrawType draw_type) const { … }
void Font::DrawText(cc::PaintCanvas* canvas,
const TextRunPaintInfo& run_info,
const gfx::PointF& point,
cc::NodeId node_id,
const cc::PaintFlags& flags,
DrawType draw_type) const { … }
void Font::DrawText(cc::PaintCanvas* canvas,
const TextFragmentPaintInfo& text_info,
const gfx::PointF& point,
cc::NodeId node_id,
const cc::PaintFlags& flags,
DrawType draw_type) const { … }
bool Font::DrawBidiText(cc::PaintCanvas* canvas,
const TextRunPaintInfo& run_info,
const gfx::PointF& point,
CustomFontNotReadyAction custom_font_not_ready_action,
const cc::PaintFlags& flags,
DrawType draw_type) const { … }
void Font::DrawEmphasisMarks(cc::PaintCanvas* canvas,
const TextRunPaintInfo& run_info,
const AtomicString& mark,
const gfx::PointF& point,
const cc::PaintFlags& flags) const { … }
void Font::DrawEmphasisMarks(cc::PaintCanvas* canvas,
const TextFragmentPaintInfo& text_info,
const AtomicString& mark,
const gfx::PointF& point,
const cc::PaintFlags& flags) const { … }
gfx::RectF Font::TextInkBounds(const TextFragmentPaintInfo& text_info) const { … }
float Font::Width(const TextRun& run, gfx::RectF* glyph_bounds) const { … }
namespace {
unsigned InterceptsFromBlobs(const ShapeResultBloberizer::BlobBuffer& blobs,
const SkPaint& paint,
const std::tuple<float, float>& bounds,
SkScalar* intercepts_buffer) { … }
void GetTextInterceptsInternal(const ShapeResultBloberizer::BlobBuffer& blobs,
const cc::PaintFlags& flags,
const std::tuple<float, float>& bounds,
Vector<Font::TextIntercept>& intercepts) { … }
}
void Font::GetTextIntercepts(const TextRunPaintInfo& run_info,
const cc::PaintFlags& flags,
const std::tuple<float, float>& bounds,
Vector<TextIntercept>& intercepts) const { … }
void Font::GetTextIntercepts(const TextFragmentPaintInfo& text_info,
const cc::PaintFlags& flags,
const std::tuple<float, float>& bounds,
Vector<TextIntercept>& intercepts) const { … }
static inline gfx::RectF PixelSnappedSelectionRect(const gfx::RectF& rect) { … }
gfx::RectF Font::SelectionRectForText(const TextRun& run,
const gfx::PointF& point,
float height,
int from,
int to) const { … }
int Font::OffsetForPosition(const TextRun& run,
float x_float,
IncludePartialGlyphsOption partial_glyphs,
BreakGlyphsOption break_glyphs) const { … }
NGShapeCache& Font::GetNGShapeCache() const { … }
ShapeCache* Font::GetShapeCache() const { … }
bool Font::CanShapeWordByWord() const { … }
void Font::ReportNotDefGlyph() const { … }
void Font::ReportEmojiSegmentGlyphCoverage(unsigned num_clusters,
unsigned num_broken_clusters) const { … }
void Font::WillUseFontData(const String& text) const { … }
GlyphData Font::GetEmphasisMarkGlyphData(const AtomicString& mark) const { … }
int Font::EmphasisMarkAscent(const AtomicString& mark) const { … }
int Font::EmphasisMarkDescent(const AtomicString& mark) const { … }
int Font::EmphasisMarkHeight(const AtomicString& mark) const { … }
float Font::TabWidth(const SimpleFontData* font_data,
const TabSize& tab_size,
float position) const { … }
LayoutUnit Font::TabWidth(const TabSize& tab_size, LayoutUnit position) const { … }
bool Font::IsFallbackValid() const { … }
}