george@mozilla.com | c59b5da | 2012-08-23 00:39:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2006-2012 The Android Open Source Project |
| 3 | * Copyright 2012 Mozilla Foundation |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | #ifndef SKFONTHOST_FREETYPE_COMMON_H_ |
| 10 | #define SKFONTHOST_FREETYPE_COMMON_H_ |
| 11 | |
| 12 | #include "SkGlyph.h" |
| 13 | #include "SkScalerContext.h" |
reed@google.com | 0da4861 | 2013-03-19 16:06:52 +0000 | [diff] [blame] | 14 | #include "SkTypeface.h" |
| 15 | |
george@mozilla.com | c59b5da | 2012-08-23 00:39:08 +0000 | [diff] [blame] | 16 | #include <ft2build.h> |
| 17 | #include FT_FREETYPE_H |
| 18 | |
| 19 | #ifdef SK_DEBUG |
| 20 | #define SkASSERT_CONTINUE(pred) \ |
| 21 | do { \ |
| 22 | if (!(pred)) \ |
| 23 | SkDebugf("file %s:%d: assert failed '" #pred "'\n", __FILE__, __LINE__); \ |
| 24 | } while (false) |
| 25 | #else |
| 26 | #define SkASSERT_CONTINUE(pred) |
| 27 | #endif |
| 28 | |
| 29 | |
| 30 | class SkScalerContext_FreeType_Base : public SkScalerContext { |
reed@google.com | 0da4861 | 2013-03-19 16:06:52 +0000 | [diff] [blame] | 31 | protected: |
george@mozilla.com | c59b5da | 2012-08-23 00:39:08 +0000 | [diff] [blame] | 32 | // See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_handling.html#FT_Bitmap_Embolden |
| 33 | // This value was chosen by eyeballing the result in Firefox and trying to match it. |
| 34 | static const FT_Pos kBitmapEmboldenStrength = 1 << 6; |
skia.committer@gmail.com | 01c34ee | 2013-03-20 07:01:02 +0000 | [diff] [blame^] | 35 | |
reed@google.com | 0da4861 | 2013-03-19 16:06:52 +0000 | [diff] [blame] | 36 | SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkDescriptor *desc) |
| 37 | : INHERITED(typeface, desc) |
george@mozilla.com | c59b5da | 2012-08-23 00:39:08 +0000 | [diff] [blame] | 38 | {} |
skia.committer@gmail.com | 01c34ee | 2013-03-20 07:01:02 +0000 | [diff] [blame^] | 39 | |
bungeman@google.com | a76de72 | 2012-10-26 19:35:54 +0000 | [diff] [blame] | 40 | void generateGlyphImage(FT_Face face, const SkGlyph& glyph); |
sugoi@google.com | 66a58ac | 2013-03-05 20:40:52 +0000 | [diff] [blame] | 41 | void generateGlyphPath(FT_Face face, SkPath* path); |
george@mozilla.com | c59b5da | 2012-08-23 00:39:08 +0000 | [diff] [blame] | 42 | void emboldenOutline(FT_Face face, FT_Outline* outline); |
reed@google.com | 0da4861 | 2013-03-19 16:06:52 +0000 | [diff] [blame] | 43 | |
| 44 | private: |
| 45 | typedef SkScalerContext INHERITED; |
| 46 | }; |
| 47 | |
| 48 | class SkTypeface_FreeType : public SkTypeface { |
| 49 | protected: |
| 50 | SkTypeface_FreeType(Style style, SkFontID uniqueID, bool isFixedWidth) |
| 51 | : INHERITED(style, uniqueID, isFixedWidth) {} |
| 52 | |
| 53 | virtual SkScalerContext* onCreateScalerContext( |
| 54 | const SkDescriptor*) const SK_OVERRIDE; |
| 55 | virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; |
| 56 | |
| 57 | private: |
| 58 | typedef SkTypeface INHERITED; |
george@mozilla.com | c59b5da | 2012-08-23 00:39:08 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | #endif // SKFONTHOST_FREETYPE_COMMON_H_ |