diff --git a/modules/skparagraph/include/FontCollection.h b/modules/skparagraph/include/FontCollection.h index 089d476604..d85a4771b4 100644 --- a/modules/skparagraph/include/FontCollection.h +++ b/modules/skparagraph/include/FontCollection.h @@ -29,7 +29,7 @@ public: sk_sp matchTypeface(const char familyName[], SkFontStyle fontStyle); sk_sp matchDefaultTypeface(SkFontStyle fontStyle); - sk_sp defaultFallback(SkUnichar unicode, SkFontStyle fontStyle); + sk_sp defaultFallback(SkUnichar unicode, SkFontStyle fontStyle, SkString locale); void disableFontFallback(); bool fontFallbackEnabled() { return fEnableFontFallback; } diff --git a/modules/skparagraph/skparagraph.gni b/modules/skparagraph/skparagraph.gni index 596aca4917..70005f3ce0 100644 --- a/modules/skparagraph/skparagraph.gni +++ b/modules/skparagraph/skparagraph.gni @@ -18,12 +18,9 @@ skparagraph_public = [ skparagraph_sources = [ "$_src/FontCollection.cpp", - "$_src/FontIterator.h", - "$_src/FontIterator.cpp", "$_src/FontResolver.h", "$_src/FontResolver.cpp", - "$_src/TextLine.h", - "$_src/TextLine.cpp", + "$_src/Iterator.h", "$_src/ParagraphBuilderImpl.h", "$_src/ParagraphBuilderImpl.cpp", "$_src/ParagraphImpl.h", @@ -31,6 +28,8 @@ skparagraph_sources = [ "$_src/ParagraphStyle.cpp", "$_src/Run.h", "$_src/Run.cpp", + "$_src/TextLine.h", + "$_src/TextLine.cpp", "$_src/TextShadow.cpp", "$_src/TextStyle.cpp", "$_src/TextWrapper.h", diff --git a/modules/skparagraph/src/FontCollection.cpp b/modules/skparagraph/src/FontCollection.cpp index c6ea57e068..f9e744c176 100644 --- a/modules/skparagraph/src/FontCollection.cpp +++ b/modules/skparagraph/src/FontCollection.cpp @@ -117,10 +117,13 @@ sk_sp FontCollection::matchDefaultTypeface(SkFontStyle fontStyle) { return nullptr; } -sk_sp FontCollection::defaultFallback(SkUnichar unicode, SkFontStyle fontStyle) { +sk_sp FontCollection::defaultFallback(SkUnichar unicode, SkFontStyle fontStyle, SkString locale) { for (const auto& manager : this->getFontManagerOrder()) { std::vector bcp47; + if (!locale.isEmpty()) { + bcp47.push_back(locale.c_str()); + } sk_sp typeface(manager->matchFamilyStyleCharacter( 0, fontStyle, bcp47.data(), bcp47.size(), unicode)); if (typeface != nullptr) { diff --git a/modules/skparagraph/src/FontIterator.cpp b/modules/skparagraph/src/FontIterator.cpp deleted file mode 100644 index 7cb3446c0f..0000000000 --- a/modules/skparagraph/src/FontIterator.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2019 Google LLC. -#include "modules/skparagraph/src/FontIterator.h" -#include -#include -#include "include/core/SkBlurTypes.h" -#include "include/core/SkCanvas.h" -#include "include/core/SkFontMgr.h" -#include "include/core/SkPictureRecorder.h" -#include "modules/skparagraph/src/ParagraphImpl.h" -#include "src/core/SkSpan.h" -#include "src/utils/SkUTF.h" - -// TODO: FontCollection and FontIterator have common functionality -namespace skia { -namespace textlayout { - -FontIterator::FontIterator(SkSpan utf8, - SkSpan styles, - sk_sp fonts) - : fText(utf8) - , fStyles(styles) - , fCurrentChar(utf8.begin()) - , fFontResolver(std::move(fonts)) { - findAllFontsForAllStyledBlocks(); -} - -void FontIterator::consume() { - SkASSERT(fCurrentChar < fText.end()); - auto found = fFontResolver.findFirst(fCurrentChar, &fFont, &fLineHeight); - SkASSERT(found); - - // Move until we find the first character that cannot be resolved with the current font - while (++fCurrentChar != fText.end()) { - SkFont font; - SkScalar height; - found = fFontResolver.findNext(fCurrentChar, &font, &height); - if (found) { - if (fFont == font && fLineHeight == height) { - continue; - } - break; - } - } -} - -void FontIterator::findAllFontsForAllStyledBlocks() { - TextBlock combined; - for (auto& block : fStyles) { - SkASSERT(combined.text().begin() == nullptr || - combined.text().end() == block.text().begin()); - - if (combined.text().begin() != nullptr && - block.style().matchOneAttribute(StyleType::kFont, combined.style())) { - combined.add(block.text()); - continue; - } - - if (!combined.text().empty()) { - fFontResolver.findAllFontsForStyledBlock(combined.style(), combined.text()); - } - - combined = block; - } - fFontResolver.findAllFontsForStyledBlock(combined.style(), combined.text()); -} - -} // namespace textlayout -} // namespace skia diff --git a/modules/skparagraph/src/FontIterator.h b/modules/skparagraph/src/FontIterator.h deleted file mode 100644 index f6396f5207..0000000000 --- a/modules/skparagraph/src/FontIterator.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2019 Google LLC. -#ifndef FontIterator_DEFINED -#define FontIterator_DEFINED - -#include -#include -#include "include/core/SkBlurTypes.h" -#include "include/core/SkCanvas.h" -#include "include/core/SkFontMgr.h" -#include "include/core/SkPictureRecorder.h" -#include "modules/skparagraph/src/FontResolver.h" -#include "modules/skparagraph/src/ParagraphImpl.h" -#include "src/core/SkSpan.h" -#include "src/utils/SkUTF.h" - -namespace skia { -namespace textlayout { - -class FontIterator final : public SkShaper::FontRunIterator { -public: - FontIterator(SkSpan utf8, - SkSpan styles, - sk_sp fonts); - - void consume() override; - - size_t endOfCurrentRun() const override { return fCurrentChar - fText.begin(); } - bool atEnd() const override { return fCurrentChar == fText.end(); } - const SkFont& currentFont() const override { return fFont; } - SkScalar lineHeight() const { return fLineHeight; } - -private: - struct Hash { - uint32_t operator()(const std::pair& key) const { - return SkTypeface::UniqueID(key.first.getTypeface()) + - SkScalarCeilToInt(key.first.getSize()) + SkScalarCeilToInt(key.second); - } - }; - - void findAllFontsForAllStyledBlocks(); - - SkSpan fText; - SkSpan fStyles; - const char* fCurrentChar; - SkFont fFont; - SkScalar fLineHeight; - FontResolver fFontResolver; -}; -} // namespace textlayout -} // namespace skia - -#endif // FontIterator_DEFINED diff --git a/modules/skparagraph/src/FontResolver.cpp b/modules/skparagraph/src/FontResolver.cpp index 0b63defa8f..6ceb9dbcf1 100644 --- a/modules/skparagraph/src/FontResolver.cpp +++ b/modules/skparagraph/src/FontResolver.cpp @@ -22,9 +22,6 @@ SkUnichar utf8_next(const char** ptr, const char* end) { namespace skia { namespace textlayout { -FontResolver::FontResolver(sk_sp fontCollection) - : fFontCollection(fontCollection) {} - bool FontResolver::findFirst(const char* codepoint, SkFont* font, SkScalar* height) { auto found = fFontMapping.find(codepoint); if (found == nullptr) { @@ -34,8 +31,8 @@ bool FontResolver::findFirst(const char* codepoint, SkFont* font, SkScalar* heig if (found == nullptr) { return false; } - *font = found->first; - *height = found->second; + *font = found->fFont; + *height = found->fHeight; return true; } @@ -44,8 +41,8 @@ bool FontResolver::findNext(const char* codepoint, SkFont* font, SkScalar* heigh if (found == nullptr) { return false; } - *font = found->first; - *height = found->second; + *font = found->fFont; + *height = found->fHeight; return true; } @@ -93,7 +90,7 @@ void FontResolver::findAllFontsForStyledBlock(const TextStyle& style, SkSpan 0 && fFontCollection->fontFallbackEnabled()) { while (fUnresolved > 0) { auto unicode = firstUnresolved(); - auto typeface = fFontCollection->defaultFallback(unicode, style.getFontStyle()); + auto typeface = fFontCollection->defaultFallback(unicode, style.getFontStyle(), style.getLocale()); if (typeface == nullptr) { break; } @@ -110,11 +107,12 @@ void FontResolver::findAllFontsForStyledBlock(const TextStyle& style, SkSpandefaultFallback(firstUnresolved(), style.getFontStyle()), - style.getFontSize(), style.getHeight()); - if (fFirstResolvedFont.first.getTypeface() != nullptr) { + makeFont(fFontCollection->defaultFallback(firstUnresolved(), style.getFontStyle(), style.getLocale()), + style.getFontSize(), + style.getHeight()); + if (fFirstResolvedFont.fFont.getTypeface() != nullptr) { SkString name; - fFirstResolvedFont.first.getTypeface()->getFamilyName(&name); + fFirstResolvedFont.fFont.getTypeface()->getFamilyName(&name); SkDebugf("Urgent font resolution: %s\n", name.c_str()); } else { SkDebugf("No font!!!\n"); @@ -122,11 +120,11 @@ void FontResolver::findAllFontsForStyledBlock(const TextStyle& style, SkSpan font) { +size_t FontResolver::resolveAllCharactersByFont(const FontDescr& font) { // Consolidate all unresolved unicodes in one array to make a batch call SkTArray glyphs(fUnresolved); glyphs.push_back_n(fUnresolved, SkGlyphID(0)); - font.first.getTypeface()->unicharsToGlyphs( + font.fFont.getTypeface()->unicharsToGlyphs( fUnresolved == fCodepoints.size() ? fCodepoints.data() : fUnresolvedCodepoints.data(), fUnresolved, glyphs.data()); @@ -209,24 +207,23 @@ void FontResolver::addResolvedWhitespacesToMapping() { fUnresolved -= resolvedWhitespaces; } -std::pair FontResolver::makeFont(sk_sp typeface, - SkScalar size, - SkScalar height) { +FontResolver::FontDescr FontResolver::makeFont(sk_sp typeface, + SkScalar size, + SkScalar height) { SkFont font(typeface, size); font.setEdging(SkFont::Edging::kAntiAlias); font.setHinting(SkFontHinting::kSlight); font.setSubpixel(true); - auto pair = std::make_pair(font, height); + FontDescr descr(font, height); - auto foundFont = fResolvedFonts.find(pair); + const FontDescr* foundFont = fResolvedFonts.find(descr); if (foundFont == nullptr) { if (fResolvedFonts.count() == 0) { - fFirstResolvedFont = pair; + fFirstResolvedFont = descr; } - fResolvedFonts.add(pair); + fResolvedFonts.add(descr); } - - return pair; + return descr; } SkUnichar FontResolver::firstUnresolved() { @@ -236,5 +233,31 @@ SkUnichar FontResolver::firstUnresolved() { auto index = firstTry ? 0 : fUnresolvedIndexes[0]; return fCodepoints[index]; } + +void FontResolver::findAllFontsForAllStyledBlocks(SkSpan utf8, + SkSpan styles, + sk_sp fontCollection) { + fFontCollection = fontCollection; + fStyles = styles; + fText = utf8; + TextBlock combined; + for (auto& block : fStyles) { + SkASSERT(combined.text().begin() == nullptr || + combined.text().end() == block.text().begin()); + + if (combined.text().begin() != nullptr && + block.style().matchOneAttribute(StyleType::kFont, combined.style())) { + combined.add(block.text()); + continue; + } + + if (!combined.text().empty()) { + this->findAllFontsForStyledBlock(combined.style(), combined.text()); + } + + combined = block; + } + this->findAllFontsForStyledBlock(combined.style(), combined.text()); +} } // namespace textlayout } // namespace skia diff --git a/modules/skparagraph/src/FontResolver.h b/modules/skparagraph/src/FontResolver.h index 224b21a2a7..e755c0ca27 100644 --- a/modules/skparagraph/src/FontResolver.h +++ b/modules/skparagraph/src/FontResolver.h @@ -2,54 +2,70 @@ #ifndef FontResolver_DEFINED #define FontResolver_DEFINED -#include "src/core/SkSpan.h" #include #include +#include "modules/skparagraph/src/TextLine.h" #include "include/core/SkFontMgr.h" #include "include/core/SkRefCnt.h" #include "include/private/SkTHash.h" #include "modules/skparagraph/include/FontCollection.h" #include "modules/skparagraph/include/TextStyle.h" +#include "src/core/SkSpan.h" namespace skia { namespace textlayout { class FontResolver { public: - FontResolver(sk_sp fontCollection); + struct FontDescr { + FontDescr() {} + FontDescr(SkFont font, SkScalar height) + : fFont(font), fHeight(height) {} + bool operator==(const FontDescr& a) const { + return this->fFont == a.fFont && this->fHeight == a.fHeight; + } + SkFont fFont; + SkScalar fHeight; + }; + + FontResolver() = default; ~FontResolver() = default; - void findAllFontsForStyledBlock(const TextStyle& style, SkSpan text); + void findAllFontsForAllStyledBlocks(SkSpan utf8, + SkSpan styles, + sk_sp fontCollection); bool findFirst(const char* codepoint, SkFont* font, SkScalar* height); bool findNext(const char* codepoint, SkFont* font, SkScalar* height); private: - std::pair makeFont(sk_sp typeface, SkScalar size, - SkScalar height); - - size_t resolveAllCharactersByFont(std::pair font); + void findAllFontsForStyledBlock(const TextStyle& style, SkSpan text); + FontDescr makeFont(sk_sp typeface, SkScalar size, SkScalar height); + size_t resolveAllCharactersByFont(const FontDescr& fontDescr); void addResolvedWhitespacesToMapping(); struct Hash { - uint32_t operator()(const std::pair& key) const { - return SkTypeface::UniqueID(key.first.getTypeface()) + - SkScalarCeilToInt(key.first.getSize()) + SkScalarCeilToInt(key.second); + uint32_t operator()(const FontDescr& key) const { + return SkTypeface::UniqueID(key.fFont.getTypeface()) + + SkScalarCeilToInt(key.fFont.getSize()) + + SkScalarCeilToInt(key.fHeight); } }; SkUnichar firstUnresolved(); sk_sp fFontCollection; + SkSpan fText; + SkSpan fStyles; - SkTHashMap> fFontMapping; - SkTHashSet, Hash> fResolvedFonts; - std::pair fFirstResolvedFont; + SkTHashMap fFontMapping; + SkTHashSet fResolvedFonts; + FontDescr fFirstResolvedFont; SkTArray fCodepoints; SkTArray fCharacters; SkTArray fUnresolvedIndexes; SkTArray fUnresolvedCodepoints; - SkTHashMap> fWhitespaces; + SkTHashMap fWhitespaces; size_t fUnresolved; }; } // namespace textlayout diff --git a/modules/skparagraph/src/Iterators.h b/modules/skparagraph/src/Iterators.h new file mode 100644 index 0000000000..f53b066849 --- /dev/null +++ b/modules/skparagraph/src/Iterators.h @@ -0,0 +1,100 @@ +// Copyright 2019 Google LLC. +#ifndef FontIterator_DEFINED +#define FontIterator_DEFINED + +#include +#include +#include "include/core/SkBlurTypes.h" +#include "include/core/SkCanvas.h" +#include "include/core/SkFontMgr.h" +#include "include/core/SkPictureRecorder.h" +#include "modules/skparagraph/src/FontResolver.h" +#include "modules/skparagraph/src/ParagraphImpl.h" +#include "src/core/SkSpan.h" +#include "src/utils/SkUTF.h" + +namespace skia { +namespace textlayout { + +class FontIterator final : public SkShaper::FontRunIterator { +public: + FontIterator(SkSpan utf8, FontResolver* fontResolver) + : fText(utf8), fCurrentChar(utf8.begin()), fFontResolver(fontResolver) { } + + void consume() override { + SkASSERT(fCurrentChar < fText.end()); + SkString locale; + auto found = fFontResolver->findFirst(fCurrentChar, &fFont, &fLineHeight); + SkASSERT(found); + + // Move until we find the first character that cannot be resolved with the current font + while (++fCurrentChar != fText.end()) { + SkFont font; + SkScalar height; + SkString locale; + found = fFontResolver->findNext(fCurrentChar, &font, &height); + if (found) { + if (fFont == font && fLineHeight == height) { + continue; + } + break; + } + } + } + + size_t endOfCurrentRun() const override { return fCurrentChar - fText.begin(); } + bool atEnd() const override { return fCurrentChar == fText.end(); } + const SkFont& currentFont() const override { return fFont; } + SkScalar currentLineHeight() const { return fLineHeight; } + +private: + + SkSpan fText; + const char* fCurrentChar; + SkFont fFont; + SkScalar fLineHeight; + FontResolver* fFontResolver; +}; + +class LangIterator final : public SkShaper::LanguageRunIterator { +public: + LangIterator(SkSpan utf8, SkSpan styles, TextStyle defaultStyle) + : fText(utf8) + , fTextStyles(styles) + , fCurrentChar(utf8.begin()) + , fCurrentStyle(fTextStyles.begin()) + , fCurrentLocale(defaultStyle.getLocale()) {} + + void consume() override { + SkASSERT(fCurrentChar < fText.end()); + + if (fCurrentStyle == fTextStyles.end()) { + fCurrentChar = fText.end(); + return; + } + + fCurrentChar = fCurrentStyle->text().end(); + fCurrentLocale = fCurrentStyle->style().getLocale(); + while (++fCurrentStyle != fTextStyles.end()) { + if (fCurrentStyle->style().getLocale() != fCurrentLocale) { + break; + } + fCurrentChar = fCurrentStyle->text().end(); + } + } + + size_t endOfCurrentRun() const override { return fCurrentChar - fText.begin(); } + bool atEnd() const override { return fCurrentChar == fText.end(); } + const char* currentLanguage() const override { return fCurrentLocale.c_str(); } + +private: + SkSpan fText; + SkSpan fTextStyles; + const char* fCurrentChar; + TextBlock* fCurrentStyle; + SkString fCurrentLocale; +}; +} // namespace textlayout +} // namespace skia + +#endif // FontIterator_DEFINED diff --git a/modules/skparagraph/src/ParagraphImpl.cpp b/modules/skparagraph/src/ParagraphImpl.cpp index 4753b321a5..86bc7dfa12 100644 --- a/modules/skparagraph/src/ParagraphImpl.cpp +++ b/modules/skparagraph/src/ParagraphImpl.cpp @@ -7,7 +7,7 @@ #include "include/core/SkCanvas.h" #include "include/core/SkFontMgr.h" #include "include/core/SkPictureRecorder.h" -#include "modules/skparagraph/src/FontIterator.h" +#include "modules/skparagraph/src/Iterators.h" #include "modules/skparagraph/src/Run.h" #include "modules/skparagraph/src/TextWrapper.h" #include "src/core/SkSpan.h" @@ -85,6 +85,24 @@ private: namespace skia { namespace textlayout { +ParagraphImpl::ParagraphImpl(const SkString& text, + ParagraphStyle style, + std::vector blocks, + sk_sp fonts) + : Paragraph(std::move(style), std::move(fonts)) + , fText(text) + , fTextSpan(fText.c_str(), fText.size()) + , fDirtyLayout(true) + , fOldWidth(0) + , fPicture(nullptr) { + fTextStyles.reserve(blocks.size()); + for (auto& block : blocks) { + fTextStyles.emplace_back( + SkSpan(fTextSpan.begin() + block.fStart, block.fEnd - block.fStart), + block.fStyle); + } +} + ParagraphImpl::ParagraphImpl(const std::u16string& utf16text, ParagraphStyle style, std::vector blocks, @@ -124,11 +142,10 @@ void ParagraphImpl::layout(SkScalar width) { if (fRuns.empty()) { fClusters.reset(); + if (!this->shapeTextIntoEndlessLine()) { // Apply the last style to the empty text - FontIterator font(SkMakeSpan(" "), - SkSpan(&fTextStyles.back(), 1), - fFontCollection); + FontIterator font(SkMakeSpan(" "), &fFontResolver); // Get the font metrics font.consume(); LineMetrics lineMetrics(font.currentFont()); @@ -311,7 +328,7 @@ bool ParagraphImpl::shapeTextIntoEndlessLine() { TRACE_EVENT0("skia", TRACE_FUNC); auto& run = fParagraph->fRuns.emplace_back(fParagraph->text(), info, - fFontIterator->lineHeight(), + fFontIterator->currentLineHeight(), fParagraph->fRuns.count(), fAdvance.fX); return run.newRunBuffer(); @@ -340,8 +357,11 @@ bool ParagraphImpl::shapeTextIntoEndlessLine() { return false; } - SkSpan styles(fTextStyles.begin(), fTextStyles.size()); - FontIterator font(fTextSpan, styles, fFontCollection); + // This is a pretty big step - resolving all characters against all given fonts + fFontResolver.findAllFontsForAllStyledBlocks(fTextSpan, styles(), fFontCollection); + + LangIterator lang(fTextSpan, styles(), paragraphStyle().getTextStyle()); + FontIterator font(fTextSpan, &fFontResolver); ShapeHandler handler(*this, &font); std::unique_ptr shaper = SkShaper::MakeShapeDontWrapOrReorder(); SkASSERT_RELEASE(shaper != nullptr); @@ -352,9 +372,8 @@ bool ParagraphImpl::shapeTextIntoEndlessLine() { return false; } auto script = SkShaper::MakeHbIcuScriptRunIterator(fTextSpan.begin(), fTextSpan.size()); - auto lang = SkShaper::MakeStdLanguageRunIterator(fTextSpan.begin(), fTextSpan.size()); - shaper->shape(fTextSpan.begin(), fTextSpan.size(), font, *bidi, *script, *lang, + shaper->shape(fTextSpan.begin(), fTextSpan.size(), font, *bidi, *script, lang, std::numeric_limits::max(), &handler); return true; } diff --git a/modules/skparagraph/src/ParagraphImpl.h b/modules/skparagraph/src/ParagraphImpl.h index 657920554a..834648b175 100644 --- a/modules/skparagraph/src/ParagraphImpl.h +++ b/modules/skparagraph/src/ParagraphImpl.h @@ -2,6 +2,7 @@ #ifndef ParagraphImpl_DEFINED #define ParagraphImpl_DEFINED +#include "FontResolver.h" #include "include/core/SkPicture.h" #include "include/private/SkTHash.h" #include "modules/skparagraph/include/Paragraph.h" @@ -28,20 +29,7 @@ public: ParagraphImpl(const SkString& text, ParagraphStyle style, std::vector blocks, - sk_sp fonts) - : Paragraph(std::move(style), std::move(fonts)) - , fText(text) - , fTextSpan(fText.c_str(), fText.size()) - , fDirtyLayout(true) - , fOldWidth(0) - , fPicture(nullptr) { - fTextStyles.reserve(blocks.size()); - for (auto& block : blocks) { - fTextStyles.emplace_back( - SkSpan(fTextSpan.begin() + block.fStart, block.fEnd - block.fStart), - block.fStyle); - } - } + sk_sp fonts); ParagraphImpl(const std::u16string& utf16text, ParagraphStyle style, @@ -107,6 +95,7 @@ private: SkTArray fClusters; SkTArray fLines; LineMetrics fStrutMetrics; + FontResolver fFontResolver; bool fDirtyLayout; SkScalar fOldWidth; diff --git a/modules/skparagraph/src/TextStyle.cpp b/modules/skparagraph/src/TextStyle.cpp index 85a387b150..204df8fd37 100644 --- a/modules/skparagraph/src/TextStyle.cpp +++ b/modules/skparagraph/src/TextStyle.cpp @@ -23,6 +23,7 @@ TextStyle::TextStyle() : fFontStyle() { fHasBackground = false; fHasForeground = false; fTextBaseline = TextBaseline::kAlphabetic; + fLocale = ""; } bool TextStyle::equals(const TextStyle& other) const { diff --git a/samplecode/SampleParagraph.cpp b/samplecode/SampleParagraph.cpp index 109507dd3e..aae635db79 100644 --- a/samplecode/SampleParagraph.cpp +++ b/samplecode/SampleParagraph.cpp @@ -1220,7 +1220,6 @@ protected: void onDrawContent(SkCanvas* canvas) override { canvas->drawColor(SK_ColorWHITE); -/* const char* text = "// Create a raised button.\n" "RaisedButton(\n" @@ -1254,7 +1253,7 @@ protected: TextStyle text_style; text_style.setFontFamilies({}); text_style.setColor(SK_ColorBLACK); - text_style.setFontSize(20); + text_style.setFontSize(50); builder.pushStyle(text_style); builder.addText(text); builder.pop(); @@ -1268,31 +1267,7 @@ protected: paint.setColor(SK_ColorLTGRAY); canvas->drawRect(result[0].rect, paint); paragraph->paint(canvas, 0, 0); - */ - std::vector text; - for (uint16_t i = 0; i < 64; ++i) { - text.push_back(i % 5 == 0 ? ' ' : i); - } - std::u16string u16_text(text.data(), text.data() + text.size()); - TextStyle default_style; - default_style.setFontFamilies({SkString("Roboto")}); - ParagraphStyle paragraph_style; - paragraph_style.setTextStyle(default_style); - TextStyle text_style; - text_style.setFontFamilies({SkString("Roboto")}); - text_style.setColor(SK_ColorBLACK); - auto fontCollection = sk_make_sp(GetResourcePath("fonts").c_str()); - SkASSERT(fontCollection->fontsFound() != 0); - ParagraphBuilderImpl builder(paragraph_style, fontCollection); - builder.pushStyle(text_style); - builder.addText(u16_text); - builder.pop(); - auto paragraph = builder.Build(); - size_t count = 10; - while (--count > 0) { - paragraph->layout(300); - paragraph->paint(canvas, 0, 0); - } + } private: