From fb747e2c745896dd94425ff690483ae3838e88fe Mon Sep 17 00:00:00 2001 From: halcanary Date: Fri, 11 Jul 2014 19:45:23 -0700 Subject: [PATCH] Make SkPDFFont::fFontInfo a const pointer. BUG=skia:2742 R=djsollen@google.com, scroggo@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/383063007 --- src/pdf/SkPDFFont.cpp | 22 ++++++++++++---------- src/pdf/SkPDFFont.h | 10 +++++----- src/pdf/SkPDFFontImpl.h | 9 +++++---- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index aa4b4b5..5779431 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -831,7 +831,7 @@ SkPDFFont* SkPDFFont::GetFontResource(SkTypeface* typeface, uint16_t glyphID) { return CanonicalFonts()[relatedFontIndex].fFont; } - SkAutoTUnref fontMetrics; + SkAutoTUnref fontMetrics; SkPDFDict* relatedFontDescriptor = NULL; if (relatedFontIndex >= 0) { SkPDFFont* relatedFont = CanonicalFonts()[relatedFontIndex].fFont; @@ -911,7 +911,8 @@ bool SkPDFFont::Find(uint32_t fontID, uint16_t glyphID, int* index) { return false; } -SkPDFFont::SkPDFFont(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, +SkPDFFont::SkPDFFont(const SkAdvancedTypefaceMetrics* info, + SkTypeface* typeface, SkPDFDict* relatedFontDescriptor) : SkPDFDict("Font"), fTypeface(ref_or_default(typeface)), @@ -928,7 +929,7 @@ SkPDFFont::SkPDFFont(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, } // static -SkPDFFont* SkPDFFont::Create(SkAdvancedTypefaceMetrics* info, +SkPDFFont* SkPDFFont::Create(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID, SkPDFDict* relatedFontDescriptor) { SkAdvancedTypefaceMetrics::FontType type = @@ -959,11 +960,11 @@ SkPDFFont* SkPDFFont::Create(SkAdvancedTypefaceMetrics* info, return new SkPDFType3Font(info, typeface, glyphID); } -SkAdvancedTypefaceMetrics* SkPDFFont::fontInfo() { +const SkAdvancedTypefaceMetrics* SkPDFFont::fontInfo() { return fFontInfo.get(); } -void SkPDFFont::setFontInfo(SkAdvancedTypefaceMetrics* info) { +void SkPDFFont::setFontInfo(const SkAdvancedTypefaceMetrics* info) { if (info == NULL || info == fFontInfo.get()) { return; } @@ -1013,6 +1014,7 @@ bool SkPDFFont::addCommonFontDescriptorEntries(int16_t defaultWidth) { scaleFromFontUnits(fFontInfo->fDescent, emSize)); fDescriptor->insertScalar("StemV", scaleFromFontUnits(fFontInfo->fStemV, emSize)); + fDescriptor->insertScalar("CapHeight", scaleFromFontUnits(fFontInfo->fCapHeight, emSize)); fDescriptor->insertInt("ItalicAngle", fFontInfo->fItalicAngle); @@ -1078,7 +1080,7 @@ void SkPDFFont::populateToUnicodeTable(const SkPDFGlyphSet* subset) { // class SkPDFType0Font /////////////////////////////////////////////////////////////////////////////// -SkPDFType0Font::SkPDFType0Font(SkAdvancedTypefaceMetrics* info, +SkPDFType0Font::SkPDFType0Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface) : SkPDFFont(info, typeface, NULL) { SkDEBUGCODE(fPopulated = false); @@ -1128,7 +1130,7 @@ bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) { // class SkPDFCIDFont /////////////////////////////////////////////////////////////////////////////// -SkPDFCIDFont::SkPDFCIDFont(SkAdvancedTypefaceMetrics* info, +SkPDFCIDFont::SkPDFCIDFont(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, const SkPDFGlyphSet* subset) : SkPDFFont(info, typeface, NULL) { populate(subset); @@ -1218,7 +1220,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); uint32_t* glyphs = (glyphIDs.count() == 0) ? NULL : glyphIDs.begin(); uint32_t glyphsCount = glyphs ? glyphIDs.count() : 0; - SkAutoTUnref fontMetrics( + SkAutoTUnref fontMetrics( typeface()->getAdvancedTypefaceMetrics(info, glyphs, glyphsCount)); setFontInfo(fontMetrics.get()); addFontDescriptor(0, &glyphIDs); @@ -1284,7 +1286,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { // class SkPDFType1Font /////////////////////////////////////////////////////////////////////////////// -SkPDFType1Font::SkPDFType1Font(SkAdvancedTypefaceMetrics* info, +SkPDFType1Font::SkPDFType1Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID, SkPDFDict* relatedFontDescriptor) @@ -1414,7 +1416,7 @@ void SkPDFType1Font::addWidthInfoFromRange( // class SkPDFType3Font /////////////////////////////////////////////////////////////////////////////// -SkPDFType3Font::SkPDFType3Font(SkAdvancedTypefaceMetrics* info, +SkPDFType3Font::SkPDFType3Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID) : SkPDFFont(info, typeface, NULL) { diff --git a/src/pdf/SkPDFFont.h b/src/pdf/SkPDFFont.h index 058a042..48d9c30 100644 --- a/src/pdf/SkPDFFont.h +++ b/src/pdf/SkPDFFont.h @@ -141,12 +141,12 @@ public: protected: // Common constructor to handle common members. - SkPDFFont(SkAdvancedTypefaceMetrics* fontInfo, SkTypeface* typeface, + SkPDFFont(const SkAdvancedTypefaceMetrics* fontInfo, SkTypeface* typeface, SkPDFDict* relatedFontDescriptor); // Accessors for subclass. - SkAdvancedTypefaceMetrics* fontInfo(); - void setFontInfo(SkAdvancedTypefaceMetrics* info); + const SkAdvancedTypefaceMetrics* fontInfo(); + void setFontInfo(const SkAdvancedTypefaceMetrics* info); uint16_t firstGlyphID() const; uint16_t lastGlyphID() const; void setLastGlyphID(uint16_t glyphID); @@ -171,7 +171,7 @@ protected: void populateToUnicodeTable(const SkPDFGlyphSet* subset); // Create instances of derived types based on fontInfo. - static SkPDFFont* Create(SkAdvancedTypefaceMetrics* fontInfo, + static SkPDFFont* Create(const SkAdvancedTypefaceMetrics* fontInfo, SkTypeface* typeface, uint16_t glyphID, SkPDFDict* relatedFontDescriptor); @@ -195,7 +195,7 @@ private: // this will be a subset if the font has more than 255 glyphs. uint16_t fFirstGlyphID; uint16_t fLastGlyphID; - SkAutoTUnref fFontInfo; + SkAutoTUnref fFontInfo; SkTDArray fResources; SkAutoTUnref fDescriptor; diff --git a/src/pdf/SkPDFFontImpl.h b/src/pdf/SkPDFFontImpl.h index 4b49683..99f1941 100644 --- a/src/pdf/SkPDFFontImpl.h +++ b/src/pdf/SkPDFFontImpl.h @@ -29,7 +29,7 @@ private: typedef SkPDFDict INHERITED; #endif - SkPDFType0Font(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface); + SkPDFType0Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface); bool populate(const SkPDFGlyphSet* subset); }; @@ -42,7 +42,7 @@ public: private: friend class SkPDFType0Font; // to access the constructor - SkPDFCIDFont(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, + SkPDFCIDFont(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, const SkPDFGlyphSet* subset); bool populate(const SkPDFGlyphSet* subset); @@ -58,7 +58,7 @@ public: private: friend class SkPDFFont; // to access the constructor - SkPDFType1Font(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, + SkPDFType1Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID, SkPDFDict* relatedFontDescriptor); bool populate(int16_t glyphID); @@ -75,7 +75,8 @@ public: private: friend class SkPDFFont; // to access the constructor - SkPDFType3Font(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID); + SkPDFType3Font(const SkAdvancedTypefaceMetrics* info, + SkTypeface* typeface, uint16_t glyphID); bool populate(int16_t glyphID); }; -- 2.7.4