Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skia::textlayout::LangIterator Class Referencefinal

#include <Iterators.h>

Inheritance diagram for skia::textlayout::LangIterator:
SkShaper::LanguageRunIterator SkShaper::RunIterator

Public Member Functions

 LangIterator (SkSpan< const char > utf8, SkSpan< Block > styles, const TextStyle &defaultStyle)
 
void consume () override
 
size_t endOfCurrentRun () const override
 
bool atEnd () const override
 
const char * currentLanguage () const override
 
- Public Member Functions inherited from SkShaper::RunIterator
virtual ~RunIterator ()=default
 

Detailed Description

Definition at line 14 of file Iterators.h.

Constructor & Destructor Documentation

◆ LangIterator()

skia::textlayout::LangIterator::LangIterator ( SkSpan< const char >  utf8,
SkSpan< Block styles,
const TextStyle defaultStyle 
)
inline

Definition at line 16 of file Iterators.h.

17 : fText(utf8)
18 , fTextStyles(styles)
19 , fCurrentChar(utf8.begin())
20 , fCurrentStyle(fTextStyles.begin())
21 , fCurrentLocale(defaultStyle.getLocale()) {}

Member Function Documentation

◆ atEnd()

bool skia::textlayout::LangIterator::atEnd ( ) const
inlineoverridevirtual

Return true if consume should no longer be called.

Implements SkShaper::RunIterator.

Definition at line 42 of file Iterators.h.

42{ return fCurrentChar >= fText.end(); }
constexpr T * end() const
Definition SkSpan_impl.h:91

◆ consume()

void skia::textlayout::LangIterator::consume ( )
inlineoverridevirtual

Set state to that of current run and move iterator to end of that run.

Implements SkShaper::RunIterator.

Definition at line 23 of file Iterators.h.

23 {
24 SkASSERT(fCurrentChar < fText.end());
25
26 if (fCurrentStyle == fTextStyles.end()) {
27 fCurrentChar = fText.end();
28 return;
29 }
30
31 fCurrentChar = fText.begin() + fCurrentStyle->fRange.end;
32 fCurrentLocale = fCurrentStyle->fStyle.getLocale();
33 while (++fCurrentStyle != fTextStyles.end() && !fCurrentStyle->fStyle.isPlaceholder()) {
34 if (fCurrentStyle->fStyle.getLocale() != fCurrentLocale) {
35 break;
36 }
37 fCurrentChar = fText.begin() + fCurrentStyle->fRange.end;
38 }
39 }
#define SkASSERT(cond)
Definition SkAssert.h:116
constexpr T * begin() const
Definition SkSpan_impl.h:90
SkString getLocale() const
Definition TextStyle.h:279

◆ currentLanguage()

const char * skia::textlayout::LangIterator::currentLanguage ( ) const
inlineoverridevirtual

Should be BCP-47, c locale names may also work.

Implements SkShaper::LanguageRunIterator.

Definition at line 43 of file Iterators.h.

43{ return fCurrentLocale.c_str(); }
const char * c_str() const
Definition SkString.h:133

◆ endOfCurrentRun()

size_t skia::textlayout::LangIterator::endOfCurrentRun ( ) const
inlineoverridevirtual

Offset to one past the last (utf8) element in the current run.

Implements SkShaper::RunIterator.

Definition at line 41 of file Iterators.h.

41{ return fCurrentChar - fText.begin(); }

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