blob: aef4d82044bc5cab301905f2824fc5a32c3b715a [file] [log] [blame]
* Copyright 2006-2012 The Android Open Source Project
* Copyright 2012 Mozilla Foundation
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#include "SkGlyph.h"
#include "SkScalerContext.h"
#include "SkTypeface.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef SK_DEBUG
#define SkASSERT_CONTINUE(pred) \
do { \
if (!(pred)) \
SkDebugf("file %s:%d: assert failed '" #pred "'\n", __FILE__, __LINE__); \
} while (false)
#define SkASSERT_CONTINUE(pred)
class SkScalerContext_FreeType_Base : public SkScalerContext {
// See
// This value was chosen by eyeballing the result in Firefox and trying to match it.
static const FT_Pos kBitmapEmboldenStrength = 1 << 6;
SkScalerContext_FreeType_Base(SkTypeface* typeface, const SkDescriptor *desc)
: INHERITED(typeface, desc)
void generateGlyphImage(FT_Face face, const SkGlyph& glyph);
void generateGlyphPath(FT_Face face, SkPath* path);
typedef SkScalerContext INHERITED;
class SkTypeface_FreeType : public SkTypeface {
SkTypeface_FreeType(Style style, SkFontID uniqueID, bool isFixedPitch)
: INHERITED(style, uniqueID, isFixedPitch)
, fGlyphCount(-1)
virtual SkScalerContext* onCreateScalerContext(
const SkDescriptor*) const SK_OVERRIDE;
virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
const uint32_t*, uint32_t) const SK_OVERRIDE;
virtual int onGetUPEM() const SK_OVERRIDE;
virtual bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count,
int32_t adjustments[]) const SK_OVERRIDE;
virtual int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[],
int glyphCount) const SK_OVERRIDE;
virtual int onCountGlyphs() const SK_OVERRIDE;
virtual LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE;
virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
virtual size_t onGetTableData(SkFontTableTag, size_t offset,
size_t length, void* data) const SK_OVERRIDE;
mutable int fGlyphCount;
typedef SkTypeface INHERITED;