Skip to content

Commit

Permalink
Added custom fonts with StyleFont for body and title.
Browse files Browse the repository at this point in the history
  • Loading branch information
richy486 committed Mar 26, 2024
1 parent f0fcdff commit 9df03d2
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIAppFonts</key>
<array>
<string>Nunito-Regular.ttf</string>
<string>NunitoSans_7pt_Condensed-Bold.ttf</string>
</array>
</dict>
</plist>
32 changes: 32 additions & 0 deletions MoreChess.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
B9FAC94B2BB06FB2002A20F7 /* WaitingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC94A2BB06FB2002A20F7 /* WaitingView.swift */; };
B9FAC94F2BB2E833002A20F7 /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC94E2BB2E833002A20F7 /* Color.swift */; };
B9FAC9512BB2F46D002A20F7 /* Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC9502BB2F46D002A20F7 /* Style.swift */; };
B9FAC9542BB2F706002A20F7 /* NunitoSans_7pt_Condensed-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B9FAC9532BB2F706002A20F7 /* NunitoSans_7pt_Condensed-Bold.ttf */; };
B9FAC9552BB2F706002A20F7 /* NunitoSans_7pt_Condensed-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B9FAC9532BB2F706002A20F7 /* NunitoSans_7pt_Condensed-Bold.ttf */; };
B9FAC9582BB2F92E002A20F7 /* Nunito-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B9FAC9572BB2F92E002A20F7 /* Nunito-Regular.ttf */; };
B9FAC9592BB2F92E002A20F7 /* Nunito-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B9FAC9572BB2F92E002A20F7 /* Nunito-Regular.ttf */; };
B9FAC95B2BB2FD0C002A20F7 /* Typography.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC95A2BB2FD0C002A20F7 /* Typography.swift */; };
B9FAC95C2BB2FD0C002A20F7 /* Typography.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9FAC95A2BB2FD0C002A20F7 /* Typography.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -122,6 +128,10 @@
B9FAC94A2BB06FB2002A20F7 /* WaitingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaitingView.swift; sourceTree = "<group>"; };
B9FAC94E2BB2E833002A20F7 /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = "<group>"; };
B9FAC9502BB2F46D002A20F7 /* Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Style.swift; sourceTree = "<group>"; };
B9FAC9532BB2F706002A20F7 /* NunitoSans_7pt_Condensed-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NunitoSans_7pt_Condensed-Bold.ttf"; sourceTree = "<group>"; };
B9FAC9572BB2F92E002A20F7 /* Nunito-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Nunito-Regular.ttf"; sourceTree = "<group>"; };
B9FAC95A2BB2FD0C002A20F7 /* Typography.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typography.swift; sourceTree = "<group>"; };
B9FAC95E2BB2FE66002A20F7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -161,6 +171,7 @@
children = (
B95CE50E2AD4CB5B00978591 /* Shared */,
B95CE51D2AD4CB5E00978591 /* macOS */,
B9FAC95E2BB2FE66002A20F7 /* Info.plist */,
B95CE5262AD4CB5E00978591 /* Tests iOS */,
B95CE5322AD4CB5E00978591 /* Tests macOS */,
B95CE5172AD4CB5E00978591 /* Products */,
Expand Down Expand Up @@ -346,12 +357,23 @@
B9FAC94D2BB2E821002A20F7 /* Resources */ = {
isa = PBXGroup;
children = (
B9FAC9522BB2F6DB002A20F7 /* Fonts */,
B9FAC94E2BB2E833002A20F7 /* Color.swift */,
B9FAC95A2BB2FD0C002A20F7 /* Typography.swift */,
B9FAC9502BB2F46D002A20F7 /* Style.swift */,
);
path = Resources;
sourceTree = "<group>";
};
B9FAC9522BB2F6DB002A20F7 /* Fonts */ = {
isa = PBXGroup;
children = (
B9FAC9572BB2F92E002A20F7 /* Nunito-Regular.ttf */,
B9FAC9532BB2F706002A20F7 /* NunitoSans_7pt_Condensed-Bold.ttf */,
);
path = Fonts;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -477,7 +499,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B9FAC9542BB2F706002A20F7 /* NunitoSans_7pt_Condensed-Bold.ttf in Resources */,
B9FAC9192BAF070C002A20F7 /* Launch Screen.storyboard in Resources */,
B9FAC9582BB2F92E002A20F7 /* Nunito-Regular.ttf in Resources */,
B95CE53B2AD4CB5E00978591 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -486,7 +510,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B9FAC9592BB2F92E002A20F7 /* Nunito-Regular.ttf in Resources */,
B95CE53C2AD4CB5E00978591 /* Assets.xcassets in Resources */,
B9FAC9552BB2F706002A20F7 /* NunitoSans_7pt_Condensed-Bold.ttf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -511,6 +537,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B9FAC95B2BB2FD0C002A20F7 /* Typography.swift in Sources */,
B9FAC92A2BAF29DF002A20F7 /* Players.swift in Sources */,
B9FAC94F2BB2E833002A20F7 /* Color.swift in Sources */,
B9FAC93F2BB059CD002A20F7 /* GameService.swift in Sources */,
Expand Down Expand Up @@ -559,6 +586,7 @@
B90F55AD2BA6289800874F00 /* PieceView.swift in Sources */,
B94B61B12B461D3200C998F3 /* Piece.swift in Sources */,
B90F55AA2BA61F6E00874F00 /* MovesView.swift in Sources */,
B9FAC95C2BB2FD0C002A20F7 /* Typography.swift in Sources */,
B94B61F62B68F8D700C998F3 /* PieceGenerator.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -718,6 +746,7 @@
DEVELOPMENT_TEAM = KWV3LMSGNJ;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Info.plist;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand Down Expand Up @@ -749,6 +778,7 @@
DEVELOPMENT_TEAM = KWV3LMSGNJ;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Info.plist;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
Expand Down Expand Up @@ -784,6 +814,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Shared/Info.plist;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -812,6 +843,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Shared/Info.plist;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
12 changes: 12 additions & 0 deletions Shared/MoreChessApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import SwiftUI

@main
struct MoreChessApp: App {

/*
init() {
for family in UIFont.familyNames {
print("\(family)")
for name in UIFont.fontNames(forFamilyName: family) {
print(" \(name)")
}
}
}
*/

var body: some Scene {
WindowGroup {
ContentView()
Expand Down
3 changes: 2 additions & 1 deletion Shared/Presentation/Lobby/LobbyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ struct LobbyView: View {
private func home() -> some View {
VStack {
Text("Host or join a new game")

.font(StyleFont.title)
Text("Select one option")
HStack {
Button("Host") {
lobbyInteractor.select(serviceType: .host)
Expand Down
Binary file added Shared/Resources/Fonts/Nunito-Regular.ttf
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Shared/Resources/Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct StyleModifier: ViewModifier {
.frame(maxWidth: .infinity, maxHeight: .infinity) // TODO: add option to disable this line.
.background(Color.background)
.foregroundStyle(Color.foreground)
.environment(\.font, StyleFont.body)
}
}

Expand Down
24 changes: 24 additions & 0 deletions Shared/Resources/Typography.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Typography.swift
// MoreChess
//
// Created by Richard Adem on 3/26/24.
//

import SwiftUI

enum CustomFontNames {
static let nunitoSansCondensedBold = "NunitoSans7ptCondensed-Bold"
static let nunitoRegular = "Nunito-Regular"
}

struct StyleFont {
static var title: Font {
let scaledSize = UIFontMetrics.default.scaledValue(for: 26)
return Font.custom(CustomFontNames.nunitoSansCondensedBold, size: scaledSize)
}
static var body: Font {
let scaledSize = UIFontMetrics.default.scaledValue(for: 16)
return Font.custom(CustomFontNames.nunitoRegular, size: scaledSize)
}
}

0 comments on commit 9df03d2

Please sign in to comment.