From 97c1108607584b6050a6880d6ce22846e4913a92 Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Wed, 9 May 2018 15:35:54 +0000 Subject: Revert "SkAdvancedTypefaceMetrics: factor out GlyphToUnicode" This reverts commit 1c2bcd8b14e029a70e88b1e81acd29553cab0d1c. Reason for revert: breaking chrome roll Original change's description: > SkAdvancedTypefaceMetrics: factor out GlyphToUnicode > > Change-Id: Iedce8c1ea2c405d5ab64ccac353970d5cd2b9d63 > Reviewed-on: https://skia-review.googlesource.com/126507 > Commit-Queue: Hal Canary > Reviewed-by: Ben Wagner TBR=halcanary@google.com,bungeman@google.com,reed@google.com Change-Id: Ib1ff8484ffd09cdb88d461ac00745aa32c191124 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/127000 Reviewed-by: Greg Daniel Commit-Queue: Greg Daniel --- tools/fonts/SkRandomScalerContext.cpp | 4 ---- tools/fonts/SkRandomScalerContext.h | 1 - tools/fonts/SkTestSVGTypeface.cpp | 16 +++++++--------- tools/fonts/SkTestSVGTypeface.h | 1 - tools/fonts/SkTestTypeface.cpp | 15 ++++++++------- tools/fonts/SkTestTypeface.h | 1 - 6 files changed, 15 insertions(+), 23 deletions(-) (limited to 'tools/fonts') diff --git a/tools/fonts/SkRandomScalerContext.cpp b/tools/fonts/SkRandomScalerContext.cpp index 9379759ff0..2d472129a1 100644 --- a/tools/fonts/SkRandomScalerContext.cpp +++ b/tools/fonts/SkRandomScalerContext.cpp @@ -164,10 +164,6 @@ void SkRandomTypeface::onFilterRec(SkScalerContextRec* rec) const { rec->fMaskFormat = SkMask::kARGB32_Format; } -void SkRandomTypeface::getGlyphToUnicodeMap(SkUnichar* glyphToUnicode) const { - fProxy->getGlyphToUnicodeMap(glyphToUnicode); -} - std::unique_ptr SkRandomTypeface::onGetAdvancedMetrics() const { return fProxy->getAdvancedMetrics(); } diff --git a/tools/fonts/SkRandomScalerContext.h b/tools/fonts/SkRandomScalerContext.h index 5dbdac68b8..b71689d9e2 100644 --- a/tools/fonts/SkRandomScalerContext.h +++ b/tools/fonts/SkRandomScalerContext.h @@ -27,7 +27,6 @@ protected: SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, const SkDescriptor*) const override; void onFilterRec(SkScalerContextRec*) const override; - void getGlyphToUnicodeMap(SkUnichar*) const override; std::unique_ptr onGetAdvancedMetrics() const override; SkStreamAsset* onOpenStream(int* ttcIndex) const override; void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const override; diff --git a/tools/fonts/SkTestSVGTypeface.cpp b/tools/fonts/SkTestSVGTypeface.cpp index 199c3b5df6..ceb523aa72 100644 --- a/tools/fonts/SkTestSVGTypeface.cpp +++ b/tools/fonts/SkTestSVGTypeface.cpp @@ -100,17 +100,15 @@ void SkTestSVGTypeface::onFilterRec(SkScalerContextRec* rec) const { rec->setHinting(SkPaint::kNo_Hinting); } -void SkTestSVGTypeface::getGlyphToUnicodeMap(SkUnichar* glyphToUnicode) const { - SkDEBUGCODE(unsigned glyphCount = this->countGlyphs()); - fCMap.foreach([=](const SkUnichar& c, const SkGlyphID& g) { - SkASSERT(g < glyphCount); - glyphToUnicode[g] = c; - }); -} - std::unique_ptr SkTestSVGTypeface::onGetAdvancedMetrics() const { std::unique_ptr info(new SkAdvancedTypefaceMetrics); - info->fFontName = fName; + info->fFontName.set(fName); + + SkTDArray& toUnicode = info->fGlyphToUnicode; + toUnicode.setCount(fGlyphCount); + fCMap.foreach([&toUnicode](const SkUnichar& c, const SkGlyphID& g) { + toUnicode[g] = c; + }); return info; } diff --git a/tools/fonts/SkTestSVGTypeface.h b/tools/fonts/SkTestSVGTypeface.h index 249cd8bfc1..0b53245b70 100644 --- a/tools/fonts/SkTestSVGTypeface.h +++ b/tools/fonts/SkTestSVGTypeface.h @@ -77,7 +77,6 @@ protected: SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, const SkDescriptor* desc) const override; void onFilterRec(SkScalerContextRec* rec) const override; - void getGlyphToUnicodeMap(SkUnichar*) const override; std::unique_ptr onGetAdvancedMetrics() const override; SkStreamAsset* onOpenStream(int* ttcIndex) const override { diff --git a/tools/fonts/SkTestTypeface.cpp b/tools/fonts/SkTestTypeface.cpp index bf3a1a3e9e..d7caa5a392 100644 --- a/tools/fonts/SkTestTypeface.cpp +++ b/tools/fonts/SkTestTypeface.cpp @@ -119,16 +119,17 @@ void SkTestTypeface::onFilterRec(SkScalerContextRec* rec) const { rec->setHinting(SkPaint::kNo_Hinting); } -void SkTestTypeface::getGlyphToUnicodeMap(SkUnichar* glyphToUnicode) const { - unsigned glyphCount = fTestFont->fCharCodesCount; - for (unsigned gid = 0; gid < glyphCount; ++gid) { - glyphToUnicode[gid] = SkTo(fTestFont->fCharCodes[gid]); - } -} - std::unique_ptr SkTestTypeface::onGetAdvancedMetrics() const { // pdf only std::unique_ptr info(new SkAdvancedTypefaceMetrics); info->fFontName.set(fTestFont->fName); + int glyphCount = this->onCountGlyphs(); + + SkTDArray& toUnicode = info->fGlyphToUnicode; + toUnicode.setCount(glyphCount); + SkASSERT(glyphCount == SkToInt(fTestFont->fCharCodesCount)); + for (int gid = 0; gid < glyphCount; ++gid) { + toUnicode[gid] = SkToS32(fTestFont->fCharCodes[gid]); + } return info; } diff --git a/tools/fonts/SkTestTypeface.h b/tools/fonts/SkTestTypeface.h index 205d82c30f..d3365f972a 100644 --- a/tools/fonts/SkTestTypeface.h +++ b/tools/fonts/SkTestTypeface.h @@ -71,7 +71,6 @@ protected: SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, const SkDescriptor* desc) const override; void onFilterRec(SkScalerContextRec* rec) const override; - void getGlyphToUnicodeMap(SkUnichar* glyphToUnicode) const override; std::unique_ptr onGetAdvancedMetrics() const override; SkStreamAsset* onOpenStream(int* ttcIndex) const override { -- cgit v1.2.3