aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/fonts
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2018-05-09 11:50:34 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-09 18:00:35 +0000
commit46cc3dabaff7daa6b57e3c33997153d986219579 (patch)
tree809ca0d62fddcbd3b378d0a4d330692ebd58748d /tools/fonts
parent06d374694a515d064a26e6c5391bce9a0c5c8aa0 (diff)
Revert "Revert "SkAdvancedTypefaceMetrics: factor out GlyphToUnicode""
This reverts commit 97c1108607584b6050a6880d6ce22846e4913a92. Change-Id: Ic3c6addc64ced39766bbee3e10b4d88faf61ba2f Reviewed-on: https://skia-review.googlesource.com/127021 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'tools/fonts')
-rw-r--r--tools/fonts/SkRandomScalerContext.cpp4
-rw-r--r--tools/fonts/SkRandomScalerContext.h1
-rw-r--r--tools/fonts/SkTestSVGTypeface.cpp16
-rw-r--r--tools/fonts/SkTestSVGTypeface.h1
-rw-r--r--tools/fonts/SkTestTypeface.cpp15
-rw-r--r--tools/fonts/SkTestTypeface.h1
6 files changed, 23 insertions, 15 deletions
diff --git a/tools/fonts/SkRandomScalerContext.cpp b/tools/fonts/SkRandomScalerContext.cpp
index 2d472129a1..9379759ff0 100644
--- a/tools/fonts/SkRandomScalerContext.cpp
+++ b/tools/fonts/SkRandomScalerContext.cpp
@@ -164,6 +164,10 @@ 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 b71689d9e2..5dbdac68b8 100644
--- a/tools/fonts/SkRandomScalerContext.h
+++ b/tools/fonts/SkRandomScalerContext.h
@@ -27,6 +27,7 @@ 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 ceb523aa72..199c3b5df6 100644
--- a/tools/fonts/SkTestSVGTypeface.cpp
+++ b/tools/fonts/SkTestSVGTypeface.cpp
@@ -100,15 +100,17 @@ 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.set(fName);
-
- SkTDArray<SkUnichar>& toUnicode = info->fGlyphToUnicode;
- toUnicode.setCount(fGlyphCount);
- fCMap.foreach([&toUnicode](const SkUnichar& c, const SkGlyphID& g) {
- toUnicode[g] = c;
- });
+ info->fFontName = fName;
return info;
}
diff --git a/tools/fonts/SkTestSVGTypeface.h b/tools/fonts/SkTestSVGTypeface.h
index 0b53245b70..249cd8bfc1 100644
--- a/tools/fonts/SkTestSVGTypeface.h
+++ b/tools/fonts/SkTestSVGTypeface.h
@@ -77,6 +77,7 @@ 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 d7caa5a392..bf3a1a3e9e 100644
--- a/tools/fonts/SkTestTypeface.cpp
+++ b/tools/fonts/SkTestTypeface.cpp
@@ -119,17 +119,16 @@ 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 d3365f972a..205d82c30f 100644
--- a/tools/fonts/SkTestTypeface.h
+++ b/tools/fonts/SkTestTypeface.h
@@ -71,6 +71,7 @@ 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 {