Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ let package = Package(
name: "BuilderIO",
dependencies: [
"SwiftyJSON",
]
],
resources: [
.process("Resources/Fonts")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt linting bit off here

]
),
]
)
1 change: 1 addition & 0 deletions Sources/BuilderIO/BuilderIOManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public final class BuilderIOManager {
"Warning: BuilderIOManager has already been configured. Ignoring subsequent configuration.")
return
}
Font.registerFonts()
_shared = BuilderIOManager(apiKey: apiKey, customNavigationScheme: customNavigationScheme)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/BuilderIO/Components/BuilderBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct BuilderBlockLayout<Content: View>: View {
// 1. Extract basic layout parameters
let direction = responsiveStyles["flexDirection"] ?? "column"
let wrap = responsiveStyles["flexWrap"] == "wrap" && direction == "row"
let scroll = responsiveStyles["overflow"] == "auto" && direction == "row"
let scroll = (responsiveStyles["overflow"] == "auto" || responsiveStyles["overflow"] == "scroll") && direction == "row"

let justify = responsiveStyles["justifyContent"]
let alignItems = responsiveStyles["alignItems"]
Expand Down
44 changes: 44 additions & 0 deletions Sources/BuilderIO/Extensions/Font.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Foundation
import SwiftUI
import UIKit

extension Font {
public static func registerFonts() {
_ = UIFont.registerFont(bundle: .module, fontName: "Lato-Regular", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Poppins-Regular", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Inter", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Inter-Italic", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "SourceCodePro", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "SourceCodePro-Italic", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Roboto", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Roboto-Italic", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "OpenSans", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "OpenSans-Italic", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Montserrat", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Montserrat-Italic", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Raleway", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Raleway-Italic", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Nunito", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "Nunito-Italic", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "DMSans", fontExtension: "ttf")
_ = UIFont.registerFont(bundle: .module, fontName: "DMSans-Italic", fontExtension: "ttf")
}

}

extension UIFont {

static func registerFont(bundle: Bundle, fontName: String, fontExtension: String) -> Bool {
guard let fontURL = bundle.url(forResource: fontName, withExtension: fontExtension) else {
fatalError("Couldn't find font \(fontName)")
}
guard let fontDataProvider = CGDataProvider(url: fontURL as CFURL) else {
fatalError("Couldn't load data from the font \(fontName)")
}
guard let font = CGFont(fontDataProvider) else {
fatalError("Couldn't create font from data")
}
var error: Unmanaged<CFError>?
return CTFontManagerRegisterGraphicsFont(font, &error)
}
}
Binary file not shown.
Binary file added Sources/BuilderIO/Resources/Fonts/DMSans.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Sources/BuilderIO/Resources/Fonts/Inter.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Sources/BuilderIO/Resources/Fonts/Nunito.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Sources/BuilderIO/Resources/Fonts/Raleway.ttf
Binary file not shown.
Binary file not shown.
Binary file added Sources/BuilderIO/Resources/Fonts/Roboto.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading