| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkPDFFont_DEFINED | 10 #ifndef SkPDFFont_DEFINED |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 attached to it in order to embed the font. SkPDFFonts are canonicalized | 75 attached to it in order to embed the font. SkPDFFonts are canonicalized |
| 76 so that resource deduplication will only include one copy of a font. | 76 so that resource deduplication will only include one copy of a font. |
| 77 This class uses the same pattern as SkPDFGraphicState, a static weak | 77 This class uses the same pattern as SkPDFGraphicState, a static weak |
| 78 reference to each instantiated class. | 78 reference to each instantiated class. |
| 79 */ | 79 */ |
| 80 class SkPDFFont : public SkPDFDict { | 80 class SkPDFFont : public SkPDFDict { |
| 81 | 81 |
| 82 public: | 82 public: |
| 83 virtual ~SkPDFFont(); | 83 virtual ~SkPDFFont(); |
| 84 | 84 |
| 85 /** Returns the typeface represented by this class. Returns NULL for the | 85 /** Returns the typeface represented by this class. Returns nullptr for the |
| 86 * default typeface. | 86 * default typeface. |
| 87 */ | 87 */ |
| 88 SkTypeface* typeface(); | 88 SkTypeface* typeface(); |
| 89 | 89 |
| 90 /** Returns the font type represented in this font. For Type0 fonts, | 90 /** Returns the font type represented in this font. For Type0 fonts, |
| 91 * returns the type of the decendant font. | 91 * returns the type of the decendant font. |
| 92 */ | 92 */ |
| 93 virtual SkAdvancedTypefaceMetrics::FontType getType(); | 93 virtual SkAdvancedTypefaceMetrics::FontType getType(); |
| 94 | 94 |
| 95 /** Returns true if this font encoding supports glyph IDs above 255. | 95 /** Returns true if this font encoding supports glyph IDs above 255. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 126 * @param typeface The typeface to find. | 126 * @param typeface The typeface to find. |
| 127 * @param glyphID Specify which section of a large font is of interest. | 127 * @param glyphID Specify which section of a large font is of interest. |
| 128 */ | 128 */ |
| 129 static SkPDFFont* GetFontResource(SkPDFCanon* canon, | 129 static SkPDFFont* GetFontResource(SkPDFCanon* canon, |
| 130 SkTypeface* typeface, | 130 SkTypeface* typeface, |
| 131 uint16_t glyphID); | 131 uint16_t glyphID); |
| 132 | 132 |
| 133 /** Subset the font based on usage set. Returns a SkPDFFont instance with | 133 /** Subset the font based on usage set. Returns a SkPDFFont instance with |
| 134 * subset. | 134 * subset. |
| 135 * @param usage Glyph subset requested. | 135 * @param usage Glyph subset requested. |
| 136 * @return NULL if font does not support subsetting, a new instance | 136 * @return nullptr if font does not support subsetting, a new instanc
e |
| 137 * of SkPDFFont otherwise. | 137 * of SkPDFFont otherwise. |
| 138 */ | 138 */ |
| 139 virtual SkPDFFont* getFontSubset(const SkPDFGlyphSet* usage); | 139 virtual SkPDFFont* getFontSubset(const SkPDFGlyphSet* usage); |
| 140 | 140 |
| 141 enum Match { | 141 enum Match { |
| 142 kExact_Match, | 142 kExact_Match, |
| 143 kRelated_Match, | 143 kRelated_Match, |
| 144 kNot_Match, | 144 kNot_Match, |
| 145 }; | 145 }; |
| 146 static Match IsMatch(SkPDFFont* existingFont, | 146 static Match IsMatch(SkPDFFont* existingFont, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 168 | 168 |
| 169 // Add common entries to FontDescriptor. | 169 // Add common entries to FontDescriptor. |
| 170 bool addCommonFontDescriptorEntries(int16_t defaultWidth); | 170 bool addCommonFontDescriptorEntries(int16_t defaultWidth); |
| 171 | 171 |
| 172 /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs, | 172 /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs, |
| 173 * including the passed glyphID. | 173 * including the passed glyphID. |
| 174 */ | 174 */ |
| 175 void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID); | 175 void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID); |
| 176 | 176 |
| 177 // Generate ToUnicode table according to glyph usage subset. | 177 // Generate ToUnicode table according to glyph usage subset. |
| 178 // If subset is NULL, all available glyph ids will be used. | 178 // If subset is nullptr, all available glyph ids will be used. |
| 179 void populateToUnicodeTable(const SkPDFGlyphSet* subset); | 179 void populateToUnicodeTable(const SkPDFGlyphSet* subset); |
| 180 | 180 |
| 181 // Create instances of derived types based on fontInfo. | 181 // Create instances of derived types based on fontInfo. |
| 182 static SkPDFFont* Create(SkPDFCanon* canon, | 182 static SkPDFFont* Create(SkPDFCanon* canon, |
| 183 const SkAdvancedTypefaceMetrics* fontInfo, | 183 const SkAdvancedTypefaceMetrics* fontInfo, |
| 184 SkTypeface* typeface, | 184 SkTypeface* typeface, |
| 185 uint16_t glyphID, | 185 uint16_t glyphID, |
| 186 SkPDFDict* relatedFontDescriptor); | 186 SkPDFDict* relatedFontDescriptor); |
| 187 | 187 |
| 188 static bool Find(uint32_t fontID, uint16_t glyphID, int* index); | 188 static bool Find(uint32_t fontID, uint16_t glyphID, int* index); |
| 189 | 189 |
| 190 private: | 190 private: |
| 191 SkAutoTUnref<SkTypeface> fTypeface; | 191 SkAutoTUnref<SkTypeface> fTypeface; |
| 192 | 192 |
| 193 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, | 193 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, |
| 194 // this will be a subset if the font has more than 255 glyphs. | 194 // this will be a subset if the font has more than 255 glyphs. |
| 195 uint16_t fFirstGlyphID; | 195 uint16_t fFirstGlyphID; |
| 196 uint16_t fLastGlyphID; | 196 uint16_t fLastGlyphID; |
| 197 SkAutoTUnref<const SkAdvancedTypefaceMetrics> fFontInfo; | 197 SkAutoTUnref<const SkAdvancedTypefaceMetrics> fFontInfo; |
| 198 SkAutoTUnref<SkPDFDict> fDescriptor; | 198 SkAutoTUnref<SkPDFDict> fDescriptor; |
| 199 | 199 |
| 200 SkAdvancedTypefaceMetrics::FontType fFontType; | 200 SkAdvancedTypefaceMetrics::FontType fFontType; |
| 201 | 201 |
| 202 typedef SkPDFDict INHERITED; | 202 typedef SkPDFDict INHERITED; |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 #endif | 205 #endif |
| OLD | NEW |