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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 * responsibility to unreference it when done. This is needed to | 118 * responsibility to unreference it when done. This is needed to |
119 * accommodate the weak reference pattern used when the returned object | 119 * accommodate the weak reference pattern used when the returned object |
120 * is new and has no other references. | 120 * is new and has no other references. |
121 * @param typeface The typeface to find. | 121 * @param typeface The typeface to find. |
122 * @param glyphID Specify which section of a large font is of interest. | 122 * @param glyphID Specify which section of a large font is of interest. |
123 */ | 123 */ |
124 static SkPDFFont* GetFontResource(SkPDFCanon* canon, | 124 static SkPDFFont* GetFontResource(SkPDFCanon* canon, |
125 SkTypeface* typeface, | 125 SkTypeface* typeface, |
126 uint16_t glyphID); | 126 uint16_t glyphID); |
127 | 127 |
128 static sk_sp<const SkAdvancedTypefaceMetrics> GetFontMetricsWithGlyphNames( | |
129 SkTypeface*, uint32_t* glyphs, uint32_t glyphsCount); | |
130 | |
131 static sk_sp<const SkAdvancedTypefaceMetrics> GetFontMetricsWithToUnicode( | 128 static sk_sp<const SkAdvancedTypefaceMetrics> GetFontMetricsWithToUnicode( |
132 SkTypeface*, uint32_t* glyphs, uint32_t glyphsCount); | 129 SkTypeface*, uint32_t* glyphs, uint32_t glyphsCount); |
133 | 130 |
134 /** Subset the font based on usage set. Returns a SkPDFFont instance with | 131 /** Subset the font based on usage set. Returns a SkPDFFont instance with |
135 * subset. | 132 * subset. |
136 * @param usage Glyph subset requested. | 133 * @param usage Glyph subset requested. |
137 * @return nullptr if font does not support subsetting, a new instanc
e | 134 * @return nullptr if font does not support subsetting, a new instanc
e |
138 * of SkPDFFont otherwise. | 135 * of SkPDFFont otherwise. |
139 */ | 136 */ |
140 virtual sk_sp<SkPDFObject> getFontSubset(const SkPDFGlyphSet* usage); | 137 virtual sk_sp<SkPDFObject> getFontSubset(const SkPDFGlyphSet* usage); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 SkGlyphID lastGlyphID() const { return fLastGlyphID; } | 170 SkGlyphID lastGlyphID() const { return fLastGlyphID; } |
174 void setLastGlyphID(uint16_t glyphID); | 171 void setLastGlyphID(uint16_t glyphID); |
175 | 172 |
176 // Accessors for FontDescriptor associated with this object. | 173 // Accessors for FontDescriptor associated with this object. |
177 SkPDFDict* getFontDescriptor() const { return fDescriptor.get(); } | 174 SkPDFDict* getFontDescriptor() const { return fDescriptor.get(); } |
178 sk_sp<SkPDFDict> refFontDescriptor() const { return fDescriptor; } | 175 sk_sp<SkPDFDict> refFontDescriptor() const { return fDescriptor; } |
179 void setFontDescriptor(sk_sp<SkPDFDict> descriptor); | 176 void setFontDescriptor(sk_sp<SkPDFDict> descriptor); |
180 | 177 |
181 sk_sp<SkTypeface> refTypeface() const { return fTypeface; } | 178 sk_sp<SkTypeface> refTypeface() const { return fTypeface; } |
182 | 179 |
183 // Add common entries to FontDescriptor. | |
184 bool addCommonFontDescriptorEntries(int16_t defaultWidth); | |
185 | |
186 /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs, | 180 /** Set fFirstGlyphID and fLastGlyphID to span at most 255 glyphs, |
187 * including the passed glyphID. | 181 * including the passed glyphID. |
188 */ | 182 */ |
189 void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID); | 183 void adjustGlyphRangeForSingleByteEncoding(uint16_t glyphID); |
190 | 184 |
191 // Generate ToUnicode table according to glyph usage subset. | 185 // Generate ToUnicode table according to glyph usage subset. |
192 // If subset is nullptr, all available glyph ids will be used. | 186 // If subset is nullptr, all available glyph ids will be used. |
193 void populateToUnicodeTable(const SkPDFGlyphSet* subset); | 187 void populateToUnicodeTable(const SkPDFGlyphSet* subset); |
194 | 188 |
195 static bool Find(uint32_t fontID, uint16_t glyphID, int* index); | 189 static bool Find(uint32_t fontID, uint16_t glyphID, int* index); |
196 | 190 |
197 void drop() override; | 191 void drop() override; |
198 | 192 |
199 private: | 193 private: |
200 sk_sp<SkTypeface> fTypeface; | 194 sk_sp<SkTypeface> fTypeface; |
201 sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo; | 195 sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo; |
202 sk_sp<SkPDFDict> fDescriptor; | 196 sk_sp<SkPDFDict> fDescriptor; |
203 | 197 |
204 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, | 198 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, |
205 // this will be a subset if the font has more than 255 glyphs. | 199 // this will be a subset if the font has more than 255 glyphs. |
206 SkGlyphID fFirstGlyphID; | 200 SkGlyphID fFirstGlyphID; |
207 SkGlyphID fLastGlyphID; | 201 SkGlyphID fLastGlyphID; |
208 SkAdvancedTypefaceMetrics::FontType fFontType; | 202 SkAdvancedTypefaceMetrics::FontType fFontType; |
209 bool fMultiByteGlyphs; | 203 bool fMultiByteGlyphs; |
210 | 204 |
211 typedef SkPDFDict INHERITED; | 205 typedef SkPDFDict INHERITED; |
212 }; | 206 }; |
213 | 207 |
214 #endif | 208 #endif |
OLD | NEW |