aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFFont.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-05-09 15:35:54 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-09 15:36:06 +0000
commit97c1108607584b6050a6880d6ce22846e4913a92 (patch)
treee6cb5bfa22fdd2fba53c9cd49d3beed28fff686b /src/pdf/SkPDFFont.cpp
parent2ed5f69da6f101e60a3cf49c0767212b563552f3 (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 'src/pdf/SkPDFFont.cpp')
-rw-r--r--src/pdf/SkPDFFont.cpp47
1 files changed, 16 insertions, 31 deletions
diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp
index 3b89f62cbe..9ba411495a 100644
--- a/src/pdf/SkPDFFont.cpp
+++ b/src/pdf/SkPDFFont.cpp
@@ -186,19 +186,6 @@ const SkAdvancedTypefaceMetrics* SkPDFFont::GetMetrics(SkTypeface* typeface,
return canon->fTypefaceMetrics.set(id, std::move(metrics))->get();
}
-const std::vector<SkUnichar>& SkPDFFont::GetUnicodeMap(const SkTypeface* typeface,
- SkPDFCanon* canon) {
- SkASSERT(typeface);
- SkASSERT(canon);
- SkFontID id = typeface->uniqueID();
- if (std::vector<SkUnichar>* ptr = canon->fToUnicodeMap.find(id)) {
- return *ptr;
- }
- std::vector<SkUnichar> buffer(typeface->countGlyphs());
- typeface->getGlyphToUnicodeMap(buffer.data());
- return *canon->fToUnicodeMap.set(id, std::move(buffer));
-}
-
SkAdvancedTypefaceMetrics::FontType SkPDFFont::FontType(const SkAdvancedTypefaceMetrics& metrics) {
if (SkToBool(metrics.fFlags & SkAdvancedTypefaceMetrics::kMultiMaster_FontFlag) ||
SkToBool(metrics.fFlags & SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag)) {
@@ -490,15 +477,14 @@ void SkPDFType0Font::getFontSubset(SkPDFCanon* canon) {
descendantFonts->appendObjRef(std::move(newCIDFont));
this->insertObject("DescendantFonts", std::move(descendantFonts));
- const std::vector<SkUnichar>& glyphToUnicode =
- SkPDFFont::GetUnicodeMap(this->typeface(), canon);
- SkASSERT(SkToSizeT(this->typeface()->countGlyphs()) == glyphToUnicode.size());
- this->insertObjRef("ToUnicode",
- SkPDFMakeToUnicodeCmap(glyphToUnicode.data(),
- &this->glyphUsage(),
- this->multiByteGlyphs(),
- this->firstGlyphID(),
- this->lastGlyphID()));
+ if (metrics.fGlyphToUnicode.count() > 0) {
+ this->insertObjRef("ToUnicode",
+ SkPDFMakeToUnicodeCmap(metrics.fGlyphToUnicode,
+ &this->glyphUsage(),
+ multiByteGlyphs(),
+ firstGlyphID(),
+ lastGlyphID()));
+ }
SkDEBUGCODE(fPopulated = true);
return;
}
@@ -736,15 +722,14 @@ static void add_type3_font_info(SkPDFCanon* canon,
fontBBox->appendInt(bbox.top());
font->insertObject("FontBBox", std::move(fontBBox));
font->insertName("CIDToGIDMap", "Identity");
-
- const std::vector<SkUnichar>& glyphToUnicode = SkPDFFont::GetUnicodeMap(typeface, canon);
- SkASSERT(glyphToUnicode.size() == SkToSizeT(typeface->countGlyphs()));
- font->insertObjRef("ToUnicode",
- SkPDFMakeToUnicodeCmap(glyphToUnicode.data(),
- &subset,
- false,
- firstGlyphID,
- lastGlyphID));
+ if (metrics && metrics->fGlyphToUnicode.count() > 0) {
+ font->insertObjRef("ToUnicode",
+ SkPDFMakeToUnicodeCmap(metrics->fGlyphToUnicode,
+ &subset,
+ false,
+ firstGlyphID,
+ lastGlyphID));
+ }
auto descriptor = sk_make_sp<SkPDFDict>("FontDescriptor");
int32_t fontDescriptorFlags = kPdfSymbolic;
if (metrics) {