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 584f08d49ea2e2ef6fba1ec6cd999b19c74a3f31..bc92812be89ffe5c3fefa1ea104df29dad3a8974 100644 |
| --- a/ui/gfx/render_text_mac.mm |
| +++ b/ui/gfx/render_text_mac.mm |
| @@ -66,9 +66,11 @@ namespace gfx { |
| namespace internal { |
| -// Note: this is only used by RenderTextHarfbuzz. |
|
tapted
2016/06/02 01:02:23
looks like this comment got lost while resolving m
Mikus
2016/06/02 10:35:20
Done.
|
| -sk_sp<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style) { |
| - gfx::Font font_with_style = font.Derive(0, style); |
| +sk_sp<SkTypeface> CreateSkiaTypeface(const Font& font, |
| + bool italic, |
| + Font::Weight weight) { |
| + const Font::FontStyle style = italic ? Font::ITALIC : Font::NORMAL; |
| + Font font_with_style = font.Derive(0, style, weight); |
| if (!font_with_style.GetNativeFont()) |
| return nullptr; |
| @@ -119,7 +121,7 @@ std::vector<RenderText::FontSpan> RenderTextMac::GetFontSpansForTesting() { |
| const CFRange cf_range = CTRunGetStringRange(runs_[i].ct_run); |
| const Range range(cf_range.location, cf_range.location + cf_range.length); |
| spans.push_back(RenderText::FontSpan( |
| - gfx::Font(base::mac::CFToNSCast(runs_[i].ct_font.get())), range)); |
| + Font(base::mac::CFToNSCast(runs_[i].ct_font.get())), range)); |
| } |
| return spans; |
| @@ -250,7 +252,7 @@ float RenderTextMac::GetLayoutTextWidth() { |
| return GetCTLineSize(line.get(), &baseline).width(); |
| } |
| -gfx::SizeF RenderTextMac::GetCTLineSize(CTLineRef line, SkScalar* baseline) { |
| +SizeF RenderTextMac::GetCTLineSize(CTLineRef line, SkScalar* baseline) { |
| CGFloat ascent = 0; |
| CGFloat descent = 0; |
| CGFloat leading = 0; |
| @@ -311,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()); |
| @@ -331,8 +333,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); |