Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Unified Diff: ui/gfx/render_text_mac.mm

Issue 1914443002: Revert of RenderTextMac: Cache the SkTypeface on the TextRun (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/render_text_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_mac.mm
diff --git a/ui/gfx/render_text_mac.mm b/ui/gfx/render_text_mac.mm
index 6a07f71a8ca39650837acf1e6d2905528cc7ac3f..f1c7299af209198be595064a33796efe5d70d5ee 100644
--- a/ui/gfx/render_text_mac.mm
+++ b/ui/gfx/render_text_mac.mm
@@ -64,6 +64,18 @@
namespace gfx {
+namespace internal {
+
+skia::RefPtr<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())));
+}
+
+} // namespace internal
+
RenderTextMac::RenderTextMac() : common_baseline_(0), runs_valid_(false) {}
RenderTextMac::~RenderTextMac() {}
@@ -200,9 +212,13 @@
CTFontRef ct_font = static_cast<CTFontRef>(run.font.GetNativeFont());
renderer->SetTextSize(CTFontGetSize(ct_font));
- // The painter adds its own ref. So don't |release()| it from the ref ptr in
- // TextRun.
- renderer->SetTypeface(run.typeface.get());
+ 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);
renderer->DrawPosText(&run.glyph_positions[0], &run.glyphs[0],
run.glyphs.size());
@@ -401,7 +417,6 @@
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);
« no previous file with comments | « ui/gfx/render_text_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698