2 * Copyright 2006-2012 The Android Open Source Project
3 * Copyright 2012 Mozilla Foundation
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
9 #ifndef SKFONTHOST_FREETYPE_COMMON_H_
10 #define SKFONTHOST_FREETYPE_COMMON_H_
13 #include "SkScalerContext.h"
14 #include "SkTypeface.h"
17 #include FT_FREETYPE_H
20 #define SkASSERT_CONTINUE(pred) \
23 SkDebugf("file %s:%d: assert failed '" #pred "'\n", __FILE__, __LINE__); \
26 #define SkASSERT_CONTINUE(pred)
29 class SkScalerContext_FreeType_Base : public SkScalerContext {
31 // See http://freetype.sourceforge.net/freetype2/docs/reference/ft2-bitmap_handling.html#FT_Bitmap_Embolden
32 // This value was chosen by eyeballing the result in Firefox and trying to match it.
33 static const FT_Pos kBitmapEmboldenStrength = 1 << 6;
35 SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkDescriptor *desc)
36 : INHERITED(typeface, desc)
39 void generateGlyphImage(FT_Face face, const SkGlyph& glyph);
40 void generateGlyphPath(FT_Face face, SkPath* path);
43 typedef SkScalerContext INHERITED;
46 class SkTypeface_FreeType : public SkTypeface {
48 /** For SkFontMgrs to make use of our ability to extract
49 * name and style from a stream, using FreeType's API.
51 static bool ScanFont(SkStream* stream, int ttcIndex,
52 SkString* name, SkTypeface::Style* style, bool* isFixedPitch);
55 SkTypeface_FreeType(Style style, SkFontID uniqueID, bool isFixedPitch)
56 : INHERITED(style, uniqueID, isFixedPitch)
60 virtual SkScalerContext* onCreateScalerContext(
61 const SkDescriptor*) const SK_OVERRIDE;
62 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
63 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
64 SkAdvancedTypefaceMetrics::PerGlyphInfo,
65 const uint32_t*, uint32_t) const SK_OVERRIDE;
66 virtual int onGetUPEM() const SK_OVERRIDE;
67 virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count,
68 int32_t adjustments[]) const SK_OVERRIDE;
69 virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[],
70 int glyphCount) const SK_OVERRIDE;
71 virtual int onCountGlyphs() const SK_OVERRIDE;
73 virtual LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE;
75 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
76 virtual size_t onGetTableData(SkFontTableTag, size_t offset,
77 size_t length, void* data) const SK_OVERRIDE;
80 mutable int fGlyphCount;
82 typedef SkTypeface INHERITED;
85 #endif // SKFONTHOST_FREETYPE_COMMON_H_