Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
skia::textlayout::Paragraph Class Referenceabstract

#include <Paragraph.h>

Inheritance diagram for skia::textlayout::Paragraph:
skia::textlayout::ParagraphImpl

Classes

struct  ExtendedVisitorInfo
 
struct  FontInfo
 
struct  GlyphClusterInfo
 
struct  GlyphInfo
 
struct  VisitorInfo
 

Public Types

enum  VisitorFlags { kWhiteSpace_VisitorFlag = 1 << 0 }
 
using Visitor = std::function< void(int lineNumber, const VisitorInfo *)>
 
using ExtendedVisitor = std::function< void(int lineNumber, const ExtendedVisitorInfo *)>
 

Public Member Functions

 Paragraph (ParagraphStyle style, sk_sp< FontCollection > fonts)
 
virtual ~Paragraph ()=default
 
SkScalar getMaxWidth ()
 
SkScalar getHeight ()
 
SkScalar getMinIntrinsicWidth ()
 
SkScalar getMaxIntrinsicWidth ()
 
SkScalar getAlphabeticBaseline ()
 
SkScalar getIdeographicBaseline ()
 
SkScalar getLongestLine ()
 
bool didExceedMaxLines ()
 
virtual void layout (SkScalar width)=0
 
virtual void paint (SkCanvas *canvas, SkScalar x, SkScalar y)=0
 
virtual void paint (ParagraphPainter *painter, SkScalar x, SkScalar y)=0
 
virtual std::vector< TextBoxgetRectsForRange (unsigned start, unsigned end, RectHeightStyle rectHeightStyle, RectWidthStyle rectWidthStyle)=0
 
virtual std::vector< TextBoxgetRectsForPlaceholders ()=0
 
virtual PositionWithAffinity getGlyphPositionAtCoordinate (SkScalar dx, SkScalar dy)=0
 
virtual SkRange< size_t > getWordBoundary (unsigned offset)=0
 
virtual void getLineMetrics (std::vector< LineMetrics > &)=0
 
virtual size_t lineNumber ()=0
 
virtual void markDirty ()=0
 
virtual int32_t unresolvedGlyphs ()=0
 
virtual std::unordered_set< SkUnicharunresolvedCodepoints ()=0
 
virtual void updateTextAlign (TextAlign textAlign)=0
 
virtual void updateFontSize (size_t from, size_t to, SkScalar fontSize)=0
 
virtual void updateForegroundPaint (size_t from, size_t to, SkPaint paint)=0
 
virtual void updateBackgroundPaint (size_t from, size_t to, SkPaint paint)=0
 
virtual void visit (const Visitor &)=0
 
virtual void extendedVisit (const ExtendedVisitor &)=0
 
virtual int getPath (int lineNumber, SkPath *dest)=0
 
virtual bool containsEmoji (SkTextBlob *textBlob)=0
 
virtual bool containsColorFontOrBitmap (SkTextBlob *textBlob)=0
 
virtual int getLineNumberAt (TextIndex codeUnitIndex) const =0
 
virtual int getLineNumberAtUTF16Offset (size_t codeUnitIndex)=0
 
virtual bool getLineMetricsAt (int lineNumber, LineMetrics *lineMetrics) const =0
 
virtual TextRange getActualTextRange (int lineNumber, bool includeSpaces) const =0
 
virtual bool getGlyphClusterAt (TextIndex codeUnitIndex, GlyphClusterInfo *glyphInfo)=0
 
virtual bool getClosestGlyphClusterAt (SkScalar dx, SkScalar dy, GlyphClusterInfo *glyphInfo)=0
 
virtual bool getGlyphInfoAtUTF16Offset (size_t codeUnitIndex, GlyphInfo *glyphInfo)=0
 
virtual bool getClosestUTF16GlyphInfoAt (SkScalar dx, SkScalar dy, GlyphInfo *glyphInfo)=0
 
virtual SkFont getFontAt (TextIndex codeUnitIndex) const =0
 
virtual SkFont getFontAtUTF16Offset (size_t codeUnitIndex)=0
 
virtual std::vector< FontInfogetFonts () const =0
 

Static Public Member Functions

static SkPath GetPath (SkTextBlob *textBlob)
 

Protected Attributes

sk_sp< FontCollectionfFontCollection
 
ParagraphStyle fParagraphStyle
 
SkScalar fAlphabeticBaseline
 
SkScalar fIdeographicBaseline
 
SkScalar fHeight
 
SkScalar fWidth
 
SkScalar fMaxIntrinsicWidth
 
SkScalar fMinIntrinsicWidth
 
SkScalar fLongestLine
 
bool fExceededMaxLines
 

Detailed Description

Definition at line 19 of file Paragraph.h.

Member Typedef Documentation

◆ ExtendedVisitor

Definition at line 112 of file Paragraph.h.

◆ Visitor

Definition at line 98 of file Paragraph.h.

Member Enumeration Documentation

◆ VisitorFlags

Enumerator
kWhiteSpace_VisitorFlag 

Definition at line 83 of file Paragraph.h.

83 {
85 };

Constructor & Destructor Documentation

◆ Paragraph()

skia::textlayout::Paragraph::Paragraph ( ParagraphStyle  style,
sk_sp< FontCollection fonts 
)

Definition at line 58 of file ParagraphImpl.cpp.

59 : fFontCollection(std::move(fonts))
60 , fParagraphStyle(std::move(style))
63 , fHeight(0)
64 , fWidth(0)
67 , fLongestLine(0)
69{
71}
#define SkASSERT(cond)
Definition: SkAssert.h:116
ParagraphStyle fParagraphStyle
Definition: Paragraph.h:274
sk_sp< FontCollection > fFontCollection
Definition: Paragraph.h:273
it will be possible to load the file into Perfetto s trace viewer disable asset fonts
Definition: switches.h:213

◆ ~Paragraph()

virtual skia::textlayout::Paragraph::~Paragraph ( )
virtualdefault

Member Function Documentation

◆ containsColorFontOrBitmap()

virtual bool skia::textlayout::Paragraph::containsColorFontOrBitmap ( SkTextBlob textBlob)
pure virtual

◆ containsEmoji()

virtual bool skia::textlayout::Paragraph::containsEmoji ( SkTextBlob textBlob)
pure virtual

◆ didExceedMaxLines()

bool skia::textlayout::Paragraph::didExceedMaxLines ( )
inline

Definition at line 40 of file Paragraph.h.

40{ return fExceededMaxLines; }

◆ extendedVisit()

virtual void skia::textlayout::Paragraph::extendedVisit ( const ExtendedVisitor )
pure virtual

◆ getActualTextRange()

virtual TextRange skia::textlayout::Paragraph::getActualTextRange ( int  lineNumber,
bool  includeSpaces 
) const
pure virtual

◆ getAlphabeticBaseline()

SkScalar skia::textlayout::Paragraph::getAlphabeticBaseline ( )
inline

Definition at line 34 of file Paragraph.h.

34{ return fAlphabeticBaseline; }

◆ getClosestGlyphClusterAt()

virtual bool skia::textlayout::Paragraph::getClosestGlyphClusterAt ( SkScalar  dx,
SkScalar  dy,
GlyphClusterInfo glyphInfo 
)
pure virtual

Finds the closest glyph cluster for a visual text position

Parameters
dxx coordinate
dyy coordinate
glyphInfoa glyph cluster info filled if not null
Returns
true if glyph cluster was found; false if not (which usually means the paragraph is empty)

Implemented in skia::textlayout::ParagraphImpl.

◆ getClosestUTF16GlyphInfoAt()

virtual bool skia::textlayout::Paragraph::getClosestUTF16GlyphInfoAt ( SkScalar  dx,
SkScalar  dy,
GlyphInfo glyphInfo 
)
pure virtual

Finds the information associated with the closest glyph to the given paragraph coordinates.

Parameters
dxx coordinate
dyy coordinate
glyphInfoan optional GlyphInfo struct to hold the information associated with the glyph found. The text indices and text ranges are described using UTF-16 offsets
Returns
true if a graphme cluster was found; false if not (which usually means the paragraph is empty)

Implemented in skia::textlayout::ParagraphImpl.

◆ getFontAt()

virtual SkFont skia::textlayout::Paragraph::getFontAt ( TextIndex  codeUnitIndex) const
pure virtual

Returns the font that is used to shape the text at the position

Parameters
codeUnitIndextext index
Returns
font info or an empty font info if the text is not found

Implemented in skia::textlayout::ParagraphImpl.

◆ getFontAtUTF16Offset()

virtual SkFont skia::textlayout::Paragraph::getFontAtUTF16Offset ( size_t  codeUnitIndex)
pure virtual

Returns the font used to shape the text at the given UTF-16 offset.

Parameters
codeUnitIndexa UTF-16 offset in the paragraph
Returns
font info or an empty font info if the text is not found

Implemented in skia::textlayout::ParagraphImpl.

◆ getFonts()

virtual std::vector< FontInfo > skia::textlayout::Paragraph::getFonts ( ) const
pure virtual

