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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 uint16_t searchGlyphID); | 151 uint16_t searchGlyphID); |
152 | 152 |
153 /** | 153 /** |
154 * Return false iff the typeface has its NotEmbeddable flag set. | 154 * Return false iff the typeface has its NotEmbeddable flag set. |
155 * If typeface is NULL, the default typeface is checked. | 155 * If typeface is NULL, the default typeface is checked. |
156 */ | 156 */ |
157 static bool CanEmbedTypeface(SkTypeface*, SkPDFCanon*); | 157 static bool CanEmbedTypeface(SkTypeface*, SkPDFCanon*); |
158 | 158 |
159 protected: | 159 protected: |
160 // Common constructor to handle common members. | 160 // Common constructor to handle common members. |
161 SkPDFFont(const SkAdvancedTypefaceMetrics* fontInfo, | 161 SkPDFFont(sk_sp<const SkAdvancedTypefaceMetrics> fontInfo, |
162 SkTypeface* typeface, | 162 sk_sp<SkTypeface> typeface, |
163 SkPDFDict* relatedFontDescriptor); | 163 sk_sp<SkPDFDict> relatedFontDescriptor, |
| 164 SkAdvancedTypefaceMetrics::FontType fontType, |
| 165 bool multiByteGlyphs); |
164 | 166 |
165 // Accessors for subclass. | 167 // Accessors for subclass. |
166 const SkAdvancedTypefaceMetrics* fontInfo(); | 168 const SkAdvancedTypefaceMetrics* getFontInfo() const { return fFontInfo.get(
); } |
167 void setFontInfo(const SkAdvancedTypefaceMetrics* info); | 169 sk_sp<const SkAdvancedTypefaceMetrics> refFontInfo() const { return fFontInf
o; } |
168 uint16_t firstGlyphID() const; | 170 |
169 uint16_t lastGlyphID() const; | 171 void setFontInfo(sk_sp<const SkAdvancedTypefaceMetrics> info); |
| 172 SkGlyphID firstGlyphID() const { return fFirstGlyphID; } |
| 173 SkGlyphID lastGlyphID() const { return fLastGlyphID; } |
170 void setLastGlyphID(uint16_t glyphID); | 174 void setLastGlyphID(uint16_t glyphID); |
171 | 175 |
172 // Accessors for FontDescriptor associated with this object. | 176 // Accessors for FontDescriptor associated with this object. |
173 SkPDFDict* getFontDescriptor(); | 177 SkPDFDict* getFontDescriptor() const { return fDescriptor.get(); } |
174 void setFontDescriptor(SkPDFDict* descriptor); | 178 sk_sp<SkPDFDict> refFontDescriptor() const { return fDescriptor; } |
| 179 void setFontDescriptor(sk_sp<SkPDFDict> descriptor); |
| 180 |
| 181 sk_sp<SkTypeface> refTypeface() const { return fTypeface; } |
175 | 182 |
176 // Add common entries to FontDescriptor. | 183 // Add common entries to FontDescriptor. |
177 bool addCommonFontDescriptorEntries(int16_t defaultWidth); | 184 bool addCommonFontDescriptorEntries(int16_t defaultWidth); |
178 | 185 |
179 /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs, | 186 /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs, |
180 * including the passed glyphID. | 187 * including the passed glyphID. |
181 */ | 188 */ |
182 void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID); | 189 void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID); |
183 | 190 |
184 // Generate ToUnicode table according to glyph usage subset. | 191 // Generate ToUnicode table according to glyph usage subset. |
185 // If subset is nullptr, all available glyph ids will be used. | 192 // If subset is nullptr, all available glyph ids will be used. |
186 void populateToUnicodeTable(const SkPDFGlyphSet* subset); | 193 void populateToUnicodeTable(const SkPDFGlyphSet* subset); |
187 | 194 |
188 // Create instances of derived types based on fontInfo. | |
189 static SkPDFFont* Create(SkPDFCanon* canon, | |
190 const SkAdvancedTypefaceMetrics* fontInfo, | |
191 SkTypeface* typeface, | |
192 uint16_t glyphID, | |
193 SkPDFDict* relatedFontDescriptor); | |
194 | |
195 static bool Find(uint32_t fontID, uint16_t glyphID, int* index); | 195 static bool Find(uint32_t fontID, uint16_t glyphID, int* index); |
196 | 196 |
197 void drop() override; | 197 void drop() override; |
198 | 198 |
199 private: | 199 private: |
200 sk_sp<SkTypeface> fTypeface; | 200 sk_sp<SkTypeface> fTypeface; |
| 201 sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo; |
| 202 sk_sp<SkPDFDict> fDescriptor; |
201 | 203 |
202 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, | 204 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, |
203 // this will be a subset if the font has more than 255 glyphs. | 205 // this will be a subset if the font has more than 255 glyphs. |
204 uint16_t fFirstGlyphID; | 206 SkGlyphID fFirstGlyphID; |
205 uint16_t fLastGlyphID; | 207 SkGlyphID fLastGlyphID; |
206 sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo; | |
207 sk_sp<SkPDFDict> fDescriptor; | |
208 | |
209 SkAdvancedTypefaceMetrics::FontType fFontType; | 208 SkAdvancedTypefaceMetrics::FontType fFontType; |
| 209 bool fMultiByteGlyphs; |
210 | 210 |
211 typedef SkPDFDict INHERITED; | 211 typedef SkPDFDict INHERITED; |
212 }; | 212 }; |
213 | 213 |
214 #endif | 214 #endif |
OLD | NEW |