Index: ui/gfx/platform_font_pango.cc |
diff --git a/ui/gfx/platform_font_pango.cc b/ui/gfx/platform_font_pango.cc |
index ebf71c62f4b5500c47e4682e6888952cca2fd215..b89cf70e87c61f9691f1f51231dfafde20a2b0d5 100644 |
--- a/ui/gfx/platform_font_pango.cc |
+++ b/ui/gfx/platform_font_pango.cc |
@@ -174,10 +174,9 @@ Font PlatformFontPango::DeriveFont(int size_delta, int style) const { |
if (gfx::Font::ITALIC & style) |
skstyle |= SkTypeface::kItalic; |
- SkTypeface* typeface = SkTypeface::CreateFromName( |
+ skia::RefPtr<SkTypeface> typeface = SkTypeface::CreateFromName( |
font_family_.c_str(), |
static_cast<SkTypeface::Style>(skstyle)); |
- SkAutoUnref tf_helper(typeface); |
return Font(new PlatformFontPango(typeface, |
font_family_, |
@@ -252,7 +251,7 @@ NativeFont PlatformFontPango::GetNativeFont() const { |
//////////////////////////////////////////////////////////////////////////////// |
// PlatformFontPango, private: |
-PlatformFontPango::PlatformFontPango(SkTypeface* typeface, |
+PlatformFontPango::PlatformFontPango(const skia::RefPtr<SkTypeface>& typeface, |
const std::string& name, |
int size, |
int style) { |
@@ -266,7 +265,7 @@ void PlatformFontPango::InitWithNameAndSize(const std::string& font_name, |
DCHECK_GT(font_size, 0); |
std::string fallback; |
- SkTypeface* typeface = SkTypeface::CreateFromName( |
+ skia::RefPtr<SkTypeface> typeface = SkTypeface::CreateFromName( |
font_name.c_str(), SkTypeface::kNormal); |
if (!typeface) { |
// A non-scalable font such as .pcf is specified. Falls back to a default |
@@ -278,7 +277,6 @@ void PlatformFontPango::InitWithNameAndSize(const std::string& font_name, |
<< ", " << kFallbackFontFamilyName; |
fallback = kFallbackFontFamilyName; |
} |
- SkAutoUnref typeface_helper(typeface); |
InitWithTypefaceNameSizeAndStyle(typeface, |
fallback.empty() ? font_name : fallback, |
@@ -287,13 +285,11 @@ void PlatformFontPango::InitWithNameAndSize(const std::string& font_name, |
} |
void PlatformFontPango::InitWithTypefaceNameSizeAndStyle( |
- SkTypeface* typeface, |
+ const skia::RefPtr<SkTypeface>& typeface, |
const std::string& font_family, |
int font_size, |
int style) { |
- typeface_helper_.reset(new SkAutoUnref(typeface)); |
typeface_ = typeface; |
- typeface_->ref(); |
font_family_ = font_family; |
font_size_pixels_ = font_size; |
style_ = style; |
@@ -312,9 +308,7 @@ void PlatformFontPango::InitWithTypefaceNameSizeAndStyle( |
} |
void PlatformFontPango::InitFromPlatformFont(const PlatformFontPango* other) { |
- typeface_helper_.reset(new SkAutoUnref(other->typeface_)); |
typeface_ = other->typeface_; |
- typeface_->ref(); |
font_family_ = other->font_family_; |
font_size_pixels_ = other->font_size_pixels_; |
style_ = other->style_; |
@@ -330,7 +324,7 @@ void PlatformFontPango::PaintSetup(SkPaint* paint) const { |
paint->setAntiAlias(false); |
paint->setSubpixelText(false); |
paint->setTextSize(font_size_pixels_); |
- paint->setTypeface(typeface_); |
+ paint->setTypeface(typeface_.get()); |
paint->setFakeBoldText((gfx::Font::BOLD & style_) && !typeface_->isBold()); |
paint->setTextSkewX((gfx::Font::ITALIC & style_) && !typeface_->isItalic() ? |
-SK_Scalar1/4 : 0); |