| Index: ui/gfx/render_text_mac.mm
|
| diff --git a/ui/gfx/render_text_mac.mm b/ui/gfx/render_text_mac.mm
|
| index f1c7299af209198be595064a33796efe5d70d5ee..915f51f927a75e665124221256000cce10843102 100644
|
| --- a/ui/gfx/render_text_mac.mm
|
| +++ b/ui/gfx/render_text_mac.mm
|
| @@ -66,12 +66,14 @@ namespace gfx {
|
|
|
| namespace internal {
|
|
|
| -skia::RefPtr<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style) {
|
| +// Note: this is only used by RenderTextHarfbuzz.
|
| +sk_sp<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style) {
|
| gfx::Font font_with_style = font.Derive(0, style);
|
| if (!font_with_style.GetNativeFont())
|
| return nullptr;
|
| - return skia::AdoptRef(SkCreateTypefaceFromCTFont(
|
| - static_cast<CTFontRef>(font_with_style.GetNativeFont())));
|
| +
|
| + return sk_sp<SkTypeface>(SkCreateTypefaceFromCTFont(
|
| + base::mac::NSToCFCast(font_with_style.GetNativeFont())));
|
| }
|
|
|
| } // namespace internal
|
| @@ -212,13 +214,9 @@ void RenderTextMac::DrawVisualText(internal::SkiaTextRenderer* renderer) {
|
| CTFontRef ct_font = static_cast<CTFontRef>(run.font.GetNativeFont());
|
| renderer->SetTextSize(CTFontGetSize(ct_font));
|
|
|
| - int font_style = Font::NORMAL;
|
| - CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ct_font);
|
| - if (traits & kCTFontBoldTrait)
|
| - font_style |= Font::BOLD;
|
| - if (traits & kCTFontItalicTrait)
|
| - font_style |= Font::ITALIC;
|
| - renderer->SetFontWithStyle(run.font, font_style);
|
| + // The painter adds its own ref. So don't |release()| it from the ref ptr in
|
| + // TextRun.
|
| + renderer->SetTypeface(run.typeface.get());
|
|
|
| renderer->DrawPosText(&run.glyph_positions[0], &run.glyphs[0],
|
| run.glyphs.size());
|
| @@ -417,6 +415,7 @@ void RenderTextMac::ComputeRuns() {
|
| CTFontRef ct_font = base::mac::GetValueFromDictionary<CTFontRef>(
|
| attributes, kCTFontAttributeName);
|
| run->font = Font(static_cast<NSFont*>(ct_font));
|
| + run->typeface.reset(SkCreateTypefaceFromCTFont(ct_font));
|
|
|
| const CGColorRef foreground = base::mac::GetValueFromDictionary<CGColorRef>(
|
| attributes, kCTForegroundColorAttributeName);
|
|
|