Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #ifndef SkPDFFont_DEFINED | 9 #ifndef SkPDFFont_DEFINED |
| 10 #define SkPDFFont_DEFINED | 10 #define SkPDFFont_DEFINED |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 reference to each instantiated class. | 68 reference to each instantiated class. |
| 69 */ | 69 */ |
| 70 class SkPDFFont : public SkPDFDict { | 70 class SkPDFFont : public SkPDFDict { |
| 71 | 71 |
| 72 public: | 72 public: |
| 73 virtual ~SkPDFFont(); | 73 virtual ~SkPDFFont(); |
| 74 | 74 |
| 75 /** Returns the typeface represented by this class. Returns nullptr for the | 75 /** Returns the typeface represented by this class. Returns nullptr for the |
| 76 * default typeface. | 76 * default typeface. |
| 77 */ | 77 */ |
| 78 SkTypeface* typeface(); | 78 SkTypeface* typeface() { return fTypeface.get(); } |
| 79 | 79 |
| 80 /** Returns the font type represented in this font. For Type0 fonts, | 80 /** Returns the font type represented in this font. For Type0 fonts, |
| 81 * returns the type of the decendant font. | 81 * returns the type of the decendant font. |
| 82 */ | 82 */ |
| 83 virtual SkAdvancedTypefaceMetrics::FontType getType(); | 83 SkAdvancedTypefaceMetrics::FontType getType() { return fFontType; } |
| 84 | 84 |
| 85 /** Returns true if this font encoding supports glyph IDs above 255. | 85 /** Returns true if this font encoding supports glyph IDs above 255. |
| 86 */ | 86 */ |
| 87 virtual bool multiByteGlyphs() const = 0; | 87 bool multiByteGlyphs() const { return fMultiByteGlyphs; } |
| 88 | 88 |
| 89 /** Returns true if the machine readable licensing bits allow embedding. | 89 /** Returns true if the machine readable licensing bits allow embedding. |
| 90 */ | 90 */ |
| 91 bool canEmbed() const; | 91 bool canEmbed() const; |
| 92 | 92 |
| 93 /** Returns true if the machine readable licensing bits allow subsetting. | 93 /** Returns true if the machine readable licensing bits allow subsetting. |
| 94 */ | 94 */ |
| 95 bool canSubset() const; | 95 bool canSubset() const; |
| 96 | 96 |
| 97 /** Return true if this font has an encoding for the passed glyph id. | 97 /** Return true if this font has an encoding for the passed glyph id. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 /** | 148 /** |
| 149 * Return false iff the typeface has its NotEmbeddable flag set. | 149 * Return false iff the typeface has its NotEmbeddable flag set. |
| 150 * If typeface is NULL, the default typeface is checked. | 150 * If typeface is NULL, the default typeface is checked. |
| 151 */ | 151 */ |
| 152 static bool CanEmbedTypeface(SkTypeface*, SkPDFCanon*); | 152 static bool CanEmbedTypeface(SkTypeface*, SkPDFCanon*); |
| 153 | 153 |
| 154 protected: | 154 protected: |
| 155 // Common constructor to handle common members. | 155 // Common constructor to handle common members. |
| 156 SkPDFFont(const SkAdvancedTypefaceMetrics* fontInfo, | 156 SkPDFFont(const SkAdvancedTypefaceMetrics* fontInfo, |
| 157 SkTypeface* typeface, | 157 SkTypeface* typeface, |
| 158 SkPDFDict* relatedFontDescriptor); | 158 SkPDFDict* relatedFontDescriptor, |
| 159 SkAdvancedTypefaceMetrics::FontType fontType, | |
| 160 bool multiByteGlyphs); | |
| 159 | 161 |
| 160 // Accessors for subclass. | 162 // Accessors for subclass. |
| 161 const SkAdvancedTypefaceMetrics* fontInfo(); | 163 sk_sp<const SkAdvancedTypefaceMetrics>& fontInfo() { return fFontInfo; } |
|
bungeman-skia
2016/08/15 16:49:58
This is a convoluted and very restraining signatur
hal.canary
2016/08/15 18:05:23
Done.
| |
| 162 void setFontInfo(const SkAdvancedTypefaceMetrics* info); | 164 void setFontInfo(sk_sp<const SkAdvancedTypefaceMetrics> info); |
| 163 uint16_t firstGlyphID() const; | 165 SkGlyphID firstGlyphID() const { return fFirstGlyphID; } |
| 164 uint16_t lastGlyphID() const; | 166 SkGlyphID lastGlyphID() const { return fLastGlyphID; } |
| 165 void setLastGlyphID(uint16_t glyphID); | 167 void setLastGlyphID(uint16_t glyphID); |
| 166 | 168 |
| 167 // Accessors for FontDescriptor associated with this object. | 169 // Accessors for FontDescriptor associated with this object. |
| 168 SkPDFDict* getFontDescriptor(); | 170 const sk_sp<SkPDFDict>& getFontDescriptor() { return fDescriptor; } |
| 169 void setFontDescriptor(SkPDFDict* descriptor); | 171 void setFontDescriptor(sk_sp<SkPDFDict> descriptor); |
| 170 | 172 |
| 171 // Add common entries to FontDescriptor. | 173 // Add common entries to FontDescriptor. |
| 172 bool addCommonFontDescriptorEntries(int16_t defaultWidth); | 174 bool addCommonFontDescriptorEntries(int16_t defaultWidth); |
| 173 | 175 |
| 174 /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs, | 176 /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs, |
| 175 * including the passed glyphID. | 177 * including the passed glyphID. |
| 176 */ | 178 */ |
| 177 void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID); | 179 void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID); |
| 178 | 180 |
| 179 // Generate ToUnicode table according to glyph usage subset. | 181 // Generate ToUnicode table according to glyph usage subset. |
| 180 // If subset is nullptr, all available glyph ids will be used. | 182 // If subset is nullptr, all available glyph ids will be used. |
| 181 void populateToUnicodeTable(const SkPDFGlyphSet* subset); | 183 void populateToUnicodeTable(const SkPDFGlyphSet* subset); |
| 182 | 184 |
| 183 // Create instances of derived types based on fontInfo. | 185 // Create instances of derived types based on fontInfo. |
| 184 static SkPDFFont* Create(SkPDFCanon* canon, | 186 static SkPDFFont* Create(SkPDFCanon* canon, |
| 185 const SkAdvancedTypefaceMetrics* fontInfo, | 187 const SkAdvancedTypefaceMetrics* fontInfo, |
| 186 SkTypeface* typeface, | 188 SkTypeface* typeface, |
| 187 uint16_t glyphID, | 189 uint16_t glyphID, |
| 188 SkPDFDict* relatedFontDescriptor); | 190 SkPDFDict* relatedFontDescriptor); |
| 189 | 191 |
| 190 static bool Find(uint32_t fontID, uint16_t glyphID, int* index); | 192 static bool Find(uint32_t fontID, uint16_t glyphID, int* index); |
| 191 | 193 |
| 192 void drop() override; | 194 void drop() override; |
| 193 | 195 |
| 194 private: | 196 private: |
| 195 sk_sp<SkTypeface> fTypeface; | 197 sk_sp<SkTypeface> fTypeface; |
| 198 sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo; | |
| 199 sk_sp<SkPDFDict> fDescriptor; | |
| 196 | 200 |
| 197 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, | 201 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, |
| 198 // this will be a subset if the font has more than 255 glyphs. | 202 // this will be a subset if the font has more than 255 glyphs. |
| 199 uint16_t fFirstGlyphID; | 203 SkGlyphID fFirstGlyphID; |
| 200 uint16_t fLastGlyphID; | 204 SkGlyphID fLastGlyphID; |
| 201 sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo; | |
| 202 sk_sp<SkPDFDict> fDescriptor; | |
| 203 | |
| 204 SkAdvancedTypefaceMetrics::FontType fFontType; | 205 SkAdvancedTypefaceMetrics::FontType fFontType; |
| 206 bool fMultiByteGlyphs; | |
| 205 | 207 |
| 206 typedef SkPDFDict INHERITED; | 208 typedef SkPDFDict INHERITED; |
| 207 }; | 209 }; |
| 208 | 210 |
| 209 #endif | 211 #endif |
| OLD | NEW |