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" |
| 14 | #include <ft2build.h> |
| 15 | #include FT_FREETYPE_H |
| 16 | |
| 17 | #ifdef SK_DEBUG |
| 18 | #define SkASSERT_CONTINUE(pred) \ |
| 19 | do { \ |
| 20 | if (!(pred)) \ |
| 21 | SkDebugf("file %s:%d: assert failed '" #pred "'\n", __FILE__, __LINE__); \ |
| 22 | } while (false) |
| 23 | #else |
| 24 | #define SkASSERT_CONTINUE(pred) |
| 25 | #endif |
| 26 | |
| 27 | |
| 28 | class SkScalerContext_FreeType_Base : public SkScalerContext { |
| 29 | public: |
| 30 | // See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_handling.html#FT_Bitmap_Embolden |
| 31 | // This value was chosen by eyeballing the result in Firefox and trying to match it. |
| 32 | static const FT_Pos kBitmapEmboldenStrength = 1 << 6; |
| 33 | |
| 34 | SkScalerContext_FreeType_Base(const SkDescriptor *desc) |
| 35 | : SkScalerContext(desc) |
| 36 | {} |
| 37 | |
| 38 | protected: |
bungeman@google.com | a76de72 | 2012-10-26 19:35:54 +0000 | [diff] [blame^] | 39 | void generateGlyphImage(FT_Face face, const SkGlyph& glyph); |
george@mozilla.com | c59b5da | 2012-08-23 00:39:08 +0000 | [diff] [blame] | 40 | void generateGlyphPath(FT_Face face, const SkGlyph& glyph, SkPath* path); |
| 41 | void emboldenOutline(FT_Face face, FT_Outline* outline); |
| 42 | }; |
| 43 | |
| 44 | #endif // SKFONTHOST_FREETYPE_COMMON_H_ |