aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/fonts
diff options
context:
space:
mode:
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, 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 {