OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 SkTypeface_DEFINED | 10 #ifndef SkTypeface_DEFINED |
11 #define SkTypeface_DEFINED | 11 #define SkTypeface_DEFINED |
12 | 12 |
13 #include "SkAdvancedTypefaceMetrics.h" | 13 #include "SkAdvancedTypefaceMetrics.h" |
14 #include "SkFontStyle.h" | 14 #include "SkFontStyle.h" |
| 15 #include "SkLazyPtr.h" |
15 #include "SkWeakRefCnt.h" | 16 #include "SkWeakRefCnt.h" |
16 | 17 |
17 class SkDescriptor; | 18 class SkDescriptor; |
18 class SkFontDescriptor; | 19 class SkFontDescriptor; |
19 class SkScalerContext; | 20 class SkScalerContext; |
20 struct SkScalerContextRec; | 21 struct SkScalerContextRec; |
21 class SkStream; | 22 class SkStream; |
22 class SkAdvancedTypefaceMetrics; | 23 class SkAdvancedTypefaceMetrics; |
23 class SkWStream; | 24 class SkWStream; |
24 | 25 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 SkStream* openStream(int* ttcIndex) const; | 276 SkStream* openStream(int* ttcIndex) const; |
276 | 277 |
277 /** | 278 /** |
278 * Return a scalercontext for the given descriptor. If this fails, then | 279 * Return a scalercontext for the given descriptor. If this fails, then |
279 * if allowFailure is true, this returns NULL, else it returns a | 280 * if allowFailure is true, this returns NULL, else it returns a |
280 * dummy scalercontext that will not crash, but will draw nothing. | 281 * dummy scalercontext that will not crash, but will draw nothing. |
281 */ | 282 */ |
282 SkScalerContext* createScalerContext(const SkDescriptor*, | 283 SkScalerContext* createScalerContext(const SkDescriptor*, |
283 bool allowFailure = false) const; | 284 bool allowFailure = false) const; |
284 | 285 |
| 286 /** |
| 287 * Return a rectangle (scaled to 1-pt) that represents the union of the bou
nds of all |
| 288 * of the glyphs, but each one positioned at (0,). This may be conservative
ly large, and |
| 289 * will not take into account any hinting or other size-specific adjustment
s. |
| 290 */ |
| 291 SkRect getBounds() const; |
| 292 |
285 // PRIVATE / EXPERIMENTAL -- do not call | 293 // PRIVATE / EXPERIMENTAL -- do not call |
286 void filterRec(SkScalerContextRec* rec) const { | 294 void filterRec(SkScalerContextRec* rec) const { |
287 this->onFilterRec(rec); | 295 this->onFilterRec(rec); |
288 } | 296 } |
289 // PRIVATE / EXPERIMENTAL -- do not call | 297 // PRIVATE / EXPERIMENTAL -- do not call |
290 void getFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const { | 298 void getFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const { |
291 this->onGetFontDescriptor(desc, isLocal); | 299 this->onGetFontDescriptor(desc, isLocal); |
292 } | 300 } |
293 | 301 |
294 protected: | 302 protected: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 */ | 334 */ |
327 virtual void onGetFamilyName(SkString* familyName) const = 0; | 335 virtual void onGetFamilyName(SkString* familyName) const = 0; |
328 | 336 |
329 /** Returns an iterator over the family names in the font. */ | 337 /** Returns an iterator over the family names in the font. */ |
330 virtual LocalizedStrings* onCreateFamilyNameIterator() const = 0; | 338 virtual LocalizedStrings* onCreateFamilyNameIterator() const = 0; |
331 | 339 |
332 virtual int onGetTableTags(SkFontTableTag tags[]) const = 0; | 340 virtual int onGetTableTags(SkFontTableTag tags[]) const = 0; |
333 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 341 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
334 size_t length, void* data) const = 0; | 342 size_t length, void* data) const = 0; |
335 | 343 |
| 344 virtual bool onComputeBounds(SkRect*) const; |
| 345 |
336 private: | 346 private: |
337 friend class SkGTypeface; | 347 friend class SkGTypeface; |
338 friend class SkPDFFont; | 348 friend class SkPDFFont; |
339 friend class SkPDFCIDFont; | 349 friend class SkPDFCIDFont; |
340 friend class GrPathRendering; | 350 friend class GrPathRendering; |
341 friend class GrGLPathRendering; | 351 friend class GrGLPathRendering; |
342 | 352 |
343 /** Retrieve detailed typeface metrics. Used by the PDF backend. | 353 /** Retrieve detailed typeface metrics. Used by the PDF backend. |
344 @param perGlyphInfo Indicate what glyph specific information (advances, | 354 @param perGlyphInfo Indicate what glyph specific information (advances, |
345 names, etc.) should be populated. | 355 names, etc.) should be populated. |
346 @param glyphIDs For per-glyph info, specify subset of the font by | 356 @param glyphIDs For per-glyph info, specify subset of the font by |
347 giving glyph ids. Each integer represents a glyph | 357 giving glyph ids. Each integer represents a glyph |
348 id. Passing NULL means all glyphs in the font. | 358 id. Passing NULL means all glyphs in the font. |
349 @param glyphIDsCount Number of elements in subsetGlyphIds. Ignored if | 359 @param glyphIDsCount Number of elements in subsetGlyphIds. Ignored if |
350 glyphIDs is NULL. | 360 glyphIDs is NULL. |
351 @return The returned object has already been referenced. | 361 @return The returned object has already been referenced. |
352 */ | 362 */ |
353 SkAdvancedTypefaceMetrics* getAdvancedTypefaceMetrics( | 363 SkAdvancedTypefaceMetrics* getAdvancedTypefaceMetrics( |
354 SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, | 364 SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, |
355 const uint32_t* glyphIDs = NULL, | 365 const uint32_t* glyphIDs = NULL, |
356 uint32_t glyphIDsCount = 0) const; | 366 uint32_t glyphIDsCount = 0) const; |
357 | 367 |
358 private: | 368 private: |
359 static SkTypeface* CreateDefault(int style); // SkLazyPtr requires an int,
not a Style. | 369 static SkTypeface* CreateDefault(int style); // SkLazyPtr requires an int,
not a Style. |
360 static void DeleteDefault(SkTypeface*); | 370 static void DeleteDefault(SkTypeface*); |
361 | 371 |
362 SkFontID fUniqueID; | 372 struct BoundsComputer; |
363 SkFontStyle fStyle; | 373 // friend struct BoundsComputer; |
364 bool fIsFixedPitch; | 374 |
| 375 SkLazyPtr<SkRect> fLazyBounds; |
| 376 SkFontID fUniqueID; |
| 377 SkFontStyle fStyle; |
| 378 bool fIsFixedPitch; |
365 | 379 |
366 friend class SkPaint; | 380 friend class SkPaint; |
367 friend class SkGlyphCache; // GetDefaultTypeface | 381 friend class SkGlyphCache; // GetDefaultTypeface |
368 // just so deprecated fonthost can call protected methods | 382 // just so deprecated fonthost can call protected methods |
369 friend class SkFontHost; | 383 friend class SkFontHost; |
370 | 384 |
371 typedef SkWeakRefCnt INHERITED; | 385 typedef SkWeakRefCnt INHERITED; |
372 }; | 386 }; |
373 | 387 |
374 #endif | 388 #endif |
OLD | NEW |