| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/ui/util/manual_text_framer.h" | 5 #include "ios/chrome/browser/ui/util/manual_text_framer.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #import "ios/chrome/browser/ui/util/core_text_util.h" | 9 #import "ios/chrome/browser/ui/util/core_text_util.h" |
| 10 #import "ios/chrome/browser/ui/util/text_frame.h" | 10 #import "ios/chrome/browser/ui/util/text_frame.h" |
| 11 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 11 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "testing/gtest_mac.h" | 13 #include "testing/gtest_mac.h" |
| 14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) | 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." | 18 #error "This file requires ARC support." |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 | 45 |
| 46 void FrameTextInBounds(CGRect bounds) { | 46 void FrameTextInBounds(CGRect bounds) { |
| 47 ManualTextFramer* manual_framer = | 47 ManualTextFramer* manual_framer = |
| 48 [[ManualTextFramer alloc] initWithString:string_ inBounds:bounds]; | 48 [[ManualTextFramer alloc] initWithString:string_ inBounds:bounds]; |
| 49 [manual_framer frameText]; | 49 [manual_framer frameText]; |
| 50 id frame = [manual_framer textFrame]; | 50 id frame = [manual_framer textFrame]; |
| 51 text_frame_ = frame; | 51 text_frame_ = frame; |
| 52 } | 52 } |
| 53 | 53 |
| 54 UIFont* RobotoFontWithSize(CGFloat size) { | 54 UIFont* RobotoFontWithSize(CGFloat size) { |
| 55 return [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:size]; | 55 return [[MDCTypography fontLoader] regularFontOfSize:size]; |
| 56 } | 56 } |
| 57 | 57 |
| 58 NSParagraphStyle* CreateParagraphStyle(CGFloat line_height, | 58 NSParagraphStyle* CreateParagraphStyle(CGFloat line_height, |
| 59 NSTextAlignment alignment, | 59 NSTextAlignment alignment, |
| 60 NSLineBreakMode line_break_mode) { | 60 NSLineBreakMode line_break_mode) { |
| 61 NSMutableParagraphStyle* style = [[NSMutableParagraphStyle alloc] init]; | 61 NSMutableParagraphStyle* style = [[NSMutableParagraphStyle alloc] init]; |
| 62 style.alignment = alignment; | 62 style.alignment = alignment; |
| 63 style.lineBreakMode = line_break_mode; | 63 style.lineBreakMode = line_break_mode; |
| 64 style.minimumLineHeight = line_height; | 64 style.minimumLineHeight = line_height; |
| 65 style.maximumLineHeight = line_height; | 65 style.maximumLineHeight = line_height; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 "\u062A\u0639\u0637\u064A\u0644\u0020\u0647\u0630\u0647\u0020\u0627" | 292 "\u062A\u0639\u0637\u064A\u0644\u0020\u0647\u0630\u0647\u0020\u0627" |
| 293 "\u0644\u062E\u062F\u0645\u0627\u062A\u002E"); | 293 "\u0644\u062E\u062F\u0645\u0627\u062A\u002E"); |
| 294 attributes()[NSFontAttributeName] = [UIFont systemFontOfSize:20.0]; | 294 attributes()[NSFontAttributeName] = [UIFont systemFontOfSize:20.0]; |
| 295 ApplyAttributesForRange(text_range()); | 295 ApplyAttributesForRange(text_range()); |
| 296 CGRect bounds = CGRectMake(0, 0, 500, 100); | 296 CGRect bounds = CGRectMake(0, 0, 500, 100); |
| 297 FrameTextInBounds(bounds); | 297 FrameTextInBounds(bounds); |
| 298 CheckForLineCountAndFramedRange(2, text_range()); | 298 CheckForLineCountAndFramedRange(2, text_range()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 } // namespace | 301 } // namespace |
| OLD | NEW |