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 | 15 |
16 #include <ft2build.h> | 16 #include <ft2build.h> |
17 #include FT_FREETYPE_H | 17 #include FT_FREETYPE_H |
18 | 18 |
19 #ifdef SK_DEBUG | 19 #ifdef SK_DEBUG |
20 #define SkASSERT_CONTINUE(pred)
\ | 20 #define SkASSERT_CONTINUE(pred)
\ |
21 do {
\ | 21 do {
\ |
22 if (!(pred))
\ | 22 if (!(pred))
\ |
23 SkDebugf("file %s:%d: assert failed '" #pred "'\n", __FILE__, __
LINE__); \ | 23 SkDebugf("file %s:%d: assert failed '" #pred "'\n", __FILE__, __
LINE__); \ |
24 } while (false) | 24 } while (false) |
25 #else | 25 #else |
26 #define SkASSERT_CONTINUE(pred) | 26 #define SkASSERT_CONTINUE(pred) |
27 #endif | 27 #endif |
28 | 28 |
29 | |
30 class SkScalerContext_FreeType_Base : public SkScalerContext { | 29 class SkScalerContext_FreeType_Base : public SkScalerContext { |
31 protected: | 30 protected: |
32 // See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_h
andling.html#FT_Bitmap_Embolden | 31 // See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_h
andling.html#FT_Bitmap_Embolden |
33 // This value was chosen by eyeballing the result in Firefox and trying to m
atch it. | 32 // This value was chosen by eyeballing the result in Firefox and trying to m
atch it. |
34 static const FT_Pos kBitmapEmboldenStrength = 1 << 6; | 33 static const FT_Pos kBitmapEmboldenStrength = 1 << 6; |
35 | 34 |
36 SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkDescriptor *desc
) | 35 SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkDescriptor *desc
) |
37 : INHERITED(typeface, desc) | 36 : INHERITED(typeface, desc) |
38 {} | 37 {} |
39 | 38 |
40 void generateGlyphImage(FT_Face face, const SkGlyph& glyph); | 39 void generateGlyphImage(FT_Face face, const SkGlyph& glyph); |
41 void generateGlyphPath(FT_Face face, SkPath* path); | 40 void generateGlyphPath(FT_Face face, SkPath* path); |
42 | 41 |
43 private: | 42 private: |
44 typedef SkScalerContext INHERITED; | 43 typedef SkScalerContext INHERITED; |
45 }; | 44 }; |
46 | 45 |
47 class SkTypeface_FreeType : public SkTypeface { | 46 class SkTypeface_FreeType : public SkTypeface { |
| 47 public: |
| 48 /** For SkFontMgrs to make use of our ability to extract |
| 49 * name and style from a stream, using FreeType's API. |
| 50 */ |
| 51 static bool ScanFont(SkStream* stream, int ttcIndex, |
| 52 SkString* name, SkTypeface::Style* style, bool* isFixed
Pitch); |
| 53 |
48 protected: | 54 protected: |
49 SkTypeface_FreeType(Style style, SkFontID uniqueID, bool isFixedPitch) | 55 SkTypeface_FreeType(Style style, SkFontID uniqueID, bool isFixedPitch) |
50 : INHERITED(style, uniqueID, isFixedPitch) | 56 : INHERITED(style, uniqueID, isFixedPitch) |
51 , fGlyphCount(-1) | 57 , fGlyphCount(-1) |
52 {} | 58 {} |
53 | 59 |
54 virtual SkScalerContext* onCreateScalerContext( | 60 virtual SkScalerContext* onCreateScalerContext( |
55 const SkDescriptor*) const SK_OVERRIDE; | 61 const SkDescriptor*) const SK_OVERRIDE; |
56 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | 62 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
57 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 63 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
(...skipping 12 matching lines...) Expand all Loading... |
70 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 76 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
71 size_t length, void* data) const SK_OVERRIDE; | 77 size_t length, void* data) const SK_OVERRIDE; |
72 | 78 |
73 private: | 79 private: |
74 mutable int fGlyphCount; | 80 mutable int fGlyphCount; |
75 | 81 |
76 typedef SkTypeface INHERITED; | 82 typedef SkTypeface INHERITED; |
77 }; | 83 }; |
78 | 84 |
79 #endif // SKFONTHOST_FREETYPE_COMMON_H_ | 85 #endif // SKFONTHOST_FREETYPE_COMMON_H_ |
OLD | NEW |