From dace65fd357ba0dbe92d9ad42d9182e7644d3786 Mon Sep 17 00:00:00 2001 From: marcprux Date: Wed, 27 Sep 2023 14:18:37 -0400 Subject: [PATCH] Adjust Android fonts up by 1 since they appear to render smaller --- Sources/SkipUI/SkipUI/Text/Font.swift | 22 +++++++++++----------- Tests/SkipUITests/TextTests.swift | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Sources/SkipUI/SkipUI/Text/Font.swift b/Sources/SkipUI/SkipUI/Text/Font.swift index 92f19589..ae718536 100644 --- a/Sources/SkipUI/SkipUI/Text/Font.swift +++ b/Sources/SkipUI/SkipUI/Text/Font.swift @@ -45,47 +45,47 @@ extension Font { // manual offsets are applied to the default font sizes to get them to line up with SwiftUI default sizes; see TextTests.swift public static let largeTitle = Font(fontImpl: { - adjust(MaterialTheme.typography.titleLarge, by: Float(+8.0)) // 41.0px height + adjust(MaterialTheme.typography.titleLarge, by: Float(+9.0 + 1.0)) }) public static let title = Font(fontImpl: { - adjust(MaterialTheme.typography.headlineMedium, by: Float(-3.0)) + adjust(MaterialTheme.typography.headlineMedium, by: Float(-2.0)) }) public static let title2 = Font(fontImpl: { - adjust(MaterialTheme.typography.headlineSmall, by: Float(-5.0)) + adjust(MaterialTheme.typography.headlineSmall, by: Float(-5.0 + 1.0)) }) public static let title3 = Font(fontImpl: { - adjust(MaterialTheme.typography.headlineSmall, by: Float(-6.5)) + adjust(MaterialTheme.typography.headlineSmall, by: Float(-6.0)) }) public static let headline = Font(fontImpl: { - adjust(MaterialTheme.typography.titleMedium, by: Float(-1.0)) + adjust(MaterialTheme.typography.titleMedium, by: Float(0.0)) }) public static let subheadline = Font(fontImpl: { - adjust(MaterialTheme.typography.titleSmall, by: Float(-1.0)) + adjust(MaterialTheme.typography.titleSmall, by: Float(0.0)) }) public static let body = Font(fontImpl: { - adjust(MaterialTheme.typography.bodyLarge, by: Float(-1.0)) + adjust(MaterialTheme.typography.bodyLarge, by: Float(0.0)) }) public static let callout = Font(fontImpl: { - adjust(MaterialTheme.typography.bodyMedium, by: Float(+0.5)) + adjust(MaterialTheme.typography.bodyMedium, by: Float(+1.0)) }) public static let footnote = Font(fontImpl: { - adjust(MaterialTheme.typography.bodySmall, by: Float(-0.8)) + adjust(MaterialTheme.typography.bodySmall, by: Float(+0.0)) }) public static let caption = Font(fontImpl: { - adjust(MaterialTheme.typography.bodySmall, by: Float(-1.0)) + adjust(MaterialTheme.typography.bodySmall, by: Float(-0.75)) }) public static let caption2 = Font(fontImpl: { - adjust(MaterialTheme.typography.bodySmall, by: Float(-2.0)) + adjust(MaterialTheme.typography.bodySmall, by: Float(-1.0)) }) private static func adjust(_ style: androidx.compose.ui.text.TextStyle, by amount: Float) -> androidx.compose.ui.text.TextStyle { diff --git a/Tests/SkipUITests/TextTests.swift b/Tests/SkipUITests/TextTests.swift index 6f9c0cb9..fb441e24 100644 --- a/Tests/SkipUITests/TextTests.swift +++ b/Tests/SkipUITests/TextTests.swift @@ -15,7 +15,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeLargeTitle() throws { let size = try render(view: Text("X").font(.largeTitle)).size #if SKIP - XCTAssertEqual(size.height, 41.0) + XCTAssertEqual(size.height, 41.0 + 2.0) #elseif os(iOS) XCTAssertEqual(size.height, 41.0) #elseif os(macOS) @@ -26,7 +26,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeTitle() throws { let size = try render(view: Text("X").font(.title)).size #if SKIP - XCTAssertEqual(size.height, 34.0) + XCTAssertEqual(size.height, 34.0 + 2.0) #elseif os(iOS) XCTAssertEqual(size.height, 34.0) #elseif os(macOS) @@ -37,7 +37,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeTitle2() throws { let size = try render(view: Text("X").font(.title2)).size #if SKIP - XCTAssertEqual(size.height, 27.0) + XCTAssertEqual(size.height, 27.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 27.0) #elseif os(macOS) @@ -48,7 +48,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeTitle3() throws { let size = try render(view: Text("X").font(.title3)).size #if SKIP - XCTAssertEqual(size.height, 24.0) + XCTAssertEqual(size.height, 24.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 24.0) #elseif os(macOS) @@ -59,7 +59,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeHeadline() throws { let size = try render(view: Text("X").font(.headline)).size #if SKIP - XCTAssertEqual(size.height, 21.0) + XCTAssertEqual(size.height, 21.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 21.0) #elseif os(macOS) @@ -70,7 +70,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeSubheadline() throws { let size = try render(view: Text("X").font(.subheadline)).size #if SKIP - XCTAssertEqual(size.height, 18.0) + XCTAssertEqual(size.height, 18.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 18.0) #elseif os(macOS) @@ -81,7 +81,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeBody() throws { let size = try render(view: Text("X").font(.body)).size #if SKIP - XCTAssertEqual(size.height, 21.0) + XCTAssertEqual(size.height, 21.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 21.0) #elseif os(macOS) @@ -92,7 +92,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeCallout() throws { let size = try render(view: Text("X").font(.callout)).size #if SKIP - XCTAssertEqual(size.height, 20.0) + XCTAssertEqual(size.height, 20.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 20.0) #elseif os(macOS) @@ -103,7 +103,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeFootnote() throws { let size = try render(view: Text("X").font(.footnote)).size #if SKIP - XCTAssertEqual(size.height, 16.0) + XCTAssertEqual(size.height, 16.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 16.0) #elseif os(macOS) @@ -114,7 +114,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeCaption() throws { let size = try render(view: Text("X").font(.caption)).size #if SKIP - XCTAssertEqual(size.height, 15.0) + XCTAssertEqual(size.height, 15.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 15.0) #elseif os(macOS) @@ -125,7 +125,7 @@ final class TextTests: XCSnapshotTestCase { func testTextSizeCaption2() throws { let size = try render(view: Text("X").font(.caption2)).size #if SKIP - XCTAssertEqual(size.height, 14.0) // 17.0 + XCTAssertEqual(size.height, 14.0 + 1.0) #elseif os(iOS) XCTAssertEqual(size.height, 14.0) #elseif os(macOS)