Chromium Code Reviews| 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..377145ae9c99f1057e2c768e784c45432ace0ff9 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) { |
| + // TODO(mboc): This accepts style, not italic. |
|
msw
2016/03/25 01:33:10
You'll need to fix this before landing.
Mikus
2016/03/25 11:49:00
Done.
|
| + gfx::Font font_with_style = font.Derive(0, italic, weight); |
| if (!font_with_style.GetNativeFont()) |
| return nullptr; |
| return skia::AdoptRef(SkCreateTypefaceFromCTFont( |
| @@ -211,13 +214,15 @@ 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. |
| + bool italic = false; |
|
msw
2016/03/25 01:33:10
nit: inline the flag check into init (and move thi
Mikus
2016/03/25 11:49:00
Done.
|
| + Font::Weight font_weight = Font::Weight::NORMAL; |
| CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ct_font); |
| if (traits & kCTFontBoldTrait) |
| - font_style |= Font::BOLD; |
| + font_weight = Font::Weight::BOLD; |
| if (traits & kCTFontItalicTrait) |
| - font_style |= Font::ITALIC; |
| - renderer->SetFontWithStyle(run.font, font_style); |
| + italic = true; |
| + renderer->SetFont(run.font, italic, font_weight); |
| renderer->DrawPosText(&run.glyph_positions[0], &run.glyphs[0], |
| run.glyphs.size()); |
| @@ -308,7 +313,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 +333,8 @@ 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 below. |
|
msw
2016/03/25 01:33:10
You'll need to fix this before landing.
Mikus
2016/03/25 11:49:00
Done for Bold, the rest will be done in a followup
|
| + const int traits = (style.style(ITALIC) ? kCTFontItalicTrait : 0); |
| if (traits != 0) { |
| base::ScopedCFTypeRef<CTFontRef> styled_font = |
| CopyFontWithSymbolicTraits(font, traits); |