├── .clang-format ├── .codecov.yml ├── .gitignore ├── .jazzy.yaml ├── .travis.yml ├── AUTHORS ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── MDFRobotoFontLoader.podspec ├── README.md ├── RELEASING.md ├── examples ├── RobotoFontLoaderSimpleExampleViewController.h ├── RobotoFontLoaderSimpleExampleViewController.m ├── RobotoVsSystemExampleViewController.m ├── WebViewExample.html ├── WebViewExampleViewController.h ├── WebViewExampleViewController.m ├── apps │ └── RobotoFontLoaderExample │ │ ├── Podfile │ │ ├── Podfile.lock │ │ ├── RobotoFontLoaderExample.xcodeproj │ │ └── project.pbxproj │ │ ├── RobotoFontLoaderExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── main.m │ │ └── RobotoFontLoaderExampleTests │ │ └── Info.plist └── resources │ └── RobotoVsSystem.storyboard ├── src ├── MDCTypographyAdditions │ ├── MDFRobotoFontLoader+MDCTypographyAdditions.h │ └── MDFRobotoFontLoader+MDCTypographyAdditions.m ├── MDFRobotoFontLoader.h ├── MDFRobotoFontLoader.m ├── MaterialRobotoFontLoader.bundle │ ├── Roboto-Black.ttf │ ├── Roboto-BlackItalic.ttf │ ├── Roboto-Bold.ttf │ ├── Roboto-BoldItalic.ttf │ ├── Roboto-Italic.ttf │ ├── Roboto-Light.ttf │ ├── Roboto-LightItalic.ttf │ ├── Roboto-Medium.ttf │ ├── Roboto-MediumItalic.ttf │ ├── Roboto-Regular.ttf │ ├── Roboto-Thin.ttf │ └── Roboto-ThinItalic.ttf └── MaterialRobotoFontLoader.h └── tests └── unit └── RobotoFontLoaderTests.m /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | 3 | AllowShortFunctionsOnASingleLine: Inline 4 | AllowShortIfStatementsOnASingleLine: false 5 | AllowShortLoopsOnASingleLine: false 6 | AlwaysBreakBeforeMultilineStrings: false 7 | BinPackParameters: false 8 | ColumnLimit: 0 9 | IndentWrappedFunctionNames: true 10 | ObjCSpaceBeforeProtocolList: true 11 | PointerBindsToType: false 12 | SortIncludes: true 13 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | ignore: 3 | - "examples/" 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Jazzy 2 | docs/ 3 | 4 | # Xcode 5 | # 6 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 7 | 8 | ## Build generated 9 | build/ 10 | DerivedData/ 11 | 12 | ## Various settings 13 | *.pbxuser 14 | !default.pbxuser 15 | *.mode1v3 16 | !default.mode1v3 17 | *.mode2v3 18 | !default.mode2v3 19 | *.perspectivev3 20 | !default.perspectivev3 21 | xcuserdata/ 22 | 23 | ## Other 24 | *.moved-aside 25 | *.xcuserstate 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | Pods/ 50 | *.xcworkspace 51 | 52 | # Carthage 53 | # 54 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 55 | # Carthage/Checkouts 56 | 57 | Carthage/Build 58 | 59 | # fastlane 60 | # 61 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 62 | # screenshots whenever they are needed. 63 | # For more information about the recommended setup visit: 64 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 65 | 66 | fastlane/report.xml 67 | fastlane/Preview.html 68 | fastlane/screenshots 69 | fastlane/test_output 70 | -------------------------------------------------------------------------------- /.jazzy.yaml: -------------------------------------------------------------------------------- 1 | module: MaterialFoundationRobotoFontLoader 2 | module_version: 1.0.0 3 | umbrella_header: src/MaterialFoundationRobotoFontLoader.h 4 | objc: true 5 | sdk: iphonesimulator 6 | github_url: https://github.com/material-foundation/material-roboto-font-loader-ios 7 | github_file_prefix: https://github.com/material-foundation/material-roboto-font-loader-ios/tree/v1.0.0 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8.1 3 | sudo: false 4 | notifications: 5 | email: false 6 | before_install: 7 | - gem install cocoapods --no-rdoc --no-ri --no-document --quiet 8 | - git clone https://github.com/phacility/arcanist.git 9 | - git clone https://github.com/phacility/libphutil.git 10 | - git clone --recursive https://github.com/material-foundation/material-arc-tools.git 11 | - pod install --repo-update 12 | script: 13 | - set -o pipefail 14 | - arcanist/bin/arc unit --everything --trace 15 | - xcodebuild build -workspace MaterialFoundationRobotoFontLoader.xcworkspace -scheme Catalog -sdk "iphonesimulator10.1" -destination "name=iPhone 6s,OS=10.1" ONLY_ACTIVE_ARCH=YES | xcpretty -c; 16 | after_success: 17 | - bash <(curl -s https://codecov.io/bash) 18 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the list of MDFRobotoFontLoader authors for copyright purposes. 2 | # 3 | # This does not necessarily list everyone who has contributed code, since in 4 | # some cases, their employer may be the copyright holder. To see the full list 5 | # of contributors, see the revision history with git log. 6 | 7 | Google Inc. 8 | and other contributors 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.3.0 2 | 3 | * Added API: Instance methods for getting bold and italic fonts from another font. 4 | 5 | # 1.2.0 6 | 7 | * Added API: isLargeForContrastRatio: so that medium can be considered large at 14pt size. 8 | 9 | # 1.1.3 10 | 11 | * Corrected import paths again because `pod lib lint --use-libraries` passes. 12 | 13 | # 1.1.2 14 | 15 | * Added example for Roboto use in UIWebViews 16 | 17 | # 1.1.1 18 | 19 | * Corrected import path to pass `pod lib lint` 20 | 21 | # 1.1.0 22 | 23 | ## API changes 24 | 25 | * Added class methods to determine if a font is italic or bold. 26 | * Added a subspec for MDCTypography protocol compatibility. 27 | 28 | # 1.0.0 29 | 30 | Initial release. 31 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including the small print at 2 | the end). 3 | 4 | ### Before you contribute 5 | 6 | Before we can use your code, you must sign the 7 | [Google Individual Contributor License Agreement] 8 | (https://cla.developers.google.com/about/google-individual) 9 | (CLA), which you can do online. The CLA is necessary mainly because you own the 10 | copyright to your changes, even after your contribution becomes part of our 11 | codebase, so we need your permission to use and distribute your code. We also 12 | need to be sure of various other things—for instance that you'll tell us if you 13 | know that your code infringes on other people's patents. You don't have to sign 14 | the CLA until after you've submitted your code for review and a member has 15 | approved it, but you must do it before we can put your code into our codebase. 16 | Before you start working on a larger contribution, you should get in touch with 17 | us first through the issue tracker with your idea so that we can help out and 18 | possibly guide you. Coordinating up front makes it much easier to avoid 19 | frustration later on. 20 | 21 | ### Code reviews 22 | 23 | All submissions, including submissions by project members, require review. 24 | We use GitHub pull requests for this purpose. 25 | 26 | ### The small print 27 | 28 | Contributions made by corporations are covered by a different agreement than 29 | the one above, the 30 | [Software Grant and Corporate Contributor License Agreement] 31 | (https://cla.developers.google.com/about/google-corporate). 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /MDFRobotoFontLoader.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "MDFRobotoFontLoader" 3 | s.summary = "MDFRobotoFontLoader" 4 | s.version = "1.3.0" 5 | s.authors = "The Material Foundation Authors" 6 | s.license = "Apache 2.0" 7 | s.homepage = "https://github.com/material-foundation/material-roboto-font-loader-ios" 8 | s.source = { :git => "https://github.com/material-foundation/material-roboto-font-loader-ios.git", :tag => "v" + s.version.to_s } 9 | s.platform = :ios, "7.0" 10 | s.requires_arc = true 11 | s.default_subspec = "RobotoFontLoader" 12 | 13 | s.subspec "RobotoFontLoader" do |ss| 14 | ss.public_header_files = "src/*.h" 15 | ss.source_files = "src/*.{h,m,mm}", "src/private/*.{h,m,mm}" 16 | ss.resources = ["src/MaterialRobotoFontLoader.bundle"] 17 | ss.dependency 'MDFFontDiskLoader' 18 | end 19 | 20 | s.subspec "MDCTypographyAdditions" do |ss| 21 | ss.public_header_files = "src/MDCTypographyAdditions/*.h" 22 | ss.source_files = "src/MDCTypographyAdditions/*.{h,m,mm}", "src/MDCTypographyAdditions/private/*.{h,m,mm}" 23 | ss.dependency 'MDFRobotoFontLoader/RobotoFontLoader' 24 | ss.dependency 'MaterialComponents/Typography' 25 | end 26 | 27 | end 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Roboto Font Loader 2 | 3 | The Roboto Font Loader lazy loads the Roboto font. 4 | 5 | ### Material Design Specifications 6 | 7 | 19 | 20 | ## Installation 21 | 22 | ### Requirements 23 | 24 | - Xcode 7.0 or higher. 25 | - iOS SDK version 7.0 or higher. 26 | 27 | ### Installation with CocoaPods 28 | 29 | To add this component to your Xcode project using CocoaPods, add the following to your `Podfile`: 30 | 31 | ``` 32 | pod 'MDFRobotoFontLoader' 33 | ``` 34 | 35 | Then, run the following command: 36 | 37 | ~~~ bash 38 | pod install 39 | ~~~ 40 | 41 | ## Usage 42 | 43 | The Roboto Font Loader provides APIs for getting the Roboto Fonts. Consider using the 44 | Typography Material Component for iOS font styles recommended by Material spec. 45 | 46 | ### Importing 47 | 48 | Before using Roboto Font Loader, you'll need to import it: 49 | 50 | 51 | #### Objective-C 52 | 53 | ~~~ objc 54 | #import "MaterialRobotoFontLoader.h" 55 | ~~~ 56 | 57 | #### Swift 58 | ~~~ swift 59 | import MDFRobotoFontLoader 60 | ~~~ 61 | 62 | 63 | ### Dependencies 64 | 65 | The Roboto Font Loader Component depends on the FontDiskLoader Component. 66 | 67 | 68 | #### Objective-C 69 | ~~~ objc 70 | UIFont *font = [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]; 71 | ~~~ 72 | 73 | #### Swift 74 | ~~~ swift 75 | let myFont:UIFont = MDFRobotoFontLoader.sharedInstance()regularFontOfSize(16) 76 | ~~~ 77 | 78 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | ## Publish the official release 2 | 3 | 1. Have all release-blocking clients given the go-ahead? **Do not create the official release until 4 | all release-blocking clients are ready**. Otherwise you might publish a release that isn't 5 | actually stable. 6 | 1. Visit our 7 | [GitHub list of releases](releases), click on 8 | "Draft a new release". 9 | 1. Tag the release "vX.Y.Z". 10 | 1. Select the stable branch. 11 | 1. Title the release "Release X.Y.Z". 12 | 1. In the body of the release notes, paste the text from [CHANGELOG.md](CHANGELOG.md) for this release. 13 | 1. Publish the release. 14 | 15 | ## Publish to Cocoapods 16 | 17 | pod trunk push --use-libraries 18 | -------------------------------------------------------------------------------- /examples/RobotoFontLoaderSimpleExampleViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface RobotoFontLoaderSimpleExampleViewController : UIViewController 20 | @end 21 | -------------------------------------------------------------------------------- /examples/RobotoFontLoaderSimpleExampleViewController.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import "RobotoFontLoaderSimpleExampleViewController.h" 18 | #import "MaterialRobotoFontLoader.h" 19 | 20 | @implementation RobotoFontLoaderSimpleExampleViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view, typically from a nib. 25 | self.view.backgroundColor = [UIColor whiteColor]; 26 | UIViewAutoresizing flexibleMargins = 27 | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | 28 | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 29 | 30 | // Consider using the named styles provided by the Typography component instead of specific font 31 | // sizes. See https://github.com/material-components/material-components-ios/tree/develop/components/Typography 32 | UILabel *label = [[UILabel alloc] init]; 33 | label.text = @"This is Roboto regular 16"; 34 | label.font = [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]; 35 | 36 | [label sizeToFit]; 37 | label.autoresizingMask = flexibleMargins; 38 | label.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds)); 39 | [self.view addSubview:label]; 40 | } 41 | 42 | + (NSArray *)catalogBreadcrumbs { 43 | return @[ @"Typography and Fonts", @"Roboto Font Loader" ]; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /examples/RobotoVsSystemExampleViewController.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | #import "MaterialRobotoFontLoader.h" 20 | 21 | @interface RobotoVsSystemExampleViewController : UIViewController 22 | @property(weak, nonatomic) IBOutlet UILabel *robotoLabel; 23 | @end 24 | 25 | @implementation RobotoVsSystemExampleViewController 26 | 27 | - (void)viewDidLoad { 28 | [super viewDidLoad]; 29 | // Do any additional setup after loading the view, typically from a nib. 30 | self.view.backgroundColor = [UIColor whiteColor]; 31 | 32 | _robotoLabel.font = 33 | [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:_robotoLabel.font.pointSize]; 34 | } 35 | 36 | + (NSArray *)catalogBreadcrumbs { 37 | return @[ @"Typography and Fonts", @"Roboto vs System" ]; 38 | } 39 | 40 | + (NSString *)catalogStoryboardName { 41 | return @"RobotoVsSystem"; 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /examples/WebViewExample.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | This is italic and this is bold and this is some unicode: э 14 | 15 | -------------------------------------------------------------------------------- /examples/WebViewExampleViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface WebViewExampleViewController : UIViewController 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /examples/WebViewExampleViewController.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import "WebViewExampleViewController.h" 18 | #import "MaterialRobotoFontLoader.h" 19 | 20 | @implementation WebViewExampleViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | // Do any additional setup after loading the view, typically from a nib. 25 | self.view.backgroundColor = [UIColor whiteColor]; 26 | UIViewAutoresizing flexibleMargins = 27 | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | 28 | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 29 | 30 | NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"WebViewExample" ofType:@"html"]; 31 | NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile 32 | encoding:NSUTF8StringEncoding error:nil]; 33 | 34 | // This ensures that Roboto has been loaded and only needs to be called once. 35 | [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]; 36 | 37 | UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; 38 | webView.autoresizingMask = flexibleMargins; 39 | [webView loadHTMLString:htmlString baseURL: [[NSBundle mainBundle] bundleURL]]; 40 | [self.view addSubview:webView]; 41 | } 42 | 43 | 44 | + (NSArray *)catalogBreadcrumbs { 45 | return @[ @"Typography and Fonts", @"UIWebView (local roboto)" ]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target "RobotoFontLoaderExample" do 4 | pod 'MDFRobotoFontLoader', :path => '../../../' 5 | pod 'MDFRobotoFontLoader/MDCTypographyAdditions', :path => '../../../' 6 | pod 'CatalogByConvention' 7 | 8 | target 'RobotoFontLoaderExampleTests' do 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CatalogByConvention (2.0.0) 3 | - MaterialComponents/Typography (19.0.4) 4 | - MDFFontDiskLoader (1.0.0) 5 | - MDFRobotoFontLoader (1.3.0): 6 | - MDFRobotoFontLoader/RobotoFontLoader (= 1.3.0) 7 | - MDFRobotoFontLoader/MDCTypographyAdditions (1.3.0): 8 | - MaterialComponents/Typography 9 | - MDFRobotoFontLoader/RobotoFontLoader 10 | - MDFRobotoFontLoader/RobotoFontLoader (1.3.0): 11 | - MDFFontDiskLoader 12 | 13 | DEPENDENCIES: 14 | - CatalogByConvention 15 | - MDFRobotoFontLoader (from `../../../`) 16 | - MDFRobotoFontLoader/MDCTypographyAdditions (from `../../../`) 17 | 18 | EXTERNAL SOURCES: 19 | MDFRobotoFontLoader: 20 | :path: "../../../" 21 | 22 | SPEC CHECKSUMS: 23 | CatalogByConvention: be55c2263132e4f9f59299ac8a528ee8715b3275 24 | MaterialComponents: bd2bbd4e8631c6a560100848c7d2a864e61b6716 25 | MDFFontDiskLoader: 95d6c92c644f24897dee5a860973b0da4d9a1ce4 26 | MDFRobotoFontLoader: 148559b202f4b67e3670f6a7c707e7b0626b1e5d 27 | 28 | PODFILE CHECKSUM: 97c787a870cd8a25dc21de6af6e774b386b1683d 29 | 30 | COCOAPODS: 1.1.1 31 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 2070DBAA1E1D73C6000A4313 /* WebViewExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2070DBA91E1D73C6000A4313 /* WebViewExampleViewController.m */; }; 11 | 2070DBAC1E1D75F1000A4313 /* WebViewExample.html in Resources */ = {isa = PBXBuildFile; fileRef = 2070DBAB1E1D75F1000A4313 /* WebViewExample.html */; }; 12 | 20BB4D3E1DEE191500838A41 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 20BB4D3D1DEE191500838A41 /* main.m */; }; 13 | 20BB4D411DEE191500838A41 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 20BB4D401DEE191500838A41 /* AppDelegate.m */; }; 14 | 20BB4D471DEE191500838A41 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 20BB4D451DEE191500838A41 /* Main.storyboard */; }; 15 | 20BB4D491DEE191500838A41 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 20BB4D481DEE191500838A41 /* Assets.xcassets */; }; 16 | 20BB4D4C1DEE191500838A41 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 20BB4D4A1DEE191500838A41 /* LaunchScreen.storyboard */; }; 17 | 20BB4D621DEE26C000838A41 /* RobotoFontLoaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 20BB4D611DEE26C000838A41 /* RobotoFontLoaderTests.m */; }; 18 | 20BB4D661DEE292400838A41 /* RobotoFontLoaderSimpleExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 20BB4D641DEE292400838A41 /* RobotoFontLoaderSimpleExampleViewController.m */; }; 19 | 20BB4D671DEE292400838A41 /* RobotoVsSystemExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 20BB4D651DEE292400838A41 /* RobotoVsSystemExampleViewController.m */; }; 20 | 20BB4D691DEE292A00838A41 /* RobotoVsSystem.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 20BB4D681DEE292A00838A41 /* RobotoVsSystem.storyboard */; }; 21 | 89EBBF13EFCF114308937390 /* Pods_RobotoFontLoaderExample_RobotoFontLoaderExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 563789189B80E7CD41322690 /* Pods_RobotoFontLoaderExample_RobotoFontLoaderExampleTests.framework */; }; 22 | C2EF2AC79EFC0FB9768D0AB7 /* Pods_RobotoFontLoaderExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3042090B945117CDA6AAAEAA /* Pods_RobotoFontLoaderExample.framework */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | 20BB4D531DEE191500838A41 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = 20BB4D311DEE191500838A41 /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 20BB4D381DEE191500838A41; 31 | remoteInfo = RobotoFontLoaderExample; 32 | }; 33 | /* End PBXContainerItemProxy section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | 2070DBA81E1D73C6000A4313 /* WebViewExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebViewExampleViewController.h; path = ../../../WebViewExampleViewController.h; sourceTree = ""; }; 37 | 2070DBA91E1D73C6000A4313 /* WebViewExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WebViewExampleViewController.m; path = ../../../WebViewExampleViewController.m; sourceTree = ""; }; 38 | 2070DBAB1E1D75F1000A4313 /* WebViewExample.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = WebViewExample.html; path = ../../../WebViewExample.html; sourceTree = ""; }; 39 | 20BB4D391DEE191500838A41 /* RobotoFontLoaderExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RobotoFontLoaderExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 20BB4D3D1DEE191500838A41 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | 20BB4D3F1DEE191500838A41 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | 20BB4D401DEE191500838A41 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | 20BB4D461DEE191500838A41 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 44 | 20BB4D481DEE191500838A41 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 45 | 20BB4D4B1DEE191500838A41 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 46 | 20BB4D4D1DEE191500838A41 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | 20BB4D521DEE191500838A41 /* RobotoFontLoaderExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RobotoFontLoaderExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 20BB4D581DEE191500838A41 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 20BB4D611DEE26C000838A41 /* RobotoFontLoaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RobotoFontLoaderTests.m; path = ../../../../tests/unit/RobotoFontLoaderTests.m; sourceTree = ""; }; 50 | 20BB4D631DEE292400838A41 /* RobotoFontLoaderSimpleExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RobotoFontLoaderSimpleExampleViewController.h; path = ../../../RobotoFontLoaderSimpleExampleViewController.h; sourceTree = ""; }; 51 | 20BB4D641DEE292400838A41 /* RobotoFontLoaderSimpleExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RobotoFontLoaderSimpleExampleViewController.m; path = ../../../RobotoFontLoaderSimpleExampleViewController.m; sourceTree = ""; }; 52 | 20BB4D651DEE292400838A41 /* RobotoVsSystemExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RobotoVsSystemExampleViewController.m; path = ../../../RobotoVsSystemExampleViewController.m; sourceTree = ""; }; 53 | 20BB4D681DEE292A00838A41 /* RobotoVsSystem.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = RobotoVsSystem.storyboard; path = ../../../resources/RobotoVsSystem.storyboard; sourceTree = ""; }; 54 | 3042090B945117CDA6AAAEAA /* Pods_RobotoFontLoaderExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RobotoFontLoaderExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 563789189B80E7CD41322690 /* Pods_RobotoFontLoaderExample_RobotoFontLoaderExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RobotoFontLoaderExample_RobotoFontLoaderExampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | 591BBC13F7D71A42B6E9CE0F /* Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests/Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.debug.xcconfig"; sourceTree = ""; }; 57 | 87BE723A4A8621845880FBE6 /* Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests/Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.release.xcconfig"; sourceTree = ""; }; 58 | CD44B0EEB67BC2FBF1920605 /* Pods-RobotoFontLoaderExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RobotoFontLoaderExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RobotoFontLoaderExample/Pods-RobotoFontLoaderExample.debug.xcconfig"; sourceTree = ""; }; 59 | E79A0B6A2D2A7D4F3038A5F1 /* Pods-RobotoFontLoaderExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RobotoFontLoaderExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-RobotoFontLoaderExample/Pods-RobotoFontLoaderExample.release.xcconfig"; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 20BB4D361DEE191500838A41 /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | C2EF2AC79EFC0FB9768D0AB7 /* Pods_RobotoFontLoaderExample.framework in Frameworks */, 68 | ); 69 | runOnlyForDeploymentPostprocessing = 0; 70 | }; 71 | 20BB4D4F1DEE191500838A41 /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | 89EBBF13EFCF114308937390 /* Pods_RobotoFontLoaderExample_RobotoFontLoaderExampleTests.framework in Frameworks */, 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | /* End PBXFrameworksBuildPhase section */ 80 | 81 | /* Begin PBXGroup section */ 82 | 01B048719B257207A0D7406F /* Frameworks */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 3042090B945117CDA6AAAEAA /* Pods_RobotoFontLoaderExample.framework */, 86 | 563789189B80E7CD41322690 /* Pods_RobotoFontLoaderExample_RobotoFontLoaderExampleTests.framework */, 87 | ); 88 | name = Frameworks; 89 | sourceTree = ""; 90 | }; 91 | 20BB4D301DEE191500838A41 = { 92 | isa = PBXGroup; 93 | children = ( 94 | 20BB4D3B1DEE191500838A41 /* RobotoFontLoaderExample */, 95 | 20BB4D551DEE191500838A41 /* RobotoFontLoaderExampleTests */, 96 | 20BB4D3A1DEE191500838A41 /* Products */, 97 | 9B4C7DB5B45C7F9A49D4B73F /* Pods */, 98 | 01B048719B257207A0D7406F /* Frameworks */, 99 | ); 100 | sourceTree = ""; 101 | }; 102 | 20BB4D3A1DEE191500838A41 /* Products */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 20BB4D391DEE191500838A41 /* RobotoFontLoaderExample.app */, 106 | 20BB4D521DEE191500838A41 /* RobotoFontLoaderExampleTests.xctest */, 107 | ); 108 | name = Products; 109 | sourceTree = ""; 110 | }; 111 | 20BB4D3B1DEE191500838A41 /* RobotoFontLoaderExample */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | 20BB4D3F1DEE191500838A41 /* AppDelegate.h */, 115 | 20BB4D401DEE191500838A41 /* AppDelegate.m */, 116 | 20BB4D681DEE292A00838A41 /* RobotoVsSystem.storyboard */, 117 | 20BB4D631DEE292400838A41 /* RobotoFontLoaderSimpleExampleViewController.h */, 118 | 20BB4D641DEE292400838A41 /* RobotoFontLoaderSimpleExampleViewController.m */, 119 | 20BB4D651DEE292400838A41 /* RobotoVsSystemExampleViewController.m */, 120 | 20BB4D451DEE191500838A41 /* Main.storyboard */, 121 | 20BB4D481DEE191500838A41 /* Assets.xcassets */, 122 | 20BB4D4A1DEE191500838A41 /* LaunchScreen.storyboard */, 123 | 20BB4D4D1DEE191500838A41 /* Info.plist */, 124 | 20BB4D3C1DEE191500838A41 /* Supporting Files */, 125 | 2070DBA81E1D73C6000A4313 /* WebViewExampleViewController.h */, 126 | 2070DBA91E1D73C6000A4313 /* WebViewExampleViewController.m */, 127 | 2070DBAB1E1D75F1000A4313 /* WebViewExample.html */, 128 | ); 129 | path = RobotoFontLoaderExample; 130 | sourceTree = ""; 131 | }; 132 | 20BB4D3C1DEE191500838A41 /* Supporting Files */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 20BB4D3D1DEE191500838A41 /* main.m */, 136 | ); 137 | name = "Supporting Files"; 138 | sourceTree = ""; 139 | }; 140 | 20BB4D551DEE191500838A41 /* RobotoFontLoaderExampleTests */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | 20BB4D611DEE26C000838A41 /* RobotoFontLoaderTests.m */, 144 | 20BB4D581DEE191500838A41 /* Info.plist */, 145 | ); 146 | path = RobotoFontLoaderExampleTests; 147 | sourceTree = ""; 148 | }; 149 | 9B4C7DB5B45C7F9A49D4B73F /* Pods */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | CD44B0EEB67BC2FBF1920605 /* Pods-RobotoFontLoaderExample.debug.xcconfig */, 153 | E79A0B6A2D2A7D4F3038A5F1 /* Pods-RobotoFontLoaderExample.release.xcconfig */, 154 | 591BBC13F7D71A42B6E9CE0F /* Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.debug.xcconfig */, 155 | 87BE723A4A8621845880FBE6 /* Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.release.xcconfig */, 156 | ); 157 | name = Pods; 158 | sourceTree = ""; 159 | }; 160 | /* End PBXGroup section */ 161 | 162 | /* Begin PBXNativeTarget section */ 163 | 20BB4D381DEE191500838A41 /* RobotoFontLoaderExample */ = { 164 | isa = PBXNativeTarget; 165 | buildConfigurationList = 20BB4D5B1DEE191500838A41 /* Build configuration list for PBXNativeTarget "RobotoFontLoaderExample" */; 166 | buildPhases = ( 167 | 3C33FA37846D03A5826BE09E /* [CP] Check Pods Manifest.lock */, 168 | 20BB4D351DEE191500838A41 /* Sources */, 169 | 20BB4D361DEE191500838A41 /* Frameworks */, 170 | 20BB4D371DEE191500838A41 /* Resources */, 171 | 3E7B3F2DA631F2D65D429269 /* [CP] Embed Pods Frameworks */, 172 | 91193DE5F7471862D7DCD424 /* [CP] Copy Pods Resources */, 173 | ); 174 | buildRules = ( 175 | ); 176 | dependencies = ( 177 | ); 178 | name = RobotoFontLoaderExample; 179 | productName = RobotoFontLoaderExample; 180 | productReference = 20BB4D391DEE191500838A41 /* RobotoFontLoaderExample.app */; 181 | productType = "com.apple.product-type.application"; 182 | }; 183 | 20BB4D511DEE191500838A41 /* RobotoFontLoaderExampleTests */ = { 184 | isa = PBXNativeTarget; 185 | buildConfigurationList = 20BB4D5E1DEE191500838A41 /* Build configuration list for PBXNativeTarget "RobotoFontLoaderExampleTests" */; 186 | buildPhases = ( 187 | E55C9DFFF62B80F441BD955C /* [CP] Check Pods Manifest.lock */, 188 | 20BB4D4E1DEE191500838A41 /* Sources */, 189 | 20BB4D4F1DEE191500838A41 /* Frameworks */, 190 | 20BB4D501DEE191500838A41 /* Resources */, 191 | BDA3C8A16F3EDA64B86DD974 /* [CP] Embed Pods Frameworks */, 192 | 10384E8BF02E0084AECA49F8 /* [CP] Copy Pods Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | 20BB4D541DEE191500838A41 /* PBXTargetDependency */, 198 | ); 199 | name = RobotoFontLoaderExampleTests; 200 | productName = RobotoFontLoaderExampleTests; 201 | productReference = 20BB4D521DEE191500838A41 /* RobotoFontLoaderExampleTests.xctest */; 202 | productType = "com.apple.product-type.bundle.unit-test"; 203 | }; 204 | /* End PBXNativeTarget section */ 205 | 206 | /* Begin PBXProject section */ 207 | 20BB4D311DEE191500838A41 /* Project object */ = { 208 | isa = PBXProject; 209 | attributes = { 210 | LastUpgradeCheck = 0800; 211 | ORGANIZATIONNAME = "Randall Li"; 212 | TargetAttributes = { 213 | 20BB4D381DEE191500838A41 = { 214 | CreatedOnToolsVersion = 8.0; 215 | ProvisioningStyle = Automatic; 216 | }; 217 | 20BB4D511DEE191500838A41 = { 218 | CreatedOnToolsVersion = 8.0; 219 | ProvisioningStyle = Automatic; 220 | TestTargetID = 20BB4D381DEE191500838A41; 221 | }; 222 | }; 223 | }; 224 | buildConfigurationList = 20BB4D341DEE191500838A41 /* Build configuration list for PBXProject "RobotoFontLoaderExample" */; 225 | compatibilityVersion = "Xcode 3.2"; 226 | developmentRegion = English; 227 | hasScannedForEncodings = 0; 228 | knownRegions = ( 229 | en, 230 | Base, 231 | ); 232 | mainGroup = 20BB4D301DEE191500838A41; 233 | productRefGroup = 20BB4D3A1DEE191500838A41 /* Products */; 234 | projectDirPath = ""; 235 | projectRoot = ""; 236 | targets = ( 237 | 20BB4D381DEE191500838A41 /* RobotoFontLoaderExample */, 238 | 20BB4D511DEE191500838A41 /* RobotoFontLoaderExampleTests */, 239 | ); 240 | }; 241 | /* End PBXProject section */ 242 | 243 | /* Begin PBXResourcesBuildPhase section */ 244 | 20BB4D371DEE191500838A41 /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | 2070DBAC1E1D75F1000A4313 /* WebViewExample.html in Resources */, 249 | 20BB4D4C1DEE191500838A41 /* LaunchScreen.storyboard in Resources */, 250 | 20BB4D491DEE191500838A41 /* Assets.xcassets in Resources */, 251 | 20BB4D471DEE191500838A41 /* Main.storyboard in Resources */, 252 | 20BB4D691DEE292A00838A41 /* RobotoVsSystem.storyboard in Resources */, 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | 20BB4D501DEE191500838A41 /* Resources */ = { 257 | isa = PBXResourcesBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXResourcesBuildPhase section */ 264 | 265 | /* Begin PBXShellScriptBuildPhase section */ 266 | 10384E8BF02E0084AECA49F8 /* [CP] Copy Pods Resources */ = { 267 | isa = PBXShellScriptBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | ); 271 | inputPaths = ( 272 | ); 273 | name = "[CP] Copy Pods Resources"; 274 | outputPaths = ( 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | shellPath = /bin/sh; 278 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests/Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests-resources.sh\"\n"; 279 | showEnvVarsInLog = 0; 280 | }; 281 | 3C33FA37846D03A5826BE09E /* [CP] Check Pods Manifest.lock */ = { 282 | isa = PBXShellScriptBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | ); 286 | inputPaths = ( 287 | ); 288 | name = "[CP] Check Pods Manifest.lock"; 289 | outputPaths = ( 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | shellPath = /bin/sh; 293 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 294 | showEnvVarsInLog = 0; 295 | }; 296 | 3E7B3F2DA631F2D65D429269 /* [CP] Embed Pods Frameworks */ = { 297 | isa = PBXShellScriptBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | ); 301 | inputPaths = ( 302 | ); 303 | name = "[CP] Embed Pods Frameworks"; 304 | outputPaths = ( 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | shellPath = /bin/sh; 308 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RobotoFontLoaderExample/Pods-RobotoFontLoaderExample-frameworks.sh\"\n"; 309 | showEnvVarsInLog = 0; 310 | }; 311 | 91193DE5F7471862D7DCD424 /* [CP] Copy Pods Resources */ = { 312 | isa = PBXShellScriptBuildPhase; 313 | buildActionMask = 2147483647; 314 | files = ( 315 | ); 316 | inputPaths = ( 317 | ); 318 | name = "[CP] Copy Pods Resources"; 319 | outputPaths = ( 320 | ); 321 | runOnlyForDeploymentPostprocessing = 0; 322 | shellPath = /bin/sh; 323 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RobotoFontLoaderExample/Pods-RobotoFontLoaderExample-resources.sh\"\n"; 324 | showEnvVarsInLog = 0; 325 | }; 326 | BDA3C8A16F3EDA64B86DD974 /* [CP] Embed Pods Frameworks */ = { 327 | isa = PBXShellScriptBuildPhase; 328 | buildActionMask = 2147483647; 329 | files = ( 330 | ); 331 | inputPaths = ( 332 | ); 333 | name = "[CP] Embed Pods Frameworks"; 334 | outputPaths = ( 335 | ); 336 | runOnlyForDeploymentPostprocessing = 0; 337 | shellPath = /bin/sh; 338 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests/Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests-frameworks.sh\"\n"; 339 | showEnvVarsInLog = 0; 340 | }; 341 | E55C9DFFF62B80F441BD955C /* [CP] Check Pods Manifest.lock */ = { 342 | isa = PBXShellScriptBuildPhase; 343 | buildActionMask = 2147483647; 344 | files = ( 345 | ); 346 | inputPaths = ( 347 | ); 348 | name = "[CP] Check Pods Manifest.lock"; 349 | outputPaths = ( 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | shellPath = /bin/sh; 353 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 354 | showEnvVarsInLog = 0; 355 | }; 356 | /* End PBXShellScriptBuildPhase section */ 357 | 358 | /* Begin PBXSourcesBuildPhase section */ 359 | 20BB4D351DEE191500838A41 /* Sources */ = { 360 | isa = PBXSourcesBuildPhase; 361 | buildActionMask = 2147483647; 362 | files = ( 363 | 20BB4D661DEE292400838A41 /* RobotoFontLoaderSimpleExampleViewController.m in Sources */, 364 | 20BB4D671DEE292400838A41 /* RobotoVsSystemExampleViewController.m in Sources */, 365 | 20BB4D411DEE191500838A41 /* AppDelegate.m in Sources */, 366 | 20BB4D3E1DEE191500838A41 /* main.m in Sources */, 367 | 2070DBAA1E1D73C6000A4313 /* WebViewExampleViewController.m in Sources */, 368 | ); 369 | runOnlyForDeploymentPostprocessing = 0; 370 | }; 371 | 20BB4D4E1DEE191500838A41 /* Sources */ = { 372 | isa = PBXSourcesBuildPhase; 373 | buildActionMask = 2147483647; 374 | files = ( 375 | 20BB4D621DEE26C000838A41 /* RobotoFontLoaderTests.m in Sources */, 376 | ); 377 | runOnlyForDeploymentPostprocessing = 0; 378 | }; 379 | /* End PBXSourcesBuildPhase section */ 380 | 381 | /* Begin PBXTargetDependency section */ 382 | 20BB4D541DEE191500838A41 /* PBXTargetDependency */ = { 383 | isa = PBXTargetDependency; 384 | target = 20BB4D381DEE191500838A41 /* RobotoFontLoaderExample */; 385 | targetProxy = 20BB4D531DEE191500838A41 /* PBXContainerItemProxy */; 386 | }; 387 | /* End PBXTargetDependency section */ 388 | 389 | /* Begin PBXVariantGroup section */ 390 | 20BB4D451DEE191500838A41 /* Main.storyboard */ = { 391 | isa = PBXVariantGroup; 392 | children = ( 393 | 20BB4D461DEE191500838A41 /* Base */, 394 | ); 395 | name = Main.storyboard; 396 | sourceTree = ""; 397 | }; 398 | 20BB4D4A1DEE191500838A41 /* LaunchScreen.storyboard */ = { 399 | isa = PBXVariantGroup; 400 | children = ( 401 | 20BB4D4B1DEE191500838A41 /* Base */, 402 | ); 403 | name = LaunchScreen.storyboard; 404 | sourceTree = ""; 405 | }; 406 | /* End PBXVariantGroup section */ 407 | 408 | /* Begin XCBuildConfiguration section */ 409 | 20BB4D591DEE191500838A41 /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ALWAYS_SEARCH_USER_PATHS = NO; 413 | CLANG_ANALYZER_NONNULL = YES; 414 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 415 | CLANG_CXX_LIBRARY = "libc++"; 416 | CLANG_ENABLE_MODULES = YES; 417 | CLANG_ENABLE_OBJC_ARC = YES; 418 | CLANG_WARN_BOOL_CONVERSION = YES; 419 | CLANG_WARN_CONSTANT_CONVERSION = YES; 420 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 421 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 422 | CLANG_WARN_EMPTY_BODY = YES; 423 | CLANG_WARN_ENUM_CONVERSION = YES; 424 | CLANG_WARN_INFINITE_RECURSION = YES; 425 | CLANG_WARN_INT_CONVERSION = YES; 426 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 427 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 428 | CLANG_WARN_UNREACHABLE_CODE = YES; 429 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 430 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 431 | COPY_PHASE_STRIP = NO; 432 | DEBUG_INFORMATION_FORMAT = dwarf; 433 | ENABLE_STRICT_OBJC_MSGSEND = YES; 434 | ENABLE_TESTABILITY = YES; 435 | GCC_C_LANGUAGE_STANDARD = gnu99; 436 | GCC_DYNAMIC_NO_PIC = NO; 437 | GCC_NO_COMMON_BLOCKS = YES; 438 | GCC_OPTIMIZATION_LEVEL = 0; 439 | GCC_PREPROCESSOR_DEFINITIONS = ( 440 | "DEBUG=1", 441 | "$(inherited)", 442 | ); 443 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 444 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 445 | GCC_WARN_UNDECLARED_SELECTOR = YES; 446 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 447 | GCC_WARN_UNUSED_FUNCTION = YES; 448 | GCC_WARN_UNUSED_VARIABLE = YES; 449 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 450 | MTL_ENABLE_DEBUG_INFO = YES; 451 | ONLY_ACTIVE_ARCH = YES; 452 | SDKROOT = iphoneos; 453 | TARGETED_DEVICE_FAMILY = "1,2"; 454 | }; 455 | name = Debug; 456 | }; 457 | 20BB4D5A1DEE191500838A41 /* Release */ = { 458 | isa = XCBuildConfiguration; 459 | buildSettings = { 460 | ALWAYS_SEARCH_USER_PATHS = NO; 461 | CLANG_ANALYZER_NONNULL = YES; 462 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 463 | CLANG_CXX_LIBRARY = "libc++"; 464 | CLANG_ENABLE_MODULES = YES; 465 | CLANG_ENABLE_OBJC_ARC = YES; 466 | CLANG_WARN_BOOL_CONVERSION = YES; 467 | CLANG_WARN_CONSTANT_CONVERSION = YES; 468 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 469 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 470 | CLANG_WARN_EMPTY_BODY = YES; 471 | CLANG_WARN_ENUM_CONVERSION = YES; 472 | CLANG_WARN_INFINITE_RECURSION = YES; 473 | CLANG_WARN_INT_CONVERSION = YES; 474 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 475 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 476 | CLANG_WARN_UNREACHABLE_CODE = YES; 477 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 478 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 479 | COPY_PHASE_STRIP = NO; 480 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 481 | ENABLE_NS_ASSERTIONS = NO; 482 | ENABLE_STRICT_OBJC_MSGSEND = YES; 483 | GCC_C_LANGUAGE_STANDARD = gnu99; 484 | GCC_NO_COMMON_BLOCKS = YES; 485 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 486 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 487 | GCC_WARN_UNDECLARED_SELECTOR = YES; 488 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 489 | GCC_WARN_UNUSED_FUNCTION = YES; 490 | GCC_WARN_UNUSED_VARIABLE = YES; 491 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 492 | MTL_ENABLE_DEBUG_INFO = NO; 493 | SDKROOT = iphoneos; 494 | TARGETED_DEVICE_FAMILY = "1,2"; 495 | VALIDATE_PRODUCT = YES; 496 | }; 497 | name = Release; 498 | }; 499 | 20BB4D5C1DEE191500838A41 /* Debug */ = { 500 | isa = XCBuildConfiguration; 501 | baseConfigurationReference = CD44B0EEB67BC2FBF1920605 /* Pods-RobotoFontLoaderExample.debug.xcconfig */; 502 | buildSettings = { 503 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 504 | INFOPLIST_FILE = RobotoFontLoaderExample/Info.plist; 505 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 506 | PRODUCT_BUNDLE_IDENTIFIER = com.google.RobotoFontLoaderExample; 507 | PRODUCT_NAME = "$(TARGET_NAME)"; 508 | }; 509 | name = Debug; 510 | }; 511 | 20BB4D5D1DEE191500838A41 /* Release */ = { 512 | isa = XCBuildConfiguration; 513 | baseConfigurationReference = E79A0B6A2D2A7D4F3038A5F1 /* Pods-RobotoFontLoaderExample.release.xcconfig */; 514 | buildSettings = { 515 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 516 | INFOPLIST_FILE = RobotoFontLoaderExample/Info.plist; 517 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 518 | PRODUCT_BUNDLE_IDENTIFIER = com.google.RobotoFontLoaderExample; 519 | PRODUCT_NAME = "$(TARGET_NAME)"; 520 | }; 521 | name = Release; 522 | }; 523 | 20BB4D5F1DEE191500838A41 /* Debug */ = { 524 | isa = XCBuildConfiguration; 525 | baseConfigurationReference = 591BBC13F7D71A42B6E9CE0F /* Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.debug.xcconfig */; 526 | buildSettings = { 527 | BUNDLE_LOADER = "$(TEST_HOST)"; 528 | INFOPLIST_FILE = RobotoFontLoaderExampleTests/Info.plist; 529 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 530 | PRODUCT_BUNDLE_IDENTIFIER = com.google.RobotoFontLoaderExampleTests; 531 | PRODUCT_NAME = "$(TARGET_NAME)"; 532 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RobotoFontLoaderExample.app/RobotoFontLoaderExample"; 533 | }; 534 | name = Debug; 535 | }; 536 | 20BB4D601DEE191500838A41 /* Release */ = { 537 | isa = XCBuildConfiguration; 538 | baseConfigurationReference = 87BE723A4A8621845880FBE6 /* Pods-RobotoFontLoaderExample-RobotoFontLoaderExampleTests.release.xcconfig */; 539 | buildSettings = { 540 | BUNDLE_LOADER = "$(TEST_HOST)"; 541 | INFOPLIST_FILE = RobotoFontLoaderExampleTests/Info.plist; 542 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 543 | PRODUCT_BUNDLE_IDENTIFIER = com.google.RobotoFontLoaderExampleTests; 544 | PRODUCT_NAME = "$(TARGET_NAME)"; 545 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RobotoFontLoaderExample.app/RobotoFontLoaderExample"; 546 | }; 547 | name = Release; 548 | }; 549 | /* End XCBuildConfiguration section */ 550 | 551 | /* Begin XCConfigurationList section */ 552 | 20BB4D341DEE191500838A41 /* Build configuration list for PBXProject "RobotoFontLoaderExample" */ = { 553 | isa = XCConfigurationList; 554 | buildConfigurations = ( 555 | 20BB4D591DEE191500838A41 /* Debug */, 556 | 20BB4D5A1DEE191500838A41 /* Release */, 557 | ); 558 | defaultConfigurationIsVisible = 0; 559 | defaultConfigurationName = Release; 560 | }; 561 | 20BB4D5B1DEE191500838A41 /* Build configuration list for PBXNativeTarget "RobotoFontLoaderExample" */ = { 562 | isa = XCConfigurationList; 563 | buildConfigurations = ( 564 | 20BB4D5C1DEE191500838A41 /* Debug */, 565 | 20BB4D5D1DEE191500838A41 /* Release */, 566 | ); 567 | defaultConfigurationIsVisible = 0; 568 | defaultConfigurationName = Release; 569 | }; 570 | 20BB4D5E1DEE191500838A41 /* Build configuration list for PBXNativeTarget "RobotoFontLoaderExampleTests" */ = { 571 | isa = XCConfigurationList; 572 | buildConfigurations = ( 573 | 20BB4D5F1DEE191500838A41 /* Debug */, 574 | 20BB4D601DEE191500838A41 /* Release */, 575 | ); 576 | defaultConfigurationIsVisible = 0; 577 | defaultConfigurationName = Release; 578 | }; 579 | /* End XCConfigurationList section */ 580 | }; 581 | rootObject = 20BB4D311DEE191500838A41 /* Project object */; 582 | } 583 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface AppDelegate : UIResponder 20 | 21 | @property (strong, nonatomic) UIWindow *window; 22 | 23 | 24 | @end 25 | 26 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import "AppDelegate.h" 18 | #import "CatalogByConvention.h" 19 | 20 | @implementation AppDelegate 21 | 22 | 23 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 24 | self.window = [[UIWindow alloc]initWithFrame: [[UIScreen mainScreen] bounds]]; 25 | 26 | UIViewController *rootViewController = [[CBCNodeListViewController alloc] initWithNode:CBCCreateNavigationTree()]; 27 | rootViewController.title = @"Catalog by Convention"; 28 | 29 | UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; 30 | self.window.rootViewController = navController; 31 | 32 | [self.window makeKeyAndVisible]; 33 | return true; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExample/main.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "AppDelegate.h" 19 | 20 | int main(int argc, char * argv[]) { 21 | @autoreleasepool { 22 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/apps/RobotoFontLoaderExample/RobotoFontLoaderExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /examples/resources/RobotoVsSystem.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 31 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/MDCTypographyAdditions/MDFRobotoFontLoader+MDCTypographyAdditions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | #import "MaterialRobotoFontLoader.h" 19 | #import "MaterialTypography.h" 20 | 21 | /** 22 | The MDCRobotoFontLoader class already informally conforms to the MDCTypographyFontLoading protocol. 23 | This formalizes that conformace. 24 | */ 25 | @interface MDFRobotoFontLoader (MaterialTypographyAdditions) 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /src/MDCTypographyAdditions/MDFRobotoFontLoader+MDCTypographyAdditions.m: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Copyright 2015-present Google Inc.. All Rights Reserved. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | 18 | #import "MDFRobotoFontLoader+MDCTypographyAdditions.h" 19 | 20 | @implementation MDFRobotoFontLoader (MaterialTypographyAdditions) 21 | @end 22 | 23 | -------------------------------------------------------------------------------- /src/MDFRobotoFontLoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | /** 20 | The MDFRobotoFontLoader class provides a central location where the Roboto fonts are lazily loaded. 21 | */ 22 | @interface MDFRobotoFontLoader : NSObject 23 | 24 | /** Shared singleton instance. */ 25 | + (nonnull MDFRobotoFontLoader *)sharedInstance; 26 | 27 | /** This is a singleton: Use sharedInstance instead. */ 28 | - (nonnull instancetype)init NS_UNAVAILABLE; 29 | 30 | /** 31 | Returns a lazy-registered Roboto Light font. 32 | 33 | If registration fails then the system font is returned. 34 | */ 35 | - (nonnull UIFont *)lightFontOfSize:(CGFloat)fontSize; 36 | 37 | /** 38 | Returns a lazy-registered Roboto Regular font. 39 | 40 | If registration fails then the system font is returned. 41 | */ 42 | - (nonnull UIFont *)regularFontOfSize:(CGFloat)fontSize; 43 | 44 | /** 45 | Returns a lazy-registered Roboto Medium font. 46 | 47 | If registration fails then the bold system font is returned. 48 | */ 49 | - (nonnull UIFont *)mediumFontOfSize:(CGFloat)fontSize; 50 | 51 | /** 52 | Returns a lazy-registered Roboto Bold font. 53 | 54 | If registration fails then the bold system font is returned. 55 | */ 56 | - (nonnull UIFont *)boldFontOfSize:(CGFloat)fontSize; 57 | 58 | /** 59 | Returns a lazy-registered Roboto Light Italic font. 60 | 61 | If registration fails then the italic system font is returned. 62 | */ 63 | - (nonnull UIFont *)lightItalicFontOfSize:(CGFloat)fontSize; 64 | 65 | /** 66 | Returns a lazy-registered Roboto Regular Italic font. 67 | 68 | If registration fails then the italic system font is returned. 69 | */ 70 | - (nonnull UIFont *)italicFontOfSize:(CGFloat)fontSize; 71 | 72 | /** 73 | Returns a lazy-registered Roboto Medium Italic font. 74 | 75 | If registration fails then the italic system font is returned. 76 | */ 77 | - (nonnull UIFont *)mediumItalicFontOfSize:(CGFloat)fontSize; 78 | 79 | /** 80 | Returns a lazy-registered Roboto Bold Italic font. 81 | 82 | If registration fails then the italic system font is returned. 83 | */ 84 | - (nonnull UIFont *)boldItalicFontOfSize:(CGFloat)fontSize; 85 | 86 | /** Returns a bold version of the specified font. */ 87 | - (nonnull UIFont *)boldFontFromFont:(nonnull UIFont *)font; 88 | 89 | /** Returns an italic version of the specified font. */ 90 | - (nonnull UIFont *)italicFontFromFont:(nonnull UIFont *)font; 91 | 92 | /** Returns a bold version of the specified font. */ 93 | + (nonnull UIFont *)boldFontFromFont:(nonnull UIFont *)font; 94 | 95 | /** Returns an italic version of the specified font. */ 96 | + (nonnull UIFont *)italicFontFromFont:(nonnull UIFont *)font; 97 | 98 | /** 99 | Whether a particular font would be considered "large" for the purposes of calculating 100 | contrast ratios. 101 | 102 | Large fonts are defined as greater than 18pt normal or 14pt bold. If the passed font is nil, then 103 | this method returns NO. 104 | For more see: https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html 105 | 106 | @param font The font to examine, or nil. 107 | @return YES if the font is non-nil and is considered "large". 108 | */ 109 | - (BOOL)isLargeForContrastRatios:(nonnull UIFont *)font; 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /src/MDFRobotoFontLoader.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import "MDFRobotoFontLoader.h" 18 | 19 | #import "MaterialFontDiskLoader.h" 20 | 21 | NSString *const MDFRobotoRegularFontName = @"Roboto-Regular"; 22 | NSString *const MDFRobotoRegularItalicFontName = @"Roboto-Italic"; 23 | NSString *const MDFRobotoBoldFontName = @"Roboto-Bold"; 24 | NSString *const MDFRobotoBoldItalicFontName = @"Roboto-BoldItalic"; 25 | NSString *const MDFRobotoMediumFontName = @"Roboto-Medium"; 26 | NSString *const MDFRobotoMediumItalicFontName = @"Roboto-MediumItalic"; 27 | NSString *const MDFRobotoLightFontName = @"Roboto-Light"; 28 | NSString *const MDFRobotoLightItalicFontName = @"Roboto-LightItalic"; 29 | 30 | NSString *const MDFRobotoRegularFontFilename = @"Roboto-Regular.ttf"; 31 | NSString *const MDFRobotoRegularItalicFontFilename = @"Roboto-Italic.ttf"; 32 | NSString *const MDFRobotoBoldFontFilename = @"Roboto-Bold.ttf"; 33 | NSString *const MDFRobotoBoldItalicFontFilename = @"Roboto-BoldItalic.ttf"; 34 | NSString *const MDFRobotoMediumFontFilename = @"Roboto-Medium.ttf"; 35 | NSString *const MDFRobotoMediumItalicFontFilename = @"Roboto-MediumItalic.ttf"; 36 | NSString *const MDFRobotoLightFontFilename = @"Roboto-Light.ttf"; 37 | NSString *const MDFRobotoLightItalicFontFilename = @"Roboto-LightItalic.ttf"; 38 | 39 | NSString *const MDFRobotoBundle = @"MaterialRobotoFontLoader.bundle"; 40 | 41 | 42 | @interface MDFRobotoFontLoader () 43 | @property(nonatomic, strong) MDFFontDiskLoader *lightFontLoader; 44 | @property(nonatomic, strong) MDFFontDiskLoader *regularFontLoader; 45 | @property(nonatomic, strong) MDFFontDiskLoader *mediumFontLoader; 46 | @property(nonatomic, strong) MDFFontDiskLoader *boldFontLoader; 47 | 48 | @property(nonatomic, strong) MDFFontDiskLoader *lightItalicFontLoader; 49 | @property(nonatomic, strong) MDFFontDiskLoader *italicFontLoader; 50 | @property(nonatomic, strong) MDFFontDiskLoader *mediumItalicFontLoader; 51 | @property(nonatomic, strong) MDFFontDiskLoader *boldItalicFontLoader; 52 | 53 | @property(nonatomic, strong) NSBundle *baseBundle; 54 | @property(nonatomic, strong) NSString *bundleFileName; 55 | 56 | @property(nonatomic, assign) BOOL disableSanityChecks; 57 | 58 | @end 59 | 60 | @implementation MDFRobotoFontLoader 61 | 62 | + (MDFRobotoFontLoader *)sharedInstance { 63 | static id sharedInstance = nil; 64 | static dispatch_once_t onceToken; 65 | dispatch_once(&onceToken, ^{ 66 | sharedInstance = [[self alloc] initInternal]; 67 | }); 68 | return sharedInstance; 69 | } 70 | 71 | + (NSBundle *)baseBundle { 72 | static NSBundle *bundle = nil; 73 | static dispatch_once_t onceToken; 74 | dispatch_once(&onceToken, ^{ 75 | // We may not be included by the main bundle, but rather by an embedded framework, so figure out 76 | // to which bundle our code is compiled, and use that as the starting point for bundle loading. 77 | bundle = [NSBundle bundleForClass:[self class]]; 78 | }); 79 | 80 | return bundle; 81 | } 82 | 83 | - (instancetype)initInternal { 84 | self = [super init]; 85 | if (self) { 86 | self = [super init]; 87 | _baseBundle = [MDFRobotoFontLoader baseBundle]; 88 | _bundleFileName = MDFRobotoBundle; 89 | } 90 | return self; 91 | } 92 | 93 | - (NSString *)description { 94 | NSMutableString *description = [super.description mutableCopy]; 95 | [description appendString:@" (\n"]; 96 | NSNull *null = [NSNull null]; 97 | NSDictionary *selectors = @{ 98 | NSStringFromSelector(@selector(lightFontLoader)) : _lightFontLoader ?: null, 99 | NSStringFromSelector(@selector(regularFontLoader)) : _regularFontLoader ?: null, 100 | NSStringFromSelector(@selector(mediumFontLoader)) : _mediumFontLoader ?: null, 101 | NSStringFromSelector(@selector(boldFontLoader)) : _boldFontLoader ?: null, 102 | NSStringFromSelector(@selector(lightItalicFontLoader)) : _lightItalicFontLoader ?: null, 103 | NSStringFromSelector(@selector(italicFontLoader)) : _italicFontLoader ?: null, 104 | NSStringFromSelector(@selector(mediumItalicFontLoader)) : _mediumItalicFontLoader ?: null, 105 | NSStringFromSelector(@selector(boldItalicFontLoader)) : _boldItalicFontLoader ?: null, 106 | }; 107 | for (NSString *selectorName in selectors) { 108 | MDFFontDiskLoader *loader = [selectors objectForKey:selectorName]; 109 | if ([loader isEqual:[NSNull null]]) { 110 | continue; 111 | } 112 | [description appendFormat:@"%@: %@\n", selectorName, loader]; 113 | } 114 | 115 | [description appendString:@")\n"]; 116 | return description; 117 | } 118 | 119 | #pragma mark - Private 120 | 121 | - (void)setBundleFileName:(NSString *)bundleFileName { 122 | if ([bundleFileName isEqualToString:_bundleFileName]) { 123 | return; 124 | } 125 | if (bundleFileName) { 126 | _bundleFileName = bundleFileName; 127 | } else { 128 | _bundleFileName = MDFRobotoBundle; 129 | } 130 | [self resetFontLoaders]; 131 | } 132 | 133 | - (void)setBaseBundle:(NSBundle *)baseBundle { 134 | if ([baseBundle isEqual:_baseBundle]) { 135 | return; 136 | } 137 | if (baseBundle) { 138 | _baseBundle = baseBundle; 139 | } else { 140 | _baseBundle = [MDFRobotoFontLoader baseBundle]; 141 | } 142 | [self resetFontLoaders]; 143 | } 144 | 145 | - (void)resetFontLoaders { 146 | _regularFontLoader = nil; 147 | _lightFontLoader = nil; 148 | _mediumFontLoader = nil; 149 | _boldFontLoader = nil; 150 | _italicFontLoader = nil; 151 | _lightItalicFontLoader = nil; 152 | _mediumItalicFontLoader = nil; 153 | _boldItalicFontLoader = nil; 154 | } 155 | 156 | - (MDFFontDiskLoader *)regularFontLoader { 157 | if (!_regularFontLoader) { 158 | _regularFontLoader = [[MDFFontDiskLoader alloc] initWithFontName:MDFRobotoRegularFontName 159 | filename:MDFRobotoRegularFontFilename 160 | bundleFileName:_bundleFileName 161 | baseBundle:_baseBundle]; 162 | } 163 | return _regularFontLoader; 164 | } 165 | 166 | - (MDFFontDiskLoader *)mediumFontLoader { 167 | if (!_mediumFontLoader) { 168 | _mediumFontLoader = [[MDFFontDiskLoader alloc] initWithFontName:MDFRobotoMediumFontName 169 | filename:MDFRobotoMediumFontFilename 170 | bundleFileName:_bundleFileName 171 | baseBundle:_baseBundle]; 172 | } 173 | return _mediumFontLoader; 174 | } 175 | 176 | - (MDFFontDiskLoader *)lightFontLoader { 177 | if (!_lightFontLoader) { 178 | _lightFontLoader = [[MDFFontDiskLoader alloc] initWithFontName:MDFRobotoLightFontName 179 | filename:MDFRobotoLightFontFilename 180 | bundleFileName:_bundleFileName 181 | baseBundle:_baseBundle]; 182 | } 183 | return _lightFontLoader; 184 | } 185 | 186 | - (MDFFontDiskLoader *)boldFontLoader { 187 | if (!_boldFontLoader) { 188 | _boldFontLoader = [[MDFFontDiskLoader alloc] initWithFontName:MDFRobotoBoldFontName 189 | filename:MDFRobotoBoldFontFilename 190 | bundleFileName:_bundleFileName 191 | baseBundle:_baseBundle]; 192 | } 193 | return _boldFontLoader; 194 | } 195 | 196 | - (MDFFontDiskLoader *)italicFontLoader { 197 | if (!_italicFontLoader) { 198 | _italicFontLoader = 199 | [[MDFFontDiskLoader alloc] initWithFontName:MDFRobotoRegularItalicFontName 200 | filename:MDFRobotoRegularItalicFontFilename 201 | bundleFileName:_bundleFileName 202 | baseBundle:_baseBundle]; 203 | } 204 | return _italicFontLoader; 205 | } 206 | 207 | - (MDFFontDiskLoader *)lightItalicFontLoader { 208 | if (!_lightItalicFontLoader) { 209 | _lightItalicFontLoader = 210 | [[MDFFontDiskLoader alloc] initWithFontName:MDFRobotoLightItalicFontName 211 | filename:MDFRobotoLightItalicFontFilename 212 | bundleFileName:_bundleFileName 213 | baseBundle:_baseBundle]; 214 | } 215 | return _lightItalicFontLoader; 216 | } 217 | 218 | - (MDFFontDiskLoader *)mediumItalicFontLoader { 219 | if (!_mediumItalicFontLoader) { 220 | _mediumItalicFontLoader = 221 | [[MDFFontDiskLoader alloc] initWithFontName:MDFRobotoMediumItalicFontName 222 | filename:MDFRobotoMediumItalicFontFilename 223 | bundleFileName:_bundleFileName 224 | baseBundle:_baseBundle]; 225 | } 226 | return _mediumItalicFontLoader; 227 | } 228 | 229 | - (MDFFontDiskLoader *)boldItalicFontLoader { 230 | if (!_boldItalicFontLoader) { 231 | _boldItalicFontLoader = 232 | [[MDFFontDiskLoader alloc] initWithFontName:MDFRobotoBoldItalicFontName 233 | filename:MDFRobotoBoldItalicFontFilename 234 | bundleFileName:_bundleFileName 235 | baseBundle:_baseBundle]; 236 | } 237 | return _boldItalicFontLoader; 238 | } 239 | 240 | #pragma mark - Public 241 | 242 | - (UIFont *)regularFontOfSize:(CGFloat)fontSize { 243 | MDFFontDiskLoader *fontLoader = self.regularFontLoader; 244 | UIFont *font = [fontLoader fontOfSize:fontSize]; 245 | NSAssert(_disableSanityChecks || font, @"Font %@ not found in location: %@.", fontLoader.fontName, 246 | fontLoader.fontURL); 247 | if (!font) { 248 | font = [UIFont systemFontOfSize:fontSize]; 249 | } 250 | return font; 251 | } 252 | 253 | - (UIFont *)mediumFontOfSize:(CGFloat)fontSize { 254 | MDFFontDiskLoader *fontLoader = self.mediumFontLoader; 255 | UIFont *font = [fontLoader fontOfSize:fontSize]; 256 | NSAssert(_disableSanityChecks || font, @"Font %@ not found in location: %@.", fontLoader.fontName, 257 | fontLoader.fontURL); 258 | if (!font) { 259 | font = [UIFont boldSystemFontOfSize:fontSize]; 260 | } 261 | return font; 262 | } 263 | 264 | - (UIFont *)lightFontOfSize:(CGFloat)fontSize { 265 | MDFFontDiskLoader *fontLoader = self.lightFontLoader; 266 | UIFont *font = [fontLoader fontOfSize:fontSize]; 267 | NSAssert(_disableSanityChecks || font, @"Font %@ not found in location: %@.", fontLoader.fontName, 268 | fontLoader.fontURL); 269 | if (!font) { 270 | font = [UIFont systemFontOfSize:fontSize]; 271 | } 272 | return font; 273 | } 274 | 275 | - (UIFont *)boldFontOfSize:(CGFloat)fontSize { 276 | MDFFontDiskLoader *fontLoader = self.boldFontLoader; 277 | UIFont *font = [fontLoader fontOfSize:fontSize]; 278 | NSAssert(_disableSanityChecks || font, @"Font %@ not found in location: %@.", fontLoader.fontName, 279 | fontLoader.fontURL); 280 | if (!font) { 281 | font = [UIFont boldSystemFontOfSize:fontSize]; 282 | } 283 | return font; 284 | } 285 | 286 | - (UIFont *)italicFontOfSize:(CGFloat)fontSize { 287 | MDFFontDiskLoader *fontLoader = self.italicFontLoader; 288 | UIFont *font = [fontLoader fontOfSize:fontSize]; 289 | NSAssert(_disableSanityChecks || font, @"Font %@ not found in location: %@.", fontLoader.fontName, 290 | fontLoader.fontURL); 291 | if (!font) { 292 | font = [UIFont italicSystemFontOfSize:fontSize]; 293 | } 294 | return font; 295 | } 296 | 297 | - (UIFont *)lightItalicFontOfSize:(CGFloat)fontSize { 298 | MDFFontDiskLoader *fontLoader = self.lightItalicFontLoader; 299 | UIFont *font = [fontLoader fontOfSize:fontSize]; 300 | NSAssert(_disableSanityChecks || font, @"Font %@ not found in location: %@.", fontLoader.fontName, 301 | fontLoader.fontURL); 302 | if (!font) { 303 | font = [UIFont italicSystemFontOfSize:fontSize]; 304 | } 305 | return font; 306 | } 307 | 308 | - (UIFont *)mediumItalicFontOfSize:(CGFloat)fontSize { 309 | MDFFontDiskLoader *fontLoader = self.mediumItalicFontLoader; 310 | UIFont *font = [fontLoader fontOfSize:fontSize]; 311 | NSAssert(_disableSanityChecks || font, @"Font %@ not found in location: %@.", fontLoader.fontName, 312 | fontLoader.fontURL); 313 | if (!font) { 314 | font = [UIFont italicSystemFontOfSize:fontSize]; 315 | } 316 | return font; 317 | } 318 | 319 | - (UIFont *)boldItalicFontOfSize:(CGFloat)fontSize { 320 | MDFFontDiskLoader *fontLoader = self.boldItalicFontLoader; 321 | UIFont *font = [fontLoader fontOfSize:fontSize]; 322 | NSAssert(_disableSanityChecks || font, @"Font %@ not found in location: %@.", fontLoader.fontName, 323 | fontLoader.fontURL); 324 | if (!font) { 325 | font = [UIFont italicSystemFontOfSize:fontSize]; 326 | } 327 | return font; 328 | } 329 | 330 | + (BOOL)isItalicFontName:(nonnull NSString *)fontName { 331 | return [fontName isEqual:MDFRobotoRegularItalicFontName] || 332 | [fontName isEqual:MDFRobotoBoldItalicFontName] || 333 | [fontName isEqual:MDFRobotoMediumItalicFontName] || 334 | [fontName isEqual:MDFRobotoLightItalicFontName]; 335 | } 336 | 337 | + (BOOL)isBoldFontName:(nonnull NSString *)fontName { 338 | return [fontName isEqualToString:MDFRobotoMediumFontName] || 339 | [fontName isEqualToString:MDFRobotoBoldFontName] || 340 | [fontName isEqualToString:MDFRobotoMediumItalicFontName] || 341 | [fontName isEqualToString:MDFRobotoBoldItalicFontName]; 342 | } 343 | 344 | - (UIFont *)boldFontFromFont:(UIFont *)font { 345 | NSString *fontName = font.fontName; 346 | CGFloat fontSize = font.pointSize; 347 | if ([[self class] isBoldFontName:fontName]) { 348 | return font; 349 | } else if ([fontName isEqual:MDFRobotoRegularFontName]) { 350 | return [self mediumFontOfSize:fontSize]; 351 | } else if ([fontName isEqual:MDFRobotoRegularItalicFontName]) { 352 | return [self mediumItalicFontOfSize:fontSize]; 353 | } else if ([fontName isEqual:MDFRobotoLightFontName]) { 354 | return [self mediumFontOfSize:fontSize]; 355 | } else if ([fontName isEqual:MDFRobotoLightItalicFontName]) { 356 | return [self mediumItalicFontOfSize:fontSize]; 357 | } 358 | return [UIFont boldSystemFontOfSize:fontSize]; 359 | } 360 | 361 | - (UIFont *)italicFontFromFont:(UIFont *)font { 362 | NSString *fontName = font.fontName; 363 | CGFloat fontSize = font.pointSize; 364 | if ([[self class] isItalicFontName:fontName]) { 365 | return font; 366 | } else if ([fontName isEqual:MDFRobotoRegularFontName]) { 367 | return [self italicFontOfSize:fontSize]; 368 | } else if ([fontName isEqual:MDFRobotoBoldFontName]) { 369 | return [self boldItalicFontOfSize:fontSize]; 370 | } else if ([fontName isEqual:MDFRobotoMediumFontName]) { 371 | return [self mediumItalicFontOfSize:fontSize]; 372 | } else if ([fontName isEqual:MDFRobotoLightFontName]) { 373 | return [self lightItalicFontOfSize:fontSize]; 374 | } 375 | return [UIFont italicSystemFontOfSize:fontSize]; 376 | } 377 | 378 | + (UIFont *)boldFontFromFont:(UIFont *)font { 379 | return [[self sharedInstance] boldFontFromFont:font]; 380 | } 381 | 382 | + (UIFont *)italicFontFromFont:(UIFont *)font { 383 | return [[self sharedInstance] italicFontFromFont:font]; 384 | } 385 | 386 | - (BOOL)isLargeForContrastRatios:(UIFont *)font { 387 | if (font.pointSize >= 18) { 388 | return YES; 389 | } 390 | if (font.pointSize < 14) { 391 | return NO; 392 | } 393 | 394 | UIFontDescriptor *fontDescriptor = font.fontDescriptor; 395 | if ((fontDescriptor.symbolicTraits & UIFontDescriptorTraitBold) == UIFontDescriptorTraitBold) { 396 | return YES; 397 | } 398 | 399 | // We treat medium as large for MDC accesibility when larger than 14 400 | if ([font.fontName rangeOfString:@"medium" options:NSCaseInsensitiveSearch].location != NSNotFound) { 401 | return YES; 402 | } 403 | 404 | return NO; 405 | } 406 | 407 | @end 408 | -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-Black.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-BlackItalic.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-Bold.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-BoldItalic.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-Italic.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-Light.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-LightItalic.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-Medium.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-MediumItalic.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-Regular.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-Thin.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.bundle/Roboto-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/material-foundation/material-roboto-font-loader-ios/bc63eabbbd1e14cee0779b05827e08db2e413553/src/MaterialRobotoFontLoader.bundle/Roboto-ThinItalic.ttf -------------------------------------------------------------------------------- /src/MaterialRobotoFontLoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | #if !defined(__IPHONE_4_1) || (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_1) 20 | #error "This component only supports iOS 4.1 and above." 21 | #endif 22 | 23 | /** 24 | The RobotoFontLoader component provides methods for getting Roboto fonts. 25 | 26 | This header is the umbrella header for the component and should be imported by consumers of the 27 | RobotoFontLoader component. Please do not directly import other headers. This will allow the 28 | componet to expand or contract the header file space without consumer modifications. 29 | */ 30 | 31 | #import "MDFRobotoFontLoader.h" 32 | -------------------------------------------------------------------------------- /tests/unit/RobotoFontLoaderTests.m: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2015-present Google Inc.. All Rights Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #import 18 | 19 | #import "MDFFontDiskLoader.h" 20 | #import "MDFRobotoFontLoader.h" 21 | 22 | static const CGFloat kEpsilonAccuracy = 0.001f; 23 | NSString *const MDFRobotoRegularFontName = @"Roboto-Regular"; 24 | NSString *const MDFRobotoRegularItalicFontName = @"Roboto-Italic"; 25 | NSString *const MDFRobotoBoldFontName = @"Roboto-Bold"; 26 | NSString *const MDFRobotoBoldItalicFontName = @"Roboto-BoldItalic"; 27 | NSString *const MDFRobotoMediumFontName = @"Roboto-Medium"; 28 | NSString *const MDFRobotoMediumItalicFontName = @"Roboto-MediumItalic"; 29 | NSString *const MDFRobotoLightFontName = @"Roboto-Light"; 30 | NSString *const MDFRobotoLightItalicFontName = @"Roboto-LightItalic"; 31 | 32 | NSString *const MDFRobotoRegularFontFilename = @"Roboto-Regular.ttf"; 33 | NSString *const MDFRobotoRegularItalicFontFilename = @"Roboto-Italic.ttf"; 34 | NSString *const MDFRobotoBoldFontFilename = @"Roboto-Bold.ttf"; 35 | NSString *const MDFRobotoBoldItalicFontFilename = @"Roboto-BoldItalic.ttf"; 36 | NSString *const MDFRobotoMediumFontFilename = @"Roboto-Medium.ttf"; 37 | NSString *const MDFRobotoMediumItalicFontFilename = @"Roboto-MediumItalic.ttf"; 38 | NSString *const MDFRobotoLightFontFilename = @"Roboto-Light.ttf"; 39 | NSString *const MDFRobotoLightItalicFontFilename = @"Roboto-LightItalic.ttf"; 40 | 41 | NSString *const MDFRobotoBundle = @"MaterialRobotoFontLoader.bundle"; 42 | 43 | /** 44 | For our tests we are following a Given When Then structure as defined in 45 | http://martinfowler.com/bliki/GivenWhenThen.html 46 | 47 | The essential idea is to break down writing a scenario (or test) into three sections: 48 | 49 | The |given| part describes the state of the world before you begin the behavior you're specifying 50 | in this scenario. You can think of it as the pre-conditions to the test. 51 | The |when| section is that behavior that you're specifying. 52 | Finally the |then| section describes the changes you expect due to the specified behavior. 53 | 54 | For us this just means that we have the Given When Then guide posts as comments for each unit test. 55 | */ 56 | @interface RobotoFontLoaderTests : XCTestCase 57 | @end 58 | 59 | @interface MDFFontDiskLoader (Testing) 60 | @property(nonatomic, assign) BOOL disableSanityChecks; 61 | @end 62 | 63 | @interface MDFRobotoFontLoader (Testing) 64 | @property(nonatomic, strong) MDFFontDiskLoader *lightFontLoader; 65 | @property(nonatomic, strong) MDFFontDiskLoader *regularFontLoader; 66 | @property(nonatomic, strong) MDFFontDiskLoader *mediumFontLoader; 67 | @property(nonatomic, strong) MDFFontDiskLoader *boldFontLoader; 68 | 69 | @property(nonatomic, strong) MDFFontDiskLoader *lightItalicFontLoader; 70 | @property(nonatomic, strong) MDFFontDiskLoader *italicFontLoader; 71 | @property(nonatomic, strong) MDFFontDiskLoader *mediumItalicFontLoader; 72 | @property(nonatomic, strong) MDFFontDiskLoader *boldItalicFontLoader; 73 | 74 | @property(nonatomic, strong, null_resettable) NSBundle *baseBundle; 75 | @property(nonatomic, assign) BOOL disableSanityChecks; 76 | 77 | + (BOOL)isItalicFontName:(nonnull NSString *)fontName; 78 | + (BOOL)isBoldFontName:(nonnull NSString *)fontName; 79 | + (NSBundle *)baseBundle; 80 | 81 | - (instancetype)initInternal; 82 | 83 | @end 84 | 85 | @implementation RobotoFontLoaderTests 86 | 87 | - (void)testItalicFontFromFontRegular { 88 | // Given 89 | CGFloat size = arc4random_uniform(1000) / (arc4random_uniform(10) + 1); 90 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 91 | UIFont *regularFont = [fontLoader regularFontOfSize:size]; 92 | 93 | // When 94 | UIFont *font = [MDFRobotoFontLoader italicFontFromFont:regularFont]; 95 | 96 | // Then 97 | XCTAssertEqualObjects(font.fontName, @"Roboto-Italic"); 98 | } 99 | 100 | - (void)testRobotoRegularWithSize { 101 | // Given 102 | CGFloat size = [self randomNumber]; 103 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 104 | 105 | // When 106 | UIFont *font = [fontLoader regularFontOfSize:size]; 107 | 108 | // Then 109 | XCTAssertEqualWithAccuracy(font.pointSize, size, kEpsilonAccuracy, 110 | @"The regular font must be the size that was asked for."); 111 | XCTAssertEqualObjects(font.fontName, MDFRobotoRegularFontName, 112 | @"The font name must match the regular font."); 113 | } 114 | 115 | - (void)testRobotoMediumWithSize { 116 | // Given 117 | CGFloat size = [self randomNumber]; 118 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 119 | 120 | // When 121 | UIFont *font = [fontLoader mediumFontOfSize:size]; 122 | 123 | // Then 124 | XCTAssertEqualWithAccuracy(font.pointSize, size, kEpsilonAccuracy, 125 | @"The medium font must be the size that was asked for."); 126 | XCTAssertEqualObjects(font.fontName, MDFRobotoMediumFontName, 127 | @"The font name must match the medium font."); 128 | } 129 | 130 | - (void)testRobotoLightWithSize { 131 | // Given 132 | CGFloat size = [self randomNumber]; 133 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 134 | 135 | // When 136 | UIFont *font = [fontLoader lightFontOfSize:size]; 137 | 138 | // Then 139 | XCTAssertEqualWithAccuracy(font.pointSize, size, kEpsilonAccuracy, 140 | @"The light font must be the size that was asked for."); 141 | XCTAssertEqualObjects(font.fontName, MDFRobotoLightFontName, 142 | @"The font name must match the light font."); 143 | } 144 | 145 | - (void)testRobotoBoldWithSize { 146 | // Given 147 | CGFloat size = [self randomNumber]; 148 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 149 | 150 | // When 151 | UIFont *font = [fontLoader boldFontOfSize:size]; 152 | 153 | // Then 154 | XCTAssertEqualWithAccuracy(font.pointSize, size, kEpsilonAccuracy, 155 | @"The bold font must be the size that was asked for."); 156 | XCTAssertEqualObjects(font.fontName, MDFRobotoBoldFontName, 157 | @"The font name must match the bold font."); 158 | } 159 | 160 | - (void)testRobotoItalicWithSize { 161 | // Given 162 | CGFloat size = [self randomNumber]; 163 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 164 | 165 | // When 166 | UIFont *font = [fontLoader italicFontOfSize:size]; 167 | 168 | // Then 169 | XCTAssertEqualWithAccuracy(font.pointSize, size, kEpsilonAccuracy, 170 | @"The italic font must be the size that was asked for."); 171 | XCTAssertEqualObjects(font.fontName, MDFRobotoRegularItalicFontName, 172 | @"The font name must match the italic font."); 173 | } 174 | 175 | - (void)testRobotoMediumItalicWithSize { 176 | // Given 177 | CGFloat size = [self randomNumber]; 178 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 179 | 180 | // When 181 | UIFont *font = [fontLoader mediumItalicFontOfSize:size]; 182 | 183 | // Then 184 | XCTAssertEqualWithAccuracy(font.pointSize, size, kEpsilonAccuracy, 185 | @"The medium italic font must be the size that was asked for."); 186 | XCTAssertEqualObjects(font.fontName, MDFRobotoMediumItalicFontName, 187 | @"The font name must match the medium italic font."); 188 | } 189 | 190 | - (void)testRobotoLightItalicWithSize { 191 | // Given 192 | CGFloat size = [self randomNumber]; 193 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 194 | 195 | // When 196 | UIFont *font = [fontLoader lightItalicFontOfSize:size]; 197 | 198 | // Then 199 | XCTAssertEqualWithAccuracy(font.pointSize, size, kEpsilonAccuracy, 200 | @"The light italic font must be the size that was asked for."); 201 | XCTAssertEqualObjects(font.fontName, MDFRobotoLightItalicFontName, 202 | @"The font name must match the light italic font."); 203 | } 204 | 205 | - (void)testRobotoBoldItalicWithSize { 206 | // Given 207 | CGFloat size = [self randomNumber]; 208 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 209 | 210 | // When 211 | UIFont *font = [fontLoader boldItalicFontOfSize:size]; 212 | 213 | // Then 214 | XCTAssertEqualWithAccuracy(font.pointSize, size, kEpsilonAccuracy, 215 | @"The bold italic font must be the size that was asked for."); 216 | XCTAssertEqualObjects(font.fontName, MDFRobotoBoldItalicFontName, 217 | @"The font name must match the bold italic font."); 218 | } 219 | 220 | - (void)testLightFallbackSystemFonts { 221 | // Given 222 | CGFloat size = [self randomNumber]; 223 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 224 | fontLoader.disableSanityChecks = YES; 225 | fontLoader.lightFontLoader = 226 | [[MDFFontDiskLoader alloc] initWithFontName:@"something that doesn't exist" 227 | fontURL:fontLoader.lightFontLoader.fontURL]; 228 | fontLoader.lightFontLoader.disableSanityChecks = YES; 229 | 230 | // When 231 | UIFont *font = [fontLoader lightFontOfSize:size]; 232 | 233 | // Then 234 | XCTAssertEqualObjects(font, [UIFont systemFontOfSize:size], 235 | @"The system font must be returned when the fontloader fails to load a" 236 | @"font."); 237 | } 238 | 239 | - (void)testFallbackSystemFonts { 240 | // Given 241 | CGFloat size = [self randomNumber]; 242 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 243 | fontLoader.disableSanityChecks = YES; 244 | fontLoader.regularFontLoader = 245 | [[MDFFontDiskLoader alloc] initWithFontName:@"something that doesn't exist" 246 | fontURL:fontLoader.regularFontLoader.fontURL]; 247 | fontLoader.regularFontLoader.disableSanityChecks = YES; 248 | 249 | // When 250 | UIFont *font = [fontLoader regularFontOfSize:size]; 251 | 252 | // Then 253 | XCTAssertEqualObjects(font, [UIFont systemFontOfSize:size], 254 | @"The system font must be returned when the fontloader fails to load a" 255 | @"font."); 256 | } 257 | 258 | - (void)testMediumFallbackSystemFonts { 259 | // Given 260 | CGFloat size = [self randomNumber]; 261 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 262 | fontLoader.disableSanityChecks = YES; 263 | fontLoader.mediumFontLoader = 264 | [[MDFFontDiskLoader alloc] initWithFontName:@"something that doesn't exist" 265 | fontURL:fontLoader.mediumFontLoader.fontURL]; 266 | fontLoader.mediumFontLoader.disableSanityChecks = YES; 267 | 268 | // When 269 | UIFont *font = [fontLoader mediumFontOfSize:size]; 270 | 271 | // Then 272 | XCTAssertEqualObjects(font, [UIFont boldSystemFontOfSize:size], 273 | @"The bold system font must be returned when the fontloader fails to load a" 274 | @"medium font."); 275 | } 276 | 277 | - (void)testBoldFallbackSystemFonts { 278 | // Given 279 | CGFloat size = [self randomNumber]; 280 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 281 | fontLoader.disableSanityChecks = YES; 282 | fontLoader.boldFontLoader = 283 | [[MDFFontDiskLoader alloc] initWithFontName:@"something that doesn't exist" 284 | fontURL:fontLoader.boldFontLoader.fontURL]; 285 | fontLoader.boldFontLoader.disableSanityChecks = YES; 286 | 287 | // When 288 | UIFont *font = [fontLoader boldFontOfSize:size]; 289 | 290 | // Then 291 | XCTAssertEqualObjects(font, [UIFont boldSystemFontOfSize:size], 292 | @"The bold system font must be returned when the fontloader fails to load a" 293 | @"bold font."); 294 | } 295 | 296 | - (void)testLightItalicFallbackSystemFonts { 297 | // Given 298 | CGFloat size = [self randomNumber]; 299 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 300 | fontLoader.disableSanityChecks = YES; 301 | fontLoader.lightItalicFontLoader = 302 | [[MDFFontDiskLoader alloc] initWithFontName:@"something that doesn't exist" 303 | fontURL:fontLoader.lightItalicFontLoader.fontURL]; 304 | fontLoader.lightItalicFontLoader.disableSanityChecks = YES; 305 | 306 | // When 307 | UIFont *font = [fontLoader lightItalicFontOfSize:size]; 308 | 309 | // Then 310 | XCTAssertEqualObjects(font, [UIFont italicSystemFontOfSize:size], 311 | @"The italic system font must be returned when the fontloader fails to load" 312 | @"an italic font."); 313 | } 314 | 315 | - (void)testItalicFallbackSystemFonts { 316 | // Given 317 | CGFloat size = [self randomNumber]; 318 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 319 | fontLoader.disableSanityChecks = YES; 320 | fontLoader.italicFontLoader = 321 | [[MDFFontDiskLoader alloc] initWithFontName:@"something that doesn't exist" 322 | fontURL:fontLoader.italicFontLoader.fontURL]; 323 | fontLoader.italicFontLoader.disableSanityChecks = YES; 324 | 325 | // When 326 | UIFont *font = [fontLoader italicFontOfSize:size]; 327 | 328 | // Then 329 | XCTAssertEqualObjects(font, [UIFont italicSystemFontOfSize:size], 330 | @"The italic system font must be returned when the fontloader fails to load" 331 | @"an italic font."); 332 | } 333 | 334 | - (void)testMediumItalicFallbackSystemFonts { 335 | // Given 336 | CGFloat size = [self randomNumber]; 337 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 338 | fontLoader.disableSanityChecks = YES; 339 | fontLoader.mediumItalicFontLoader = 340 | [[MDFFontDiskLoader alloc] initWithFontName:@"something that doesn't exist" 341 | fontURL:fontLoader.mediumItalicFontLoader.fontURL]; 342 | fontLoader.mediumItalicFontLoader.disableSanityChecks = YES; 343 | 344 | // When 345 | UIFont *font = [fontLoader mediumItalicFontOfSize:size]; 346 | 347 | // Then 348 | XCTAssertEqualObjects(font, [UIFont italicSystemFontOfSize:size], 349 | @"The italic system font must be returned when the fontloader fails to " 350 | @"load a medium italic font."); 351 | } 352 | 353 | - (void)testBoldItalicFallbackSystemFonts { 354 | // Given 355 | CGFloat size = [self randomNumber]; 356 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 357 | fontLoader.disableSanityChecks = YES; 358 | fontLoader.boldItalicFontLoader = 359 | [[MDFFontDiskLoader alloc] initWithFontName:@"something that doesn't exist" 360 | fontURL:fontLoader.boldItalicFontLoader.fontURL]; 361 | fontLoader.boldItalicFontLoader.disableSanityChecks = YES; 362 | 363 | // When 364 | UIFont *font = [fontLoader boldItalicFontOfSize:size]; 365 | 366 | // Then 367 | XCTAssertEqualObjects(font, [UIFont italicSystemFontOfSize:size], 368 | @"The italic system font must be returned when the fontloader fails to " 369 | @"load a bold italic font."); 370 | } 371 | 372 | - (void)testSettingBaseBundleResetsLoader { 373 | // Given 374 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 375 | NSArray *existingFontLoaders = @[ 376 | fontLoader.regularFontLoader, fontLoader.lightFontLoader, fontLoader.mediumFontLoader, 377 | fontLoader.boldFontLoader, fontLoader.italicFontLoader, fontLoader.lightItalicFontLoader, 378 | fontLoader.mediumItalicFontLoader, fontLoader.boldItalicFontLoader 379 | ]; 380 | 381 | // When 382 | fontLoader.baseBundle = nil; 383 | fontLoader.baseBundle = [MDFRobotoFontLoader baseBundle]; 384 | NSArray *newFontLoaders = @[ 385 | fontLoader.regularFontLoader, fontLoader.lightFontLoader, fontLoader.mediumFontLoader, 386 | fontLoader.boldFontLoader, fontLoader.italicFontLoader, fontLoader.lightItalicFontLoader, 387 | fontLoader.mediumItalicFontLoader, fontLoader.boldItalicFontLoader 388 | ]; 389 | 390 | // Then 391 | for (NSUInteger index = 0; index < existingFontLoaders.count; ++index) { 392 | MDFFontDiskLoader *exisitngFontLoader = existingFontLoaders[index]; 393 | MDFFontDiskLoader *newFontLoader = newFontLoaders[index]; 394 | XCTAssertNotEqual(newFontLoader, exisitngFontLoader, // Check that pointers are different. 395 | @"Fontloader must be new objects when the base bundle gets set."); 396 | } 397 | } 398 | 399 | - (void)testResetingBaseBundle { 400 | // Given 401 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 402 | 403 | // When 404 | fontLoader.baseBundle = nil; 405 | 406 | // Then 407 | XCTAssertNotNil(fontLoader.baseBundle, @"The baseBundle must always have a value."); 408 | } 409 | 410 | - (void)testDescription { 411 | // Given 412 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 413 | NSArray *expected = @[ 414 | [NSString stringWithFormat:@"%@: %@", NSStringFromSelector(@selector(lightFontLoader)), 415 | fontLoader.lightFontLoader], 416 | [NSString stringWithFormat:@"%@: %@", NSStringFromSelector(@selector(regularFontLoader)), 417 | fontLoader.regularFontLoader], 418 | [NSString stringWithFormat:@"%@: %@", NSStringFromSelector(@selector(mediumFontLoader)), 419 | fontLoader.mediumFontLoader], 420 | [NSString stringWithFormat:@"%@: %@", NSStringFromSelector(@selector(boldFontLoader)), 421 | fontLoader.boldFontLoader], 422 | [NSString stringWithFormat:@"%@: %@", NSStringFromSelector(@selector(lightItalicFontLoader)), 423 | fontLoader.lightItalicFontLoader], 424 | [NSString stringWithFormat:@"%@: %@", NSStringFromSelector(@selector(italicFontLoader)), 425 | fontLoader.italicFontLoader], 426 | [NSString stringWithFormat:@"%@: %@", NSStringFromSelector(@selector(mediumItalicFontLoader)), 427 | fontLoader.mediumItalicFontLoader], 428 | [NSString stringWithFormat:@"%@: %@", NSStringFromSelector(@selector(boldItalicFontLoader)), 429 | fontLoader.boldItalicFontLoader], 430 | ]; 431 | 432 | // When 433 | NSString *actual = [fontLoader description]; 434 | 435 | // Then 436 | for (NSString *LoaderDescriptoin in expected) { 437 | XCTAssertTrue([actual rangeOfString:LoaderDescriptoin].location != NSNotFound, 438 | @"actual %@ does not end with: %@", actual, expected); 439 | } 440 | } 441 | 442 | - (void)testDescriptionWithNoLoaderMustBeMostlyEmpty { 443 | // Given 444 | MDFRobotoFontLoader *fontLoader = [[MDFRobotoFontLoader alloc] initInternal]; 445 | NSString *expected = @" (\n)\n"; 446 | 447 | // When 448 | NSString *actual = [fontLoader description]; 449 | 450 | // Then 451 | XCTAssertTrue([actual hasSuffix:expected], @"Description %@ must end with: %@", actual, expected); 452 | } 453 | 454 | - (void)testIsItalicFontName { 455 | XCTAssertFalse([MDFRobotoFontLoader isItalicFontName:MDFRobotoRegularFontName]); 456 | XCTAssertFalse([MDFRobotoFontLoader isItalicFontName:MDFRobotoBoldFontName]); 457 | XCTAssertFalse([MDFRobotoFontLoader isItalicFontName:MDFRobotoMediumFontName]); 458 | XCTAssertFalse([MDFRobotoFontLoader isItalicFontName:MDFRobotoLightFontName]); 459 | 460 | XCTAssertTrue([MDFRobotoFontLoader isItalicFontName:MDFRobotoRegularItalicFontName]); 461 | XCTAssertTrue([MDFRobotoFontLoader isItalicFontName:MDFRobotoBoldItalicFontName]); 462 | XCTAssertTrue([MDFRobotoFontLoader isItalicFontName:MDFRobotoMediumItalicFontName]); 463 | XCTAssertTrue([MDFRobotoFontLoader isItalicFontName:MDFRobotoLightItalicFontName]); 464 | } 465 | 466 | - (void)testIsBoldFontName { 467 | XCTAssertTrue([MDFRobotoFontLoader isBoldFontName:MDFRobotoBoldItalicFontName]); 468 | XCTAssertTrue([MDFRobotoFontLoader isBoldFontName:MDFRobotoMediumItalicFontName]); 469 | XCTAssertTrue([MDFRobotoFontLoader isBoldFontName:MDFRobotoBoldFontName]); 470 | XCTAssertTrue([MDFRobotoFontLoader isBoldFontName:MDFRobotoMediumFontName]); 471 | 472 | XCTAssertFalse([MDFRobotoFontLoader isBoldFontName:MDFRobotoRegularFontName]); 473 | XCTAssertFalse([MDFRobotoFontLoader isBoldFontName:MDFRobotoLightFontName]); 474 | XCTAssertFalse([MDFRobotoFontLoader isBoldFontName:MDFRobotoRegularItalicFontName]); 475 | XCTAssertFalse([MDFRobotoFontLoader isBoldFontName:MDFRobotoLightItalicFontName]); 476 | } 477 | 478 | - (void)testItalicFontFromFontClassMethod { 479 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 480 | CGFloat size = 10; 481 | NSDictionary *italicFontForFont = @{ 482 | [fontLoader lightFontOfSize:size]:[fontLoader lightItalicFontOfSize:size], 483 | [fontLoader regularFontOfSize:size]:[fontLoader italicFontOfSize:size], 484 | [fontLoader mediumFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 485 | [fontLoader boldFontOfSize:size]:[fontLoader boldItalicFontOfSize:size], 486 | [fontLoader lightItalicFontOfSize:size]:[fontLoader lightItalicFontOfSize:size], 487 | [fontLoader italicFontOfSize:size]:[fontLoader italicFontOfSize:size], 488 | [fontLoader mediumItalicFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 489 | [fontLoader boldItalicFontOfSize:size]:[fontLoader boldItalicFontOfSize:size], 490 | }; 491 | for (UIFont *font in italicFontForFont) { 492 | XCTAssertEqualObjects([MDFRobotoFontLoader italicFontFromFont:font], italicFontForFont[font]); 493 | } 494 | } 495 | 496 | - (void)testBoldFontFromFontClassMethod { 497 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 498 | CGFloat size = 10; 499 | NSDictionary *boldFontForFont = @{ 500 | [fontLoader lightFontOfSize:size]:[fontLoader mediumFontOfSize:size], 501 | [fontLoader regularFontOfSize:size]:[fontLoader mediumFontOfSize:size], 502 | [fontLoader mediumFontOfSize:size]:[fontLoader mediumFontOfSize:size], 503 | [fontLoader boldFontOfSize:size]:[fontLoader boldFontOfSize:size], 504 | [fontLoader lightItalicFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 505 | [fontLoader italicFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 506 | [fontLoader mediumItalicFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 507 | [fontLoader boldItalicFontOfSize:size]:[fontLoader boldItalicFontOfSize:size], 508 | }; 509 | for (UIFont *font in boldFontForFont) { 510 | XCTAssertEqualObjects([MDFRobotoFontLoader boldFontFromFont:font], boldFontForFont[font]); 511 | } 512 | } 513 | 514 | - (void)testItalicFontFromFont { 515 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 516 | CGFloat size = 10; 517 | NSDictionary *italicFontForFont = @{ 518 | [fontLoader lightFontOfSize:size]:[fontLoader lightItalicFontOfSize:size], 519 | [fontLoader regularFontOfSize:size]:[fontLoader italicFontOfSize:size], 520 | [fontLoader mediumFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 521 | [fontLoader boldFontOfSize:size]:[fontLoader boldItalicFontOfSize:size], 522 | [fontLoader lightItalicFontOfSize:size]:[fontLoader lightItalicFontOfSize:size], 523 | [fontLoader italicFontOfSize:size]:[fontLoader italicFontOfSize:size], 524 | [fontLoader mediumItalicFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 525 | [fontLoader boldItalicFontOfSize:size]:[fontLoader boldItalicFontOfSize:size], 526 | }; 527 | for (UIFont *font in italicFontForFont) { 528 | XCTAssertEqualObjects([fontLoader italicFontFromFont:font], italicFontForFont[font]); 529 | } 530 | } 531 | 532 | - (void)testBoldFontFromFont { 533 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 534 | CGFloat size = 10; 535 | NSDictionary *boldFontForFont = @{ 536 | [fontLoader lightFontOfSize:size]:[fontLoader mediumFontOfSize:size], 537 | [fontLoader regularFontOfSize:size]:[fontLoader mediumFontOfSize:size], 538 | [fontLoader mediumFontOfSize:size]:[fontLoader mediumFontOfSize:size], 539 | [fontLoader boldFontOfSize:size]:[fontLoader boldFontOfSize:size], 540 | [fontLoader lightItalicFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 541 | [fontLoader italicFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 542 | [fontLoader mediumItalicFontOfSize:size]:[fontLoader mediumItalicFontOfSize:size], 543 | [fontLoader boldItalicFontOfSize:size]:[fontLoader boldItalicFontOfSize:size], 544 | }; 545 | for (UIFont *font in boldFontForFont) { 546 | XCTAssertEqualObjects([fontLoader boldFontFromFont:font], boldFontForFont[font]); 547 | } 548 | } 549 | 550 | - (void)testIsLargeForContrastRatio { 551 | // Given 552 | CGFloat smallSize = 10.0f; 553 | CGFloat largeIfBoldSize = 15.0f; 554 | CGFloat largeSize = 18.0f; 555 | MDFRobotoFontLoader *fontLoader = [MDFRobotoFontLoader sharedInstance]; 556 | 557 | // Then 558 | XCTAssertFalse([fontLoader isLargeForContrastRatios:[UIFont systemFontOfSize:smallSize]]); 559 | XCTAssertFalse([fontLoader isLargeForContrastRatios:[UIFont boldSystemFontOfSize:smallSize]]); 560 | XCTAssertTrue( 561 | [fontLoader isLargeForContrastRatios:[UIFont boldSystemFontOfSize:largeIfBoldSize]]); 562 | XCTAssertTrue([fontLoader isLargeForContrastRatios:[UIFont systemFontOfSize:largeSize]]); 563 | 564 | // Light 565 | XCTAssertFalse([fontLoader isLargeForContrastRatios:[fontLoader lightFontOfSize:smallSize]]); 566 | XCTAssertFalse( 567 | [fontLoader isLargeForContrastRatios:[fontLoader lightFontOfSize:largeIfBoldSize]]); 568 | XCTAssertTrue([fontLoader isLargeForContrastRatios:[fontLoader lightFontOfSize:largeSize]]); 569 | 570 | // Regular 571 | XCTAssertFalse([fontLoader isLargeForContrastRatios:[fontLoader regularFontOfSize:smallSize]]); 572 | XCTAssertFalse( 573 | [fontLoader isLargeForContrastRatios:[fontLoader regularFontOfSize:largeIfBoldSize]]); 574 | XCTAssertTrue([fontLoader isLargeForContrastRatios:[fontLoader regularFontOfSize:largeSize]]); 575 | 576 | // Medium 577 | XCTAssertFalse([fontLoader isLargeForContrastRatios:[fontLoader mediumFontOfSize:smallSize]]); 578 | // We treat medium as large for MDC accesibility. 579 | XCTAssertTrue( 580 | [fontLoader isLargeForContrastRatios:[fontLoader mediumFontOfSize:largeIfBoldSize]]); 581 | XCTAssertTrue([fontLoader isLargeForContrastRatios:[fontLoader mediumFontOfSize:largeSize]]); 582 | 583 | // Bold 584 | XCTAssertFalse([fontLoader isLargeForContrastRatios:[fontLoader boldFontOfSize:smallSize]]); 585 | XCTAssertTrue([fontLoader isLargeForContrastRatios:[fontLoader boldFontOfSize:largeIfBoldSize]]); 586 | XCTAssertTrue([fontLoader isLargeForContrastRatios:[fontLoader boldFontOfSize:largeSize]]); 587 | 588 | // Italic 589 | XCTAssertFalse([fontLoader isLargeForContrastRatios:[fontLoader italicFontOfSize:smallSize]]); 590 | XCTAssertFalse( 591 | [fontLoader isLargeForContrastRatios:[fontLoader italicFontOfSize:largeIfBoldSize]]); 592 | XCTAssertTrue([fontLoader isLargeForContrastRatios:[fontLoader italicFontOfSize:largeSize]]); 593 | } 594 | 595 | #pragma mark private 596 | 597 | - (CGFloat)randomNumber { 598 | return arc4random_uniform(1000) / (CGFloat)(arc4random_uniform(9) + 1); 599 | } 600 | 601 | @end 602 | --------------------------------------------------------------------------------