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 "SkMutex.h" | 13 #include "SkMutex.h" |
14 #include "SkScalerContext.h" | 14 #include "SkScalerContext.h" |
15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
16 #include "SkTypes.h" | 16 #include "SkTypes.h" |
17 | 17 |
18 #include "SkFontMgr.h" | 18 #include "SkFontMgr.h" |
19 | 19 |
20 #include <ft2build.h> | 20 #include <ft2build.h> |
21 #include FT_FREETYPE_H | 21 #include FT_FREETYPE_H |
22 | 22 |
23 class SkScalerContext_FreeType_Base : public SkScalerContext { | 23 class SkScalerContext_FreeType_Base : public SkScalerContext { |
24 protected: | 24 protected: |
25 // See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_h
andling.html#FT_Bitmap_Embolden | 25 // See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_h
andling.html#FT_Bitmap_Embolden |
26 // This value was chosen by eyeballing the result in Firefox and trying to m
atch it. | 26 // This value was chosen by eyeballing the result in Firefox and trying to m
atch it. |
27 static const FT_Pos kBitmapEmboldenStrength = 1 << 6; | 27 static const FT_Pos kBitmapEmboldenStrength = 1 << 6; |
28 | 28 |
29 SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkDescriptor *desc
) | 29 SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkScalerContextEff
ects& effects, |
30 : INHERITED(typeface, desc) | 30 const SkDescriptor *desc) |
| 31 : INHERITED(typeface, effects, desc) |
31 {} | 32 {} |
32 | 33 |
33 void generateGlyphImage(FT_Face face, const SkGlyph& glyph); | 34 void generateGlyphImage(FT_Face face, const SkGlyph& glyph); |
34 void generateGlyphPath(FT_Face face, SkPath* path); | 35 void generateGlyphPath(FT_Face face, SkPath* path); |
35 | 36 |
36 private: | 37 private: |
37 typedef SkScalerContext INHERITED; | 38 typedef SkScalerContext INHERITED; |
38 }; | 39 }; |
39 | 40 |
40 class SkTypeface_FreeType : public SkTypeface { | 41 class SkTypeface_FreeType : public SkTypeface { |
(...skipping 27 matching lines...) Expand all Loading... |
68 FT_Library fLibrary; | 69 FT_Library fLibrary; |
69 mutable SkMutex fLibraryMutex; | 70 mutable SkMutex fLibraryMutex; |
70 }; | 71 }; |
71 | 72 |
72 protected: | 73 protected: |
73 SkTypeface_FreeType(const SkFontStyle& style, SkFontID uniqueID, bool isFixe
dPitch) | 74 SkTypeface_FreeType(const SkFontStyle& style, SkFontID uniqueID, bool isFixe
dPitch) |
74 : INHERITED(style, uniqueID, isFixedPitch) | 75 : INHERITED(style, uniqueID, isFixedPitch) |
75 , fGlyphCount(-1) | 76 , fGlyphCount(-1) |
76 {} | 77 {} |
77 | 78 |
78 virtual SkScalerContext* onCreateScalerContext( | 79 virtual SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&
, |
79 const SkDescriptor*) const override; | 80 const SkDescriptor*) const ov
erride; |
80 void onFilterRec(SkScalerContextRec*) const override; | 81 void onFilterRec(SkScalerContextRec*) const override; |
81 SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 82 SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
82 PerGlyphInfo, const uint32_t*, uint32_t) const override; | 83 PerGlyphInfo, const uint32_t*, uint32_t) const override; |
83 int onGetUPEM() const override; | 84 int onGetUPEM() const override; |
84 virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count, | 85 virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count, |
85 int32_t adjustments[]) const override; | 86 int32_t adjustments[]) const override; |
86 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], | 87 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], |
87 int glyphCount) const override; | 88 int glyphCount) const override; |
88 int onCountGlyphs() const override; | 89 int onCountGlyphs() const override; |
89 | 90 |
90 LocalizedStrings* onCreateFamilyNameIterator() const override; | 91 LocalizedStrings* onCreateFamilyNameIterator() const override; |
91 | 92 |
92 int onGetTableTags(SkFontTableTag tags[]) const override; | 93 int onGetTableTags(SkFontTableTag tags[]) const override; |
93 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 94 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
94 size_t length, void* data) const override; | 95 size_t length, void* data) const override; |
95 | 96 |
96 private: | 97 private: |
97 mutable int fGlyphCount; | 98 mutable int fGlyphCount; |
98 | 99 |
99 typedef SkTypeface INHERITED; | 100 typedef SkTypeface INHERITED; |
100 }; | 101 }; |
101 | 102 |
102 #endif // SKFONTHOST_FREETYPE_COMMON_H_ | 103 #endif // SKFONTHOST_FREETYPE_COMMON_H_ |
OLD | NEW |