Index: ui/gfx/render_text_mac.mm |
diff --git a/ui/gfx/render_text_mac.mm b/ui/gfx/render_text_mac.mm |
index 3a6d01b9f3ad84bf581e59276e0670b11e6124be..3b4b2383432e6de1f77dde5aa1e44534c57418be 100644 |
--- a/ui/gfx/render_text_mac.mm |
+++ b/ui/gfx/render_text_mac.mm |
@@ -65,8 +65,11 @@ namespace gfx { |
namespace internal { |
-skia::RefPtr<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style) { |
- gfx::Font font_with_style = font.Derive(0, style); |
+skia::RefPtr<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, |
+ bool italic, |
+ gfx::Font::Weight weight) { |
+ const Font::FontStyle style = italic ? Font::ITALIC : Font::NORMAL; |
+ gfx::Font font_with_style = font.Derive(0, style, weight); |
if (!font_with_style.GetNativeFont()) |
return nullptr; |
return skia::AdoptRef(SkCreateTypefaceFromCTFont( |
@@ -211,13 +214,12 @@ 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; |
+ // TODO(mboc): Apply font weights. |
+ Font::Weight font_weight = Font::Weight::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); |
+ font_weight = Font::Weight::BOLD; |
+ renderer->SetFont(run.font, traits & kCTFontItalicTrait, font_weight); |
renderer->DrawPosText(&run.glyph_positions[0], &run.glyphs[0], |
run.glyphs.size()); |
@@ -308,7 +310,7 @@ base::ScopedCFTypeRef<CFMutableArrayRef> RenderTextMac::ApplyStyles( |
CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks)); |
// https://developer.apple.com/library/mac/#documentation/Carbon/Reference/CoreText_StringAttributes_Ref/Reference/reference.html |
- internal::StyleIterator style(colors(), baselines(), styles()); |
+ internal::StyleIterator style(colors(), baselines(), weights(), styles()); |
const size_t layout_text_length = CFAttributedStringGetLength(attr_string); |
for (size_t i = 0, end = 0; i < layout_text_length; i = end) { |
end = TextIndexToGivenTextIndex(text, style.GetRange().end()); |
@@ -328,8 +330,10 @@ base::ScopedCFTypeRef<CFMutableArrayRef> RenderTextMac::ApplyStyles( |
CFArrayAppendValue(attributes, underline_value); |
} |
- const int traits = (style.style(BOLD) ? kCTFontBoldTrait : 0) | |
- (style.style(ITALIC) ? kCTFontItalicTrait : 0); |
+ // TODO(mboc): Apply font weights other than bold below. |
+ const int traits = |
+ (style.style(ITALIC) ? kCTFontItalicTrait : 0) | |
+ (style.weight() >= Font::Weight::BOLD ? kCTFontBoldTrait : 0); |
if (traits != 0) { |
base::ScopedCFTypeRef<CTFontRef> styled_font = |
CopyFontWithSymbolicTraits(font, traits); |