blob: 01100de43eb13f7d4ca0582c9304ca31145159ca [file] [log] [blame]
george@mozilla.comc59b5da2012-08-23 00:39:08 +00001/*
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
28class SkScalerContext_FreeType_Base : public SkScalerContext {
29public:
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
38protected:
bungeman@google.coma76de722012-10-26 19:35:54 +000039 void generateGlyphImage(FT_Face face, const SkGlyph& glyph);
george@mozilla.comc59b5da2012-08-23 00:39:08 +000040 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_