Skip to content

Commit

Permalink
Adjust Android fonts up by 1 since they appear to render smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
marcprux committed Sep 27, 2023
1 parent 32ea991 commit dace65f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions Sources/SkipUI/SkipUI/Text/Font.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 11 additions & 11 deletions Tests/SkipUITests/TextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit dace65f

Please sign in to comment.