OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006-2012 The Android Open Source Project | 2 * Copyright 2006-2012 The Android Open Source Project |
3 * Copyright 2012 Mozilla Foundation | 3 * Copyright 2012 Mozilla Foundation |
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 #ifndef SKFONTHOST_FREETYPE_COMMON_H_ | 9 #ifndef SKFONTHOST_FREETYPE_COMMON_H_ |
10 #define SKFONTHOST_FREETYPE_COMMON_H_ | 10 #define SKFONTHOST_FREETYPE_COMMON_H_ |
11 | 11 |
12 #include "SkGlyph.h" | 12 #include "SkGlyph.h" |
13 #include "SkScalerContext.h" | 13 #include "SkScalerContext.h" |
14 #include "SkTypeface.h" | 14 #include "SkTypeface.h" |
| 15 #include "SkTypes.h" |
15 | 16 |
16 #include <ft2build.h> | 17 #include <ft2build.h> |
17 #include FT_FREETYPE_H | 18 #include FT_FREETYPE_H |
18 | 19 |
19 #ifdef SK_DEBUG | 20 #ifdef SK_DEBUG |
20 #define SkASSERT_CONTINUE(pred)
\ | 21 #define SkASSERT_CONTINUE(pred)
\ |
21 do {
\ | 22 do {
\ |
22 if (!(pred))
\ | 23 if (!(pred))
\ |
23 SkDebugf("file %s:%d: assert failed '" #pred "'\n", __FILE__, __
LINE__); \ | 24 SkDebugf("file %s:%d: assert failed '" #pred "'\n", __FILE__, __
LINE__); \ |
24 } while (false) | 25 } while (false) |
(...skipping 16 matching lines...) Expand all Loading... |
41 | 42 |
42 private: | 43 private: |
43 typedef SkScalerContext INHERITED; | 44 typedef SkScalerContext INHERITED; |
44 }; | 45 }; |
45 | 46 |
46 class SkTypeface_FreeType : public SkTypeface { | 47 class SkTypeface_FreeType : public SkTypeface { |
47 public: | 48 public: |
48 /** For SkFontMgrs to make use of our ability to extract | 49 /** For SkFontMgrs to make use of our ability to extract |
49 * name and style from a stream, using FreeType's API. | 50 * name and style from a stream, using FreeType's API. |
50 */ | 51 */ |
51 static bool ScanFont(SkStream* stream, int ttcIndex, | 52 class Scanner : ::SkNoncopyable { |
52 SkString* name, SkFontStyle* style, bool* isFixedPitch)
; | 53 public: |
| 54 Scanner(); |
| 55 ~Scanner(); |
| 56 bool recognizedFont(SkStream* stream, int* numFonts) const; |
| 57 bool scanFont(SkStream* stream, int ttcIndex, |
| 58 SkString* name, SkFontStyle* style, bool* isFixedPitch) co
nst; |
| 59 private: |
| 60 FT_Face openFace(SkStream* stream, int ttcIndex, FT_Stream ftStream) con
st; |
| 61 FT_Library fLibrary; |
| 62 mutable SkMutex fLibraryMutex; |
| 63 }; |
53 | 64 |
54 protected: | 65 protected: |
55 SkTypeface_FreeType(const SkFontStyle& style, SkFontID uniqueID, bool isFixe
dPitch) | 66 SkTypeface_FreeType(const SkFontStyle& style, SkFontID uniqueID, bool isFixe
dPitch) |
56 : INHERITED(style, uniqueID, isFixedPitch) | 67 : INHERITED(style, uniqueID, isFixedPitch) |
57 , fGlyphCount(-1) | 68 , fGlyphCount(-1) |
58 {} | 69 {} |
59 | 70 |
60 virtual SkScalerContext* onCreateScalerContext( | 71 virtual SkScalerContext* onCreateScalerContext( |
61 const SkDescriptor*) const SK_OVERRIDE; | 72 const SkDescriptor*) const SK_OVERRIDE; |
62 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 73 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
(...skipping 13 matching lines...) Expand all Loading... |
76 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 87 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
77 size_t length, void* data) const SK_OVERRIDE; | 88 size_t length, void* data) const SK_OVERRIDE; |
78 | 89 |
79 private: | 90 private: |
80 mutable int fGlyphCount; | 91 mutable int fGlyphCount; |
81 | 92 |
82 typedef SkTypeface INHERITED; | 93 typedef SkTypeface INHERITED; |
83 }; | 94 }; |
84 | 95 |
85 #endif // SKFONTHOST_FREETYPE_COMMON_H_ | 96 #endif // SKFONTHOST_FREETYPE_COMMON_H_ |
OLD | NEW |