From 39a9a5069b25aa8b9529118cfd0ece5f412fb56b Mon Sep 17 00:00:00 2001 From: reed Date: Tue, 12 May 2015 09:50:04 -0700 Subject: Make SkAdvancedTypefaceMetrics private. Review URL: https://codereview.chromium.org/1129283003 --- include/core/SkAdvancedTypefaceMetrics.h | 162 ------------------------------- include/core/SkTypeface.h | 17 +++- 2 files changed, 14 insertions(+), 165 deletions(-) delete mode 100644 include/core/SkAdvancedTypefaceMetrics.h (limited to 'include/core') diff --git a/include/core/SkAdvancedTypefaceMetrics.h b/include/core/SkAdvancedTypefaceMetrics.h deleted file mode 100644 index 06757c0c17..0000000000 --- a/include/core/SkAdvancedTypefaceMetrics.h +++ /dev/null @@ -1,162 +0,0 @@ - -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - -#ifndef SkAdvancedTypefaceMetrics_DEFINED -#define SkAdvancedTypefaceMetrics_DEFINED - -#include "SkRect.h" -#include "SkRefCnt.h" -#include "SkString.h" -#include "SkTDArray.h" -#include "SkTemplates.h" - -/** \class SkAdvancedTypefaceMetrics - - The SkAdvancedTypefaceMetrics class is used by the PDF backend to correctly - embed typefaces. This class is created and filled in with information by - SkTypeface::getAdvancedTypefaceMetrics. -*/ - -class SkAdvancedTypefaceMetrics : public SkRefCnt { -public: - SK_DECLARE_INST_COUNT(SkAdvancedTypefaceMetrics) - - SkString fFontName; - - enum FontType { - kType1_Font, - kType1CID_Font, - kCFF_Font, - kTrueType_Font, - kOther_Font, - }; - // The type of the underlying font program. This field determines which - // of the following fields are valid. If it is kOther_Font the per glyph - // information will never be populated. - FontType fType; - - enum FontFlags { - kEmpty_FontFlag = 0x0, //! - struct AdvanceMetric { - enum MetricType { - kDefault, // Default advance: fAdvance.count = 1 - kRange, // Advances for a range: fAdvance.count = fEndID-fStartID - kRun // fStartID-fEndID have same advance: fAdvance.count = 1 - }; - MetricType fType; - uint16_t fStartId; - uint16_t fEndId; - SkTDArray fAdvance; - SkAutoTDelete > fNext; - }; - - struct VerticalMetric { - int16_t fVerticalAdvance; - int16_t fOriginXDisp; // Horiz. displacement of the secondary origin. - int16_t fOriginYDisp; // Vert. displacement of the secondary origin. - }; - typedef AdvanceMetric WidthRange; - typedef AdvanceMetric VerticalAdvanceRange; - - // This is indexed by glyph id. - SkAutoTDelete fGlyphWidths; - // Only used for Vertical CID fonts. - SkAutoTDelete fVerticalMetrics; - - // The names of each glyph, only populated for postscript fonts. - SkAutoTDelete > fGlyphNames; - - // The mapping from glyph to Unicode, only populated if - // kToUnicode_PerGlyphInfo is passed to GetAdvancedTypefaceMetrics. - SkTDArray fGlyphToUnicode; - -private: - typedef SkRefCnt INHERITED; -}; - -namespace skia_advanced_typeface_metrics_utils { - -template -void resetRange(SkAdvancedTypefaceMetrics::AdvanceMetric* range, - int startId); - -template -SkAdvancedTypefaceMetrics::AdvanceMetric* appendRange( - SkAutoTDelete >* nextSlot, - int startId); - -template -void finishRange( - SkAdvancedTypefaceMetrics::AdvanceMetric* range, - int endId, - typename SkAdvancedTypefaceMetrics::AdvanceMetric::MetricType - type); - -/** Retrieve advance data for glyphs. Used by the PDF backend. It calls - underlying platform dependent API getAdvance to acquire the data. - @param num_glyphs Total number of glyphs in the given font. - @param glyphIDs For per-glyph info, specify subset of the font by - giving glyph ids. Each integer represents a glyph - id. Passing NULL means all glyphs in the font. - @param glyphIDsCount Number of elements in subsetGlyphIds. Ignored if - glyphIDs is NULL. -*/ -template -SkAdvancedTypefaceMetrics::AdvanceMetric* getAdvanceData( - FontHandle fontHandle, - int num_glyphs, - const uint32_t* glyphIDs, - uint32_t glyphIDsCount, - bool (*getAdvance)(FontHandle fontHandle, int gId, Data* data)); - -} // namespace skia_advanced_typeface_metrics_utils - -#endif diff --git a/include/core/SkTypeface.h b/include/core/SkTypeface.h index 6a6d7241a2..7d8b892f2c 100644 --- a/include/core/SkTypeface.h +++ b/include/core/SkTypeface.h @@ -10,9 +10,10 @@ #ifndef SkTypeface_DEFINED #define SkTypeface_DEFINED -#include "SkAdvancedTypefaceMetrics.h" #include "SkFontStyle.h" #include "SkLazyPtr.h" +#include "SkRect.h" +#include "SkString.h" #include "SkWeakRefCnt.h" class SkDescriptor; @@ -307,6 +308,16 @@ public: } protected: + // The type of advance data wanted. + enum PerGlyphInfo { + kNo_PerGlyphInfo = 0x0, // Don't populate any per glyph info. + kHAdvance_PerGlyphInfo = 0x1, // Populate horizontal advance data. + kVAdvance_PerGlyphInfo = 0x2, // Populate vertical advance data. + kGlyphNames_PerGlyphInfo = 0x4, // Populate glyph names (Type 1 only). + kToUnicode_PerGlyphInfo = 0x8 // Populate ToUnicode table, ignored + // for Type 1 fonts + }; + /** uniqueID must be unique and non-zero */ SkTypeface(const SkFontStyle& style, SkFontID uniqueID, bool isFixedPitch = false); @@ -321,7 +332,7 @@ protected: virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) const = 0; virtual void onFilterRec(SkScalerContextRec*) const = 0; virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( - SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, + PerGlyphInfo, const uint32_t* glyphIDs, uint32_t glyphIDsCount) const = 0; @@ -368,7 +379,7 @@ private: @return The returned object has already been referenced. */ SkAdvancedTypefaceMetrics* getAdvancedTypefaceMetrics( - SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, + PerGlyphInfo, const uint32_t* glyphIDs = NULL, uint32_t glyphIDsCount = 0) const; -- cgit v1.2.3