Skip to content

Commit 883ba7d

Browse files
committed
feat: create the main font structure
1 parent e448b32 commit 883ba7d

File tree

10 files changed

+1059
-45
lines changed

10 files changed

+1059
-45
lines changed

Sources/OpenSwiftUI/Views/Text Input and Output/Setting a font/Font.swift

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Font+Design.swift
3+
// OpenSwiftUI
4+
//
5+
// Created by Helbert Gomes on Jan 27, 2026.
6+
// Licensed under the MIT License. See LICENSE in the project root for license information.
7+
// SPDX-License-Identifier: MIT
8+
9+
import Foundation
10+
11+
extension Font {
12+
13+
/// A design to use for fonts.
14+
public enum Design : String, Codable, Equatable, Hashable, Sendable {
15+
16+
/// The default design.
17+
case `default`
18+
19+
/// The serif design.
20+
case serif
21+
22+
/// The rounded design.
23+
case rounded
24+
25+
/// The monospaced design.
26+
case monospaced
27+
}
28+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// Font+TextStyle.swift
3+
// OpenSwiftUI
4+
//
5+
// Created by Helbert Gomes on Jan 27, 2026.
6+
// Licensed under the MIT License. See LICENSE in the project root for license information.
7+
// SPDX-License-Identifier: MIT
8+
9+
import Foundation
10+
11+
extension Font {
12+
13+
/// A dynamic text style to use for fonts.
14+
public enum TextStyle : String, Codable, Equatable, Hashable, CaseIterable, Sendable {
15+
16+
/// The font style for large titles.
17+
case largeTitle
18+
19+
/// The font used for first level hierarchical headings.
20+
case title
21+
22+
/// The font used for second level hierarchical headings.
23+
case title2
24+
25+
/// The font used for third level hierarchical headings.
26+
case title3
27+
28+
/// The font used for headings.
29+
case headline
30+
31+
/// The font used for subheadings.
32+
case subheadline
33+
34+
/// The font used for body text.
35+
case body
36+
37+
/// The font used for callouts.
38+
case callout
39+
40+
/// The font used in footnotes.
41+
case footnote
42+
43+
/// The font used for standard captions.
44+
case caption
45+
46+
/// The font used for alternate captions.
47+
case caption2
48+
}
49+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// Font+Weight.swift
3+
// OpenSwiftUI
4+
//
5+
// Created by Helbert Gomes on Jan 27, 2026.
6+
// Licensed under the MIT License. See LICENSE in the project root for license information.
7+
// SPDX-License-Identifier: MIT
8+
9+
import Foundation
10+
11+
extension Font {
12+
13+
/// A weight to use for fonts.
14+
@frozen public struct Weight : Codable, Equatable, Hashable, Sendable {
15+
16+
// MARK: - Getting font weights
17+
18+
/// The ultra light weight.
19+
public static let ultraLight = Font.Weight(value: -0.8)
20+
21+
/// The thin weight.
22+
public static let thin = Font.Weight(value: -0.6)
23+
24+
/// The light weight.
25+
public static let light = Font.Weight(value: -0.4)
26+
27+
/// The regular weight.
28+
public static let regular = Font.Weight(value: 0)
29+
30+
/// The medium weight.
31+
public static let medium = Font.Weight(value: 0.23)
32+
33+
/// The semibold weight.
34+
public static let semibold = Font.Weight(value: 0.3)
35+
36+
/// The bold weight.
37+
public static let bold = Font.Weight(value: 0.4)
38+
39+
/// The heavy weight.
40+
public static let heavy = Font.Weight(value: 0.56)
41+
42+
/// The black weight.
43+
public static let black = Font.Weight(value: 0.62)
44+
45+
// MARK: - Creating a font weight
46+
47+
/// The value of the weight.
48+
package let value: Double
49+
50+
/// Creates a new weight with the given value.
51+
///
52+
/// - Parameter value: The value of the weight.
53+
private init(value: Double) {
54+
self.value = value
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)