Skip to content

Commit 35b70da

Browse files
authored
Fonts and Fixes (#37)
* fix to enabling scrolling when with react apps - scroll keyword for react is scroll * added custom font support * added montserrat * added 3 more fonts
1 parent 1f052d6 commit 35b70da

23 files changed

+50
-2
lines changed

Package.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ let package = Package(
2727
name: "BuilderIO",
2828
dependencies: [
2929
"SwiftyJSON",
30-
]
30+
],
31+
resources: [
32+
.process("Resources/Fonts")
33+
]
3134
),
3235
]
3336
)

Sources/BuilderIO/BuilderIOManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public final class BuilderIOManager {
2424
"Warning: BuilderIOManager has already been configured. Ignoring subsequent configuration.")
2525
return
2626
}
27+
Font.registerFonts()
2728
_shared = BuilderIOManager(apiKey: apiKey, customNavigationScheme: customNavigationScheme)
2829
}
2930

Sources/BuilderIO/Components/BuilderBlock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct BuilderBlockLayout<Content: View>: View {
102102
// 1. Extract basic layout parameters
103103
let direction = responsiveStyles["flexDirection"] ?? "column"
104104
let wrap = responsiveStyles["flexWrap"] == "wrap" && direction == "row"
105-
let scroll = responsiveStyles["overflow"] == "auto" && direction == "row"
105+
let scroll = (responsiveStyles["overflow"] == "auto" || responsiveStyles["overflow"] == "scroll") && direction == "row"
106106

107107
let justify = responsiveStyles["justifyContent"]
108108
let alignItems = responsiveStyles["alignItems"]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Foundation
2+
import SwiftUI
3+
import UIKit
4+
5+
extension Font {
6+
public static func registerFonts() {
7+
_ = UIFont.registerFont(bundle: .module, fontName: "Lato-Regular", fontExtension: "ttf")
8+
_ = UIFont.registerFont(bundle: .module, fontName: "Poppins-Regular", fontExtension: "ttf")
9+
_ = UIFont.registerFont(bundle: .module, fontName: "Inter", fontExtension: "ttf")
10+
_ = UIFont.registerFont(bundle: .module, fontName: "Inter-Italic", fontExtension: "ttf")
11+
_ = UIFont.registerFont(bundle: .module, fontName: "SourceCodePro", fontExtension: "ttf")
12+
_ = UIFont.registerFont(bundle: .module, fontName: "SourceCodePro-Italic", fontExtension: "ttf")
13+
_ = UIFont.registerFont(bundle: .module, fontName: "Roboto", fontExtension: "ttf")
14+
_ = UIFont.registerFont(bundle: .module, fontName: "Roboto-Italic", fontExtension: "ttf")
15+
_ = UIFont.registerFont(bundle: .module, fontName: "OpenSans", fontExtension: "ttf")
16+
_ = UIFont.registerFont(bundle: .module, fontName: "OpenSans-Italic", fontExtension: "ttf")
17+
_ = UIFont.registerFont(bundle: .module, fontName: "Montserrat", fontExtension: "ttf")
18+
_ = UIFont.registerFont(bundle: .module, fontName: "Montserrat-Italic", fontExtension: "ttf")
19+
_ = UIFont.registerFont(bundle: .module, fontName: "Raleway", fontExtension: "ttf")
20+
_ = UIFont.registerFont(bundle: .module, fontName: "Raleway-Italic", fontExtension: "ttf")
21+
_ = UIFont.registerFont(bundle: .module, fontName: "Nunito", fontExtension: "ttf")
22+
_ = UIFont.registerFont(bundle: .module, fontName: "Nunito-Italic", fontExtension: "ttf")
23+
_ = UIFont.registerFont(bundle: .module, fontName: "DMSans", fontExtension: "ttf")
24+
_ = UIFont.registerFont(bundle: .module, fontName: "DMSans-Italic", fontExtension: "ttf")
25+
}
26+
27+
}
28+
29+
extension UIFont {
30+
31+
static func registerFont(bundle: Bundle, fontName: String, fontExtension: String) -> Bool {
32+
guard let fontURL = bundle.url(forResource: fontName, withExtension: fontExtension) else {
33+
fatalError("Couldn't find font \(fontName)")
34+
}
35+
guard let fontDataProvider = CGDataProvider(url: fontURL as CFURL) else {
36+
fatalError("Couldn't load data from the font \(fontName)")
37+
}
38+
guard let font = CGFont(fontDataProvider) else {
39+
fatalError("Couldn't create font from data")
40+
}
41+
var error: Unmanaged<CFError>?
42+
return CTFontManagerRegisterGraphicsFont(font, &error)
43+
}
44+
}
277 KB
Binary file not shown.
233 KB
Binary file not shown.
311 KB
Binary file not shown.
883 KB
Binary file not shown.
854 KB
Binary file not shown.
117 KB
Binary file not shown.

0 commit comments

Comments
 (0)