}
SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
- if (family && family->style() == s) {
+ if (!family) {
+ return SkTypeface::RefDefault(s);
+ }
+
+ if (family->style() == s) {
family->ref();
return const_cast<SkTypeface*>(family);
}
+
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
bool bold = s & SkTypeface::kBold;
bool italic = s & SkTypeface::kItalic;
: SkFontStyle::kNormal_Weight,
SkFontStyle::kNormal_Width,
italic ? SkFontStyle::kItalic_Slant
- : SkFontStyle::kUpright_Slant);
+ : SkFontStyle::kUpright_Slant);
return fm->matchFaceStyle(family, newStyle);
}
const SkFontStyle& style) const SK_OVERRIDE
{
//TODO: should the SkTypeface_fontconfig know its family?
- const char* name = NULL;
- if (typeface) {
- const SkTypeface_fontconfig* fcTypeface =
+ const SkTypeface_fontconfig* fcTypeface =
static_cast<const SkTypeface_fontconfig*>(typeface);
- name = get_string(fcTypeface->fPattern, FC_FAMILY);
- }
- return this->matchFamilyStyle(name, style);
+ return this->matchFamilyStyle(get_string(fcTypeface->fPattern, FC_FAMILY), style);
}
/** @param stream does not take ownership of the reference. */