Returns the information about all the fonts used to shape the paragraph text

Returns
a list of fonts and text ranges

Implemented in skia::textlayout::ParagraphImpl.

◆ getGlyphClusterAt()

virtual bool skia::textlayout::Paragraph::getGlyphClusterAt ( TextIndex  codeUnitIndex,
GlyphClusterInfo glyphInfo 
)
pure virtual

Finds a glyph cluster for text index

Parameters
codeUnitIndexa text index
glyphInfoa glyph cluster info filled if not null
Returns
true if glyph cluster was found; false if not

Implemented in skia::textlayout::ParagraphImpl.

◆ getGlyphInfoAtUTF16Offset()

virtual bool skia::textlayout::Paragraph::getGlyphInfoAtUTF16Offset ( size_t  codeUnitIndex,
GlyphInfo glyphInfo 
)
pure virtual

Retrives the information associated with the glyph located at the given codeUnitIndex.

Parameters
codeUnitIndexa UTF-16 offset into the paragraph
glyphInfoan optional GlyphInfo struct to hold the information associated with the glyph found at the given index
Returns
false only if the offset is out of bounds

Implemented in skia::textlayout::ParagraphImpl.

◆ getGlyphPositionAtCoordinate()

virtual PositionWithAffinity skia::textlayout::Paragraph::getGlyphPositionAtCoordinate ( SkScalar  dx,
SkScalar  dy 
)
pure virtual

◆ getHeight()

SkScalar skia::textlayout::Paragraph::getHeight ( )
inline

Definition at line 28 of file Paragraph.h.

28{ return fHeight; }

◆ getIdeographicBaseline()

SkScalar skia::textlayout::Paragraph::getIdeographicBaseline ( )
inline

Definition at line 36 of file Paragraph.h.

36{ return fIdeographicBaseline; }

◆ getLineMetrics()

virtual void skia::textlayout::Paragraph::getLineMetrics ( std::vector< LineMetrics > &  )
pure virtual

◆ getLineMetricsAt()

virtual bool skia::textlayout::Paragraph::getLineMetricsAt ( int  lineNumber,
LineMetrics lineMetrics 
) const
pure virtual

◆ getLineNumberAt()

virtual int skia::textlayout::Paragraph::getLineNumberAt ( TextIndex  codeUnitIndex) const
pure virtual

◆ getLineNumberAtUTF16Offset()

virtual int skia::textlayout::Paragraph::getLineNumberAtUTF16Offset ( size_t  codeUnitIndex)
pure virtual

◆ getLongestLine()

SkScalar skia::textlayout::Paragraph::getLongestLine ( )
inline

Definition at line 38 of file Paragraph.h.

38{ return fLongestLine; }

◆ getMaxIntrinsicWidth()

SkScalar skia::textlayout::Paragraph::getMaxIntrinsicWidth ( )
inline

Definition at line 32 of file Paragraph.h.

32{ return fMaxIntrinsicWidth; }

◆ getMaxWidth()

SkScalar skia::textlayout::Paragraph::getMaxWidth ( )
inline

Definition at line 26 of file Paragraph.h.

26{ return fWidth; }

◆ getMinIntrinsicWidth()

SkScalar skia::textlayout::Paragraph::getMinIntrinsicWidth ( )
inline

Definition at line 30 of file Paragraph.h.

30{ return fMinIntrinsicWidth; }

◆ getPath()

virtual int skia::textlayout::Paragraph::getPath ( int  lineNumber,
SkPath dest 
)
pure virtual

◆ GetPath()

SkPath skia::textlayout::Paragraph::GetPath ( SkTextBlob textBlob)
static

Definition at line 1504 of file ParagraphImpl.cpp.

1504 {
1505 SkPath path;
1506 SkTextBlobRunIterator iter(textBlob);
1507 while (!iter.done()) {
1508 SkFont font = iter.font();
1509 struct Rec { SkPath* fDst; SkPoint fOffset; const SkPoint* fPos; } rec =
1510 {&path, {textBlob->bounds().left(), textBlob->bounds().top()},
1511 iter.points()};
1512 font.getPaths(iter.glyphs(), iter.glyphCount(),
1513 [](const SkPath* src, const SkMatrix& mx, void* ctx) {
1514 Rec* rec = (Rec*)ctx;
1515 if (src) {
1516 SkMatrix tmp(mx);
1517 tmp.postTranslate(rec->fPos->fX - rec->fOffset.fX,
1518 rec->fPos->fY - rec->fOffset.fY);
1519 rec->fDst->addPath(*src, tmp);
1520 }
1521 rec->fPos += 1;
1522 },
1523 &rec);
1524 iter.next();
1525 }
1526 return path;
1527}
SkRect fDst
Definition: LatticeOp.cpp:381
Definition: SkFont.h:35
Definition: SkPath.h:59
const SkRect & bounds() const
Definition: SkTextBlob.h:53
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
font
Font Metadata and Metrics.
constexpr float left() const
Definition: SkRect.h:734
constexpr float top() const
Definition: SkRect.h:741

◆ getRectsForPlaceholders()

virtual std::vector< TextBox > skia::textlayout::Paragraph::getRectsForPlaceholders ( )
pure virtual

◆ getRectsForRange()

virtual std::vector< TextBox > skia::textlayout::Paragraph::getRectsForRange ( unsigned  start,
unsigned  end,
RectHeightStyle  rectHeightStyle,
RectWidthStyle  rectWidthStyle 
)
pure virtual

◆ getWordBoundary()

virtual SkRange< size_t > skia::textlayout::Paragraph::getWordBoundary ( unsigned  offset)
pure virtual

◆ layout()

virtual void skia::textlayout::Paragraph::layout ( SkScalar  width)
pure virtual

◆ lineNumber()

virtual size_t skia::textlayout::Paragraph::lineNumber ( )
pure virtual

◆ markDirty()

virtual void skia::textlayout::Paragraph::markDirty ( )
pure virtual

◆ paint() [1/2]

virtual void skia::textlayout::Paragraph::paint ( ParagraphPainter painter,
SkScalar  x,
SkScalar  y 
)
pure virtual

◆ paint() [2/2]

virtual void skia::textlayout::Paragraph::paint ( SkCanvas canvas,
SkScalar  x,
SkScalar  y 
)
pure virtual

◆ unresolvedCodepoints()

virtual std::unordered_set< SkUnichar > skia::textlayout::Paragraph::unresolvedCodepoints ( )
pure virtual

◆ unresolvedGlyphs()

virtual int32_t skia::textlayout::Paragraph::unresolvedGlyphs ( )
pure virtual

◆ updateBackgroundPaint()

virtual void skia::textlayout::Paragraph::updateBackgroundPaint ( size_t  from,
size_t  to,
SkPaint  paint 
)
pure virtual

◆ updateFontSize()

virtual void skia::textlayout::Paragraph::updateFontSize ( size_t  from,
size_t  to,
SkScalar  fontSize 
)
pure virtual

◆ updateForegroundPaint()

virtual void skia::textlayout::Paragraph::updateForegroundPaint ( size_t  from,
size_t  to,
SkPaint  paint 
)
pure virtual

◆ updateTextAlign()

virtual void skia::textlayout::Paragraph::updateTextAlign ( TextAlign  textAlign)
pure virtual

◆ visit()

virtual void skia::textlayout::Paragraph::visit ( const Visitor )
pure virtual

Member Data Documentation

◆ fAlphabeticBaseline

SkScalar skia::textlayout::Paragraph::fAlphabeticBaseline
protected

Definition at line 277 of file Paragraph.h.

◆ fExceededMaxLines

bool skia::textlayout::Paragraph::fExceededMaxLines
protected

Definition at line 284 of file Paragraph.h.

◆ fFontCollection

sk_sp<FontCollection> skia::textlayout::Paragraph::fFontCollection
protected

Definition at line 273 of file Paragraph.h.

◆ fHeight

SkScalar skia::textlayout::Paragraph::fHeight
protected

Definition at line 279 of file Paragraph.h.

◆ fIdeographicBaseline

SkScalar skia::textlayout::Paragraph::fIdeographicBaseline
protected

Definition at line 278 of file Paragraph.h.

◆ fLongestLine

SkScalar skia::textlayout::Paragraph::fLongestLine
protected

Definition at line 283 of file Paragraph.h.

◆ fMaxIntrinsicWidth

SkScalar skia::textlayout::Paragraph::fMaxIntrinsicWidth
protected

Definition at line 281 of file Paragraph.h.

◆ fMinIntrinsicWidth

SkScalar skia::textlayout::Paragraph::fMinIntrinsicWidth
protected

Definition at line 282 of file Paragraph.h.

◆ fParagraphStyle

ParagraphStyle skia::textlayout::Paragraph::fParagraphStyle
protected

Definition at line 274 of file Paragraph.h.

◆ fWidth

SkScalar skia::textlayout::Paragraph::fWidth
protected

Definition at line 280 of file Paragraph.h.


The documentation for this class was generated from the following files: