OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/render_text_mac.h" | 5 #include "ui/gfx/render_text_mac.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
9 #include <CoreText/CoreText.h> | 9 #include <CoreText/CoreText.h> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "third_party/skia/include/ports/SkTypeface_mac.h" | 22 #include "third_party/skia/include/ports/SkTypeface_mac.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // This function makes a copy of |font| with the given symbolic traits. On OSX | 26 // This function makes a copy of |font| with the given symbolic traits. On OSX |
27 // 10.11, CTFontCreateCopyWithSymbolicTraits has the right behavior but | 27 // 10.11, CTFontCreateCopyWithSymbolicTraits has the right behavior but |
28 // CTFontCreateWithFontDescriptor does not. The opposite holds true for OSX | 28 // CTFontCreateWithFontDescriptor does not. The opposite holds true for OSX |
29 // 10.10. | 29 // 10.10. |
30 base::ScopedCFTypeRef<CTFontRef> CopyFontWithSymbolicTraits(CTFontRef font, | 30 base::ScopedCFTypeRef<CTFontRef> CopyFontWithSymbolicTraits(CTFontRef font, |
31 int sym_traits) { | 31 int sym_traits) { |
32 if (base::mac::IsOSElCapitanOrLater()) { | 32 if (base::mac::IsAtLeastOS10_11()) { |
33 return base::ScopedCFTypeRef<CTFontRef>(CTFontCreateCopyWithSymbolicTraits( | 33 return base::ScopedCFTypeRef<CTFontRef>(CTFontCreateCopyWithSymbolicTraits( |
34 font, 0, nullptr, sym_traits, sym_traits)); | 34 font, 0, nullptr, sym_traits, sym_traits)); |
35 } | 35 } |
36 | 36 |
37 base::ScopedCFTypeRef<CTFontDescriptorRef> orig_desc( | 37 base::ScopedCFTypeRef<CTFontDescriptorRef> orig_desc( |
38 CTFontCopyFontDescriptor(font)); | 38 CTFontCopyFontDescriptor(font)); |
39 base::ScopedCFTypeRef<CFDictionaryRef> orig_attributes( | 39 base::ScopedCFTypeRef<CFDictionaryRef> orig_attributes( |
40 CTFontDescriptorCopyAttributes(orig_desc)); | 40 CTFontDescriptorCopyAttributes(orig_desc)); |
41 // Make a mutable copy of orig_attributes. | 41 // Make a mutable copy of orig_attributes. |
42 base::ScopedCFTypeRef<CFMutableDictionaryRef> attributes( | 42 base::ScopedCFTypeRef<CFMutableDictionaryRef> attributes( |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 } | 442 } |
443 | 443 |
444 void RenderTextMac::InvalidateStyle() { | 444 void RenderTextMac::InvalidateStyle() { |
445 line_.reset(); | 445 line_.reset(); |
446 attributes_.reset(); | 446 attributes_.reset(); |
447 runs_.clear(); | 447 runs_.clear(); |
448 runs_valid_ = false; | 448 runs_valid_ = false; |
449 } | 449 } |
450 | 450 |
451 } // namespace gfx | 451 } // namespace gfx |
OLD | NEW |