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 SkScalerContextEff
ects& effects, | 29 SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkDescriptor *desc
) |
30 const SkDescriptor *desc) | 30 : INHERITED(typeface, desc) |
31 : INHERITED(typeface, effects, desc) | |
32 {} | 31 {} |
33 | 32 |
34 void generateGlyphImage(FT_Face face, const SkGlyph& glyph); | 33 void generateGlyphImage(FT_Face face, const SkGlyph& glyph); |
35 void generateGlyphPath(FT_Face face, SkPath* path); | 34 void generateGlyphPath(FT_Face face, SkPath* path); |
36 | 35 |
37 private: | 36 private: |
38 typedef SkScalerContext INHERITED; | 37 typedef SkScalerContext INHERITED; |
39 }; | 38 }; |
40 | 39 |
41 class SkTypeface_FreeType : public SkTypeface { | 40 class SkTypeface_FreeType : public SkTypeface { |
(...skipping 27 matching lines...) Expand all Loading... |
69 FT_Library fLibrary; | 68 FT_Library fLibrary; |
70 mutable SkMutex fLibraryMutex; | 69 mutable SkMutex fLibraryMutex; |
71 }; | 70 }; |
72 | 71 |
73 protected: | 72 protected: |
74 SkTypeface_FreeType(const SkFontStyle& style, SkFontID uniqueID, bool isFixe
dPitch) | 73 SkTypeface_FreeType(const SkFontStyle& style, SkFontID uniqueID, bool isFixe
dPitch) |
75 : INHERITED(style, uniqueID, isFixedPitch) | 74 : INHERITED(style, uniqueID, isFixedPitch) |
76 , fGlyphCount(-1) | 75 , fGlyphCount(-1) |
77 {} | 76 {} |
78 | 77 |
79 virtual SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&
, | 78 virtual SkScalerContext* onCreateScalerContext( |
80 const SkDescriptor*) const ov
erride; | 79 const SkDescriptor*) const override; |
81 void onFilterRec(SkScalerContextRec*) const override; | 80 void onFilterRec(SkScalerContextRec*) const override; |
82 SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( | 81 SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( |
83 PerGlyphInfo, const uint32_t*, uint32_t) const override; | 82 PerGlyphInfo, const uint32_t*, uint32_t) const override; |
84 int onGetUPEM() const override; | 83 int onGetUPEM() const override; |
85 virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count, | 84 virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count, |
86 int32_t adjustments[]) const override; | 85 int32_t adjustments[]) const override; |
87 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], | 86 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], |
88 int glyphCount) const override; | 87 int glyphCount) const override; |
89 int onCountGlyphs() const override; | 88 int onCountGlyphs() const override; |
90 | 89 |
91 LocalizedStrings* onCreateFamilyNameIterator() const override; | 90 LocalizedStrings* onCreateFamilyNameIterator() const override; |
92 | 91 |
93 int onGetTableTags(SkFontTableTag tags[]) const override; | 92 int onGetTableTags(SkFontTableTag tags[]) const override; |
94 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 93 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
95 size_t length, void* data) const override; | 94 size_t length, void* data) const override; |
96 | 95 |
97 private: | 96 private: |
98 mutable int fGlyphCount; | 97 mutable int fGlyphCount; |
99 | 98 |
100 typedef SkTypeface INHERITED; | 99 typedef SkTypeface INHERITED; |
101 }; | 100 }; |
102 | 101 |
103 #endif // SKFONTHOST_FREETYPE_COMMON_H_ | 102 #endif // SKFONTHOST_FREETYPE_COMMON_H_ |
OLD | NEW |