diff options
author | Greg Daniel <egdaniel@google.com> | 2018-05-09 15:35:54 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-09 15:36:06 +0000 |
commit | 97c1108607584b6050a6880d6ce22846e4913a92 (patch) | |
tree | e6cb5bfa22fdd2fba53c9cd49d3beed28fff686b /tools/fonts | |
parent | 2ed5f69da6f101e60a3cf49c0767212b563552f3 (diff) |
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 <halcanary@google.com>
> Reviewed-by: Ben Wagner <bungeman@google.com>
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 <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tools/fonts')
-rw-r--r-- | tools/fonts/SkRandomScalerContext.cpp | 4 | ||||
-rw-r--r-- | tools/fonts/SkRandomScalerContext.h | 1 | ||||
-rw-r--r-- | tools/fonts/SkTestSVGTypeface.cpp | 16 | ||||
-rw-r--r-- | tools/fonts/SkTestSVGTypeface.h | 1 | ||||
-rw-r--r-- | tools/fonts/SkTestTypeface.cpp | 15 | ||||
-rw-r--r-- | tools/fonts/SkTestTypeface.h | 1 |
6 files changed, 15 insertions, 23 deletions
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<SkAdvancedTypefaceMetrics> 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<SkAdvancedTypefaceMetrics> 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<SkAdvancedTypefaceMetrics> SkTestSVGTypeface::onGetAdvancedMetrics() const { std::unique_ptr<SkAdvancedTypefaceMetrics> info(new SkAdvancedTypefaceMetrics); - info->fFontName = fName; + info->fFontName.set(fName); + + SkTDArray<SkUnichar>& 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<SkAdvancedTypefaceMetrics> 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<SkUnichar>(fTestFont->fCharCodes[gid]); - } -} - std::unique_ptr<SkAdvancedTypefaceMetrics> SkTestTypeface::onGetAdvancedMetrics() const { // pdf only std::unique_ptr<SkAdvancedTypefaceMetrics> info(new SkAdvancedTypefaceMetrics); info->fFontName.set(fTestFont->fName); + int glyphCount = this->onCountGlyphs(); + + SkTDArray<SkUnichar>& 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<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override; SkStreamAsset* onOpenStream(int* ttcIndex) const override { |