| Index: src/pdf/SkPDFFont.h
|
| diff --git a/src/pdf/SkPDFFont.h b/src/pdf/SkPDFFont.h
|
| index 36b93ecc352ad6e0668a3568fb0a029b19cb3f27..f2f1df4c244c2102adebfcb20aeccbb90754d888 100644
|
| --- a/src/pdf/SkPDFFont.h
|
| +++ b/src/pdf/SkPDFFont.h
|
| @@ -60,7 +60,6 @@ private:
|
| SkTArray<FontGlyphSetPair> fMap;
|
| };
|
|
|
| -
|
| /** \class SkPDFFont
|
| A PDF Object class representing a font. The font may have resources
|
| attached to it in order to embed the font. SkPDFFonts are canonicalized
|
| @@ -76,28 +75,27 @@ public:
|
| /** Returns the typeface represented by this class. Returns nullptr for the
|
| * default typeface.
|
| */
|
| - SkTypeface* typeface() { return fTypeface.get(); }
|
| + SkTypeface* typeface() const { return fTypeface.get(); }
|
|
|
| /** Returns the font type represented in this font. For Type0 fonts,
|
| * returns the type of the decendant font.
|
| */
|
| - SkAdvancedTypefaceMetrics::FontType getType() { return fFontType; }
|
| -
|
| - /** Returns true if this font encoding supports glyph IDs above 255.
|
| - */
|
| - bool multiByteGlyphs() const { return fMultiByteGlyphs; }
|
| + SkAdvancedTypefaceMetrics::FontType getType() const { return fFontType; }
|
|
|
| - /** Returns true if the machine readable licensing bits allow embedding.
|
| - */
|
| - bool canEmbed() const;
|
| + static bool IsMultiByte(SkAdvancedTypefaceMetrics::FontType type) {
|
| + return type == SkAdvancedTypefaceMetrics::kType1CID_Font ||
|
| + type == SkAdvancedTypefaceMetrics::kTrueType_Font;
|
| + }
|
|
|
| - /** Returns true if the machine readable licensing bits allow subsetting.
|
| + /** Returns true if this font encoding supports glyph IDs above 255.
|
| */
|
| - bool canSubset() const;
|
| + bool multiByteGlyphs() const { return SkPDFFont::IsMultiByte(this->getType()); }
|
|
|
| /** Return true if this font has an encoding for the passed glyph id.
|
| */
|
| - bool hasGlyph(uint16_t glyphID);
|
| + bool hasGlyph(SkGlyphID gid) {
|
| + return (gid >= fFirstGlyphID && gid <= fLastGlyphID) || gid == 0;
|
| + }
|
|
|
| /** Convert (in place) the input glyph IDs into the font encoding. If the
|
| * font has more glyphs than can be encoded (like a type 1 font with more
|
| @@ -124,10 +122,11 @@ public:
|
| */
|
| static SkPDFFont* GetFontResource(SkPDFCanon* canon,
|
| SkTypeface* typeface,
|
| - uint16_t glyphID);
|
| + SkGlyphID glyphID);
|
|
|
| - static sk_sp<const SkAdvancedTypefaceMetrics> GetFontMetricsWithToUnicode(
|
| - SkTypeface*, uint32_t* glyphs, uint32_t glyphsCount);
|
| + // Uses (kGlyphNames_PerGlyphInfo | kToUnicode_PerGlyphInfo).
|
| + static const SkAdvancedTypefaceMetrics* GetMetrics(SkTypeface* typeface,
|
| + SkPDFCanon* canon);
|
|
|
| /** Subset the font based on usage set. Returns a SkPDFFont instance with
|
| * subset.
|
| @@ -135,18 +134,8 @@ public:
|
| * @return nullptr if font does not support subsetting, a new instance
|
| * of SkPDFFont otherwise.
|
| */
|
| - virtual sk_sp<SkPDFObject> getFontSubset(const SkPDFGlyphSet* usage);
|
| -
|
| - enum Match {
|
| - kExact_Match,
|
| - kRelated_Match,
|
| - kNot_Match,
|
| - };
|
| - static Match IsMatch(SkPDFFont* existingFont,
|
| - uint32_t existingFontID,
|
| - uint16_t existingGlyphID,
|
| - uint32_t searchFontID,
|
| - uint16_t searchGlyphID);
|
| + virtual sk_sp<SkPDFObject> getFontSubset(SkPDFCanon* canon,
|
| + const SkPDFGlyphSet* usage);
|
|
|
| /**
|
| * Return false iff the typeface has its NotEmbeddable flag set.
|
| @@ -156,52 +145,29 @@ public:
|
|
|
| protected:
|
| // Common constructor to handle common members.
|
| - SkPDFFont(sk_sp<const SkAdvancedTypefaceMetrics> fontInfo,
|
| - sk_sp<SkTypeface> typeface,
|
| - sk_sp<SkPDFDict> relatedFontDescriptor,
|
| - SkAdvancedTypefaceMetrics::FontType fontType,
|
| - bool multiByteGlyphs);
|
| -
|
| - // Accessors for subclass.
|
| - const SkAdvancedTypefaceMetrics* getFontInfo() const { return fFontInfo.get(); }
|
| - sk_sp<const SkAdvancedTypefaceMetrics> refFontInfo() const { return fFontInfo; }
|
| + SkPDFFont(sk_sp<SkTypeface> typeface,
|
| + SkAdvancedTypefaceMetrics::FontType fontType);
|
|
|
| - void setFontInfo(sk_sp<const SkAdvancedTypefaceMetrics> info);
|
| SkGlyphID firstGlyphID() const { return fFirstGlyphID; }
|
| SkGlyphID lastGlyphID() const { return fLastGlyphID; }
|
| - void setLastGlyphID(uint16_t glyphID);
|
| -
|
| - // Accessors for FontDescriptor associated with this object.
|
| - SkPDFDict* getFontDescriptor() const { return fDescriptor.get(); }
|
| - sk_sp<SkPDFDict> refFontDescriptor() const { return fDescriptor; }
|
| - void setFontDescriptor(sk_sp<SkPDFDict> descriptor);
|
|
|
| sk_sp<SkTypeface> refTypeface() const { return fTypeface; }
|
|
|
| /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs,
|
| * including the passed glyphID.
|
| */
|
| - void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID);
|
| -
|
| - // Generate ToUnicode table according to glyph usage subset.
|
| - // If subset is nullptr, all available glyph ids will be used.
|
| - void populateToUnicodeTable(const SkPDFGlyphSet* subset);
|
| -
|
| - static bool Find(uint32_t fontID, uint16_t glyphID, int* index);
|
| + void adjustGlyphRangeForSingleByteEncoding(SkGlyphID glyphID);
|
|
|
| void drop() override;
|
|
|
| private:
|
| sk_sp<SkTypeface> fTypeface;
|
| - sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo;
|
| - sk_sp<SkPDFDict> fDescriptor;
|
|
|
| // The glyph IDs accessible with this font. For Type1 (non CID) fonts,
|
| // this will be a subset if the font has more than 255 glyphs.
|
| SkGlyphID fFirstGlyphID;
|
| SkGlyphID fLastGlyphID;
|
| SkAdvancedTypefaceMetrics::FontType fFontType;
|
| - bool fMultiByteGlyphs;
|
|
|
| typedef SkPDFDict INHERITED;
|
| };
|
|
|