class SkTypeface_Android : public SkTypeface_FreeType {
public:
SkTypeface_Android(int index,
- Style style,
+ const SkFontStyle& style,
bool isFixedPitch,
- const SkString familyName)
+ const SkString& familyName)
: INHERITED(style, SkTypefaceCache::NewFontID(), isFixedPitch)
, fIndex(index)
, fFamilyName(familyName) { }
class SkTypeface_AndroidSystem : public SkTypeface_Android {
public:
- SkTypeface_AndroidSystem(const SkString pathName,
+ SkTypeface_AndroidSystem(const SkString& pathName,
int index,
- Style style,
+ const SkFontStyle& style,
bool isFixedPitch,
- const SkString familyName,
+ const SkString& familyName,
const SkLanguage& lang,
FontVariant variantStyle)
: INHERITED(index, style, isFixedPitch, familyName)
public:
SkTypeface_AndroidStream(SkStream* stream,
int index,
- Style style,
+ const SkFontStyle& style,
bool isFixedPitch,
- const SkString familyName)
+ const SkString& familyName)
: INHERITED(index, style, isFixedPitch, familyName)
, fStream(SkRef(stream)) { }
class SkFontStyleSet_Android : public SkFontStyleSet {
public:
- explicit SkFontStyleSet_Android(const FontFamily& family, const char* basePath) {
+ explicit SkFontStyleSet_Android(const FontFamily& family, const char* basePath,
+ const SkTypeface_FreeType::Scanner& scanner)
+ {
const SkString* cannonicalFamilyName = NULL;
if (family.fNames.count() > 0) {
cannonicalFamilyName = &family.fNames[0];
const int ttcIndex = fontFile.fIndex;
SkString familyName;
- SkTypeface::Style style;
+ SkFontStyle style;
bool isFixedWidth;
- if (!SkTypeface_FreeType::ScanFont(stream.get(), ttcIndex,
- &familyName, &style, &isFixedWidth)) {
+ if (!scanner.scanFont(stream.get(), ttcIndex, &familyName, &style, &isFixedWidth)) {
DEBUG_FONT(("---- SystemFonts[%d] file=%s (INVALID)", i, pathName.c_str()));
continue;
}
+ if (fontFile.fWeight != 0) {
+ style = SkFontStyle(fontFile.fWeight, style.width(), style.slant());
+ }
+
const SkLanguage& lang = family.fLanguage;
uint32_t variant = family.fVariant;
if (kDefault_FontVariant == variant) {
private:
SkFontStyle style(int index) {
- return SkFontStyle(this->weight(index), SkFontStyle::kNormal_Width,
- this->slant(index));
- }
- SkFontStyle::Weight weight(int index) {
- if (fStyles[index]->isBold()) return SkFontStyle::kBold_Weight;
- return SkFontStyle::kNormal_Weight;
- }
- SkFontStyle::Slant slant(int index) {
- if (fStyles[index]->isItalic()) return SkFontStyle::kItalic_Slant;
- return SkFontStyle::kUpright_Slant;
+ return fStyles[index]->fontStyle();
}
static int match_score(const SkFontStyle& pattern, const SkFontStyle& candidate) {
int score = 0;
virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVERRIDE {
bool isFixedPitch;
- SkTypeface::Style style;
+ SkFontStyle style;
SkString name;
- if (!SkTypeface_FreeType::ScanFont(stream, ttcIndex, &name, &style, &isFixedPitch)) {
+ if (!fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch)) {
return NULL;
}
return SkNEW_ARGS(SkTypeface_AndroidStream, (stream, ttcIndex,
virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
unsigned styleBits) const SK_OVERRIDE {
- SkTypeface::Style oldStyle = (SkTypeface::Style)styleBits;
- SkFontStyle style = SkFontStyle(oldStyle & SkTypeface::kBold
- ? SkFontStyle::kBold_Weight
- : SkFontStyle::kNormal_Weight,
- SkFontStyle::kNormal_Width,
- oldStyle & SkTypeface::kItalic
- ? SkFontStyle::kItalic_Slant
- : SkFontStyle::kUpright_Slant);
+ SkFontStyle style = SkFontStyle(styleBits);
if (familyName) {
// On Android, we must return NULL when we can't find the requested
private:
+ SkTypeface_FreeType::Scanner fScanner;
+
SkTArray<SkAutoTUnref<SkFontStyleSet_Android>, true> fFontStyleSets;
SkFontStyleSet* fDefaultFamily;
SkTypeface* fDefaultTypeface;
}
}
- SkFontStyleSet_Android* newSet = SkNEW_ARGS(SkFontStyleSet_Android, (family, basePath));
+ SkFontStyleSet_Android* newSet =
+ SkNEW_ARGS(SkFontStyleSet_Android, (family, basePath, fScanner));
if (0 == newSet->count()) {
SkDELETE(newSet);
continue;