File tree Expand file tree Collapse file tree 4 files changed +40
-6
lines changed Expand file tree Collapse file tree 4 files changed +40
-6
lines changed Original file line number Diff line number Diff line change @@ -64,10 +64,6 @@ public protocol FontFamily {
6464 func accessibilityBoldWeight( for weight: Typography . FontWeight ) -> Typography . FontWeight
6565}
6666
67- extension Typography {
68- fileprivate static let logger = Logger ( subsystem: " YMatterType " , category: " fonts " )
69- }
70-
7167// MARK: - Default implementations
7268
7369/// Default implementations
@@ -88,7 +84,9 @@ extension FontFamily {
8884 let name = fontName ( for: weight, compatibleWith: traitCollection)
8985 guard let font = UIFont ( name: name, size: pointSize) else {
9086 // Fallback to system font and log a message.
91- Typography . logger. warning ( " Custom font \( name) not properly installed. " )
87+ if YMatterType . isLoggingEnabled {
88+ YMatterType . fontLogger. warning ( " Custom font \( name) not properly installed. " )
89+ }
9290 return Typography . systemFamily. font (
9391 for: weight,
9492 pointSize: pointSize,
Original file line number Diff line number Diff line change 1+ //
2+ // YMatterType+Logging.swift
3+ // YMatterType
4+ //
5+ // Created by Sahil Saini on 04/04/23.
6+ // Copyright © 2023 Y Media Labs. All rights reserved.
7+ //
8+
9+ import os
10+
11+ /// Y—MatterType Settings
12+ public struct YMatterType {
13+ /// Whether console logging for warnings is enabled. Defaults to `true`.
14+ public static var isLoggingEnabled = true
15+ }
16+
17+ internal extension YMatterType {
18+ /// Logger for warnings related to font loading. cf. `FontFamily`
19+ static let fontLogger = Logger ( subsystem: " YMatterType " , category: " fonts " )
20+ }
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ extension Typography {
9292
9393struct NotoSansFactory : FontFamilyFactory {
9494 // Always returns Noto Sans font family
95- func getFontFamily( familyName: String , style: YMatterType . Typography . FontStyle ) -> YMatterType . FontFamily {
95+ func getFontFamily( familyName: String , style: Typography . FontStyle ) -> FontFamily {
9696 Typography . notoSans
9797 }
9898}
Original file line number Diff line number Diff line change 1+ //
2+ // YMatterType+LoggingTests.swift
3+ // YMatterType
4+ //
5+ // Created by Sahil Saini on 04/04/23.
6+ // Copyright © 2023 Y Media Labs. All rights reserved.
7+ //
8+
9+ import XCTest
10+ @testable import YMatterType
11+
12+ final class YMatterTypeLoggingTests : XCTestCase {
13+ func testDefaults( ) {
14+ XCTAssertTrue ( YMatterType . isLoggingEnabled)
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments