22
33#include " modules/skparagraph/src/Iterators.h"
44#include " modules/skparagraph/src/OneLineShaper.h"
5- #include < unicode/uchar.h >
5+ #include " modules/skparagraph/src/ParagraphUtil.h "
66#include < algorithm>
77#include < unordered_set>
8- #include " src/utils/SkUTF.h"
98
109namespace skia {
1110namespace textlayout {
1211
13- namespace {
14-
15- SkUnichar utf8_next (const char ** ptr, const char * end) {
16- SkUnichar val = SkUTF::NextUTF8 (ptr, end);
17- return val < 0 ? 0xFFFD : val;
18- }
19-
20- }
21-
2212void OneLineShaper::commitRunBuffer (const RunInfo&) {
2313
2414 fCurrentRun ->commit ();
@@ -313,8 +303,8 @@ void OneLineShaper::sortOutGlyphs(std::function<void(GlyphRange)>&& sortOutUnres
313303 block.end = i;
314304 } else {
315305 const char * cluster = text.begin () + clusterIndex (i);
316- SkUnichar codepoint = utf8_next (&cluster, text.end ());
317- if (u_iscntrl (codepoint)) {
306+ SkUnichar codepoint = nextUtf8Unit (&cluster, text.end ());
307+ if (isControl (codepoint)) {
318308 // This codepoint does not have to be resolved; let's pretend it's resolved
319309 if (block.start == EMPTY_INDEX) {
320310 // Keep skipping resolved code points
@@ -419,7 +409,7 @@ void OneLineShaper::matchResolvedFonts(const TextStyle& textStyle,
419409 // We have the global cache for all already found typefaces for SkUnichar
420410 // but we still need to keep track of all SkUnichars used in this unresolved block
421411 SkTHashSet<SkUnichar> alreadyTried;
422- SkUnichar unicode = utf8_next (&ch, unresolvedText.end ());
412+ SkUnichar unicode = nextUtf8Unit (&ch, unresolvedText.end ());
423413 while (true ) {
424414
425415 sk_sp<SkTypeface> typeface;
@@ -457,7 +447,7 @@ void OneLineShaper::matchResolvedFonts(const TextStyle& textStyle,
457447
458448 // We can stop here or we can switch to another DIFFERENT codepoint
459449 while (ch != unresolvedText.end ()) {
460- unicode = utf8_next (&ch, unresolvedText.end ());
450+ unicode = nextUtf8Unit (&ch, unresolvedText.end ());
461451 auto found = alreadyTried.find (unicode);
462452 if (found == nullptr ) {
463453 alreadyTried.add (unicode);
@@ -472,10 +462,6 @@ void OneLineShaper::matchResolvedFonts(const TextStyle& textStyle,
472462
473463bool OneLineShaper::iterateThroughShapingRegions (const ShapeVisitor& shape) {
474464
475- if (!fParagraph ->getBidiRegions ()) {
476- return false ;
477- }
478-
479465 size_t bidiIndex = 0 ;
480466
481467 SkScalar advanceX = 0 ;
@@ -485,20 +471,20 @@ bool OneLineShaper::iterateThroughShapingRegions(const ShapeVisitor& shape) {
485471 // Shape the text by bidi regions
486472 while (bidiIndex < fParagraph ->fBidiRegions .size ()) {
487473 BidiRegion& bidiRegion = fParagraph ->fBidiRegions [bidiIndex];
488- auto start = std::max (bidiRegion.text . start , placeholder.fTextBefore .start );
489- auto end = std::min (bidiRegion.text . end , placeholder.fTextBefore .end );
474+ auto start = std::max (bidiRegion.start , placeholder.fTextBefore .start );
475+ auto end = std::min (bidiRegion.end , placeholder.fTextBefore .end );
490476
491477 // Set up the iterators (the style iterator points to a bigger region that it could
492478 TextRange textRange (start, end);
493479 auto blockRange = fParagraph ->findAllBlocks (textRange);
494480 SkSpan<Block> styleSpan (fParagraph ->blocks (blockRange));
495481
496482 // Shape the text between placeholders
497- if (!shape (textRange, styleSpan, advanceX, start, bidiRegion.direction )) {
483+ if (!shape (textRange, styleSpan, advanceX, start, bidiRegion.level )) {
498484 return false ;
499485 }
500486
501- if (end == bidiRegion.text . end ) {
487+ if (end == bidiRegion.end ) {
502488 ++bidiIndex;
503489 } else /* if (end == placeholder.fTextBefore.end)*/ {
504490 break ;
0 commit comments