Skip to content

Commit

Permalink
Remove custom fonts used by Kanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Jun 24, 2024
1 parent 2ee755c commit f7743b6
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 180 deletions.
132 changes: 1 addition & 131 deletions WordPress/Classes/Utility/Kanvas/KanvasCameraCustomUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,141 +6,11 @@ public class KanvasCustomUI {

public static let shared = KanvasCustomUI()

private static let brightBlue = UIColor.muriel(color: MurielColor(name: .blue)).color(for: UITraitCollection(userInterfaceStyle: .dark))
private static let brightPink = UIColor.muriel(color: MurielColor(name: .pink)).color(for: UITraitCollection(userInterfaceStyle: .dark))
private static let brightRed = UIColor.muriel(color: MurielColor(name: .red)).color(for: UITraitCollection(userInterfaceStyle: .dark))
private static let brightOrange = UIColor.muriel(color: MurielColor(name: .orange)).color(for: UITraitCollection(userInterfaceStyle: .dark))

static private var firstPrimary: UIColor {
return KanvasCustomUI.primaryColors.first ?? UIColor.blue
}

static private var lastPrimary: UIColor {
return KanvasCustomUI.primaryColors.last ?? UIColor.green
}

private let pickerColors: [UIColor] = [KanvasCustomUI.firstPrimary] + KanvasCustomUI.primaryColors + [KanvasCustomUI.lastPrimary]

private let segmentColors: [UIColor] = KanvasCustomUI.primaryColors + KanvasCustomUI.primaryColors + [KanvasCustomUI.firstPrimary]

static private let primaryColors: [UIColor] = [.blue,
.purple,
.magenta,
.red,
.yellow,
.green]

private let backgroundColorCollection: [UIColor] = KanvasCustomUI.primaryColors

private let mangaColor: UIColor = brightPink
private let toonColor: UIColor = brightOrange

private let selectedColor = brightBlue // ColorPickerController:29
private let black25 = UIColor(white: 0, alpha: 0.25)

func cameraColors() -> KanvasColors {
let firstPrimary = KanvasCustomUI.primaryColors.first ?? .blue
return KanvasColors(
drawingDefaultColor: firstPrimary,
colorPickerColors: pickerColors,
selectedPickerColor: selectedColor,
timeSegmentColors: segmentColors,
backgroundColors: backgroundColorCollection,
strokeColor: firstPrimary,
sliderActiveColor: firstPrimary,
sliderOuterCircleColor: firstPrimary,
trimBackgroundColor: firstPrimary,
trashColor: Self.brightRed,
tooltipBackgroundColor: .systemRed,
closeButtonColor: black25,
cameraConfirmationColor: firstPrimary,
primaryButtonBackgroundColor: Self.brightRed,
permissionsButtonColor: Self.brightBlue,
permissionsButtonAcceptedBackgroundColor: UIColor.muriel(color: MurielColor(name: .green, shade: .shade20)),
overlayColor: UIColor.muriel(color: MurielColor.gray),
filterColors: [
.manga: mangaColor,
.toon: toonColor,
])
}

private static let cameraPermissions = KanvasFonts.CameraPermissions(titleFont: UIFont.systemFont(ofSize: 26, weight: .medium), descriptionFont: UIFont.systemFont(ofSize: 16), buttonFont: UIFont.systemFont(ofSize: 16, weight: .medium))
private static let drawer = KanvasFonts.Drawer(textSelectedFont: UIFont.systemFont(ofSize: 14, weight: .medium), textUnselectedFont: UIFont.systemFont(ofSize: 14))

func cameraFonts() -> KanvasFonts {
let paddingAdjustment: (UIFont) -> KanvasFonts.Padding? = { font in
if font == UIFont.systemFont(ofSize: font.pointSize) {
return KanvasFonts.Padding(topMargin: 8.0,
leftMargin: 5.7,
extraVerticalPadding: 0.125 * font.pointSize,
extraHorizontalPadding: 0)
}
else {
return nil
}
}
let editorFonts: [UIFont] = [.libreBaskerville(fontSize: 20), .nunitoBold(fontSize: 24), .pacifico(fontSize: 24), .shrikhand(fontSize: 22), .spaceMonoBold(fontSize: 20), .oswaldUpper(fontSize: 22)]
return KanvasFonts(permissions: Self.cameraPermissions,
drawer: Self.drawer,
editorFonts: editorFonts,
optionSelectorCellFont: UIFont.systemFont(ofSize: 16, weight: .medium),
mediaClipsFont: UIFont.systemFont(ofSize: 9.5),
mediaClipsSmallFont: UIFont.systemFont(ofSize: 8),
modeButtonFont: UIFont.systemFont(ofSize: 18.5),
speedLabelFont: UIFont.systemFont(ofSize: 16, weight: .medium),
timeIndicatorFont: UIFont.systemFont(ofSize: 16, weight: .medium),
colorSelectorTooltipFont:
UIFont.systemFont(ofSize: 14),
modeSelectorTooltipFont: UIFont.systemFont(ofSize: 15),
postLabelFont: UIFont.systemFont(ofSize: 14, weight: .medium),
gifMakerRevertButtonFont: UIFont.systemFont(ofSize: 15, weight: .bold),
paddingAdjustment: paddingAdjustment
)
fatalError()
}

func cameraImages() -> KanvasImages {
return KanvasImages(confirmImage: UIImage(named: "stories-confirm-button"), editorConfirmImage: UIImage(named: "stories-confirm-button"), nextImage: UIImage(named: "stories-next-button"))
}
}

extension UIFont {

static func libreBaskerville(fontSize: CGFloat) -> UIFont {
let font = UIFont(name: "LibreBaskerville-Regular", size: fontSize) ?? UIFont.systemFont(ofSize: fontSize, weight: .medium)
return UIFontMetrics.default.scaledFont(for: font)
}

static func nunitoBold(fontSize: CGFloat) -> UIFont {
let font = UIFont(name: "Nunito-Bold", size: fontSize) ?? UIFont.systemFont(ofSize: fontSize, weight: .medium)
return UIFontMetrics.default.scaledFont(for: font)
}

static func pacifico(fontSize: CGFloat) -> UIFont {
let font = UIFont(name: "Pacifico-Regular", size: fontSize) ?? UIFont.systemFont(ofSize: fontSize, weight: .medium)
return UIFontMetrics.default.scaledFont(for: font)
}

static func oswaldUpper(fontSize: CGFloat) -> UIFont {
let font = UIFont(name: "Oswald-Regular", size: fontSize) ?? UIFont.systemFont(ofSize: fontSize, weight: .medium)
return UIFontMetrics.default.scaledFont(for: font)
}

static func shrikhand(fontSize: CGFloat) -> UIFont {
let font = UIFont(name: "Shrikhand-Regular", size: fontSize) ?? UIFont.systemFont(ofSize: fontSize, weight: .medium)
return UIFontMetrics.default.scaledFont(for: font)
}

static func spaceMonoBold(fontSize: CGFloat) -> UIFont {
let font = UIFont(name: "SpaceMono-Bold", size: fontSize) ?? UIFont.systemFont(ofSize: fontSize, weight: .medium)
return UIFontMetrics.default.scaledFont(for: font)
}

@objc func fontByAddingSymbolicTrait(_ trait: UIFontDescriptor.SymbolicTraits) -> UIFont {
let modifiedTraits = fontDescriptor.symbolicTraits.union(trait)
guard let modifiedDescriptor = fontDescriptor.withSymbolicTraits(modifiedTraits) else {
assertionFailure("Unable to created modified font descriptor by adding a symbolic trait.")
return self
}
return UIFont(descriptor: modifiedDescriptor, size: pointSize)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import DGCharts
import Kanvas

// MARK: - StatsInsightsFilterDimension

Expand Down
Binary file removed WordPress/Fonts/LibreBaskerville-Regular.ttf
Binary file not shown.
Binary file removed WordPress/Fonts/Nunito-Bold.ttf
Binary file not shown.
Binary file removed WordPress/Fonts/Pacifico-Regular.ttf
Binary file not shown.
Binary file removed WordPress/Fonts/Shrikhand-Regular.ttf
Binary file not shown.
Binary file removed WordPress/Fonts/SpaceMono-Bold.ttf
Binary file not shown.
Binary file removed WordPress/Fonts/oswald_upper.ttf
Binary file not shown.
6 changes: 0 additions & 6 deletions WordPress/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,6 @@
<key>UIAppFonts</key>
<array>
<string>Noticons.ttf</string>
<string>oswald_upper.ttf</string>
<string>Shrikhand-Regular.ttf</string>
<string>LibreBaskerville-Regular.ttf</string>
<string>SpaceMono-Bold.ttf</string>
<string>Pacifico-Regular.ttf</string>
<string>Nunito-Bold.ttf</string>
<string>EBGaramond-Regular.ttf</string>
</array>
<key>UIBackgroundModes</key>
Expand Down
6 changes: 0 additions & 6 deletions WordPress/Jetpack/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,6 @@
<key>UIAppFonts</key>
<array>
<string>Noticons.ttf</string>
<string>oswald_upper.ttf</string>
<string>Shrikhand-Regular.ttf</string>
<string>LibreBaskerville-Regular.ttf</string>
<string>SpaceMono-Bold.ttf</string>
<string>Pacifico-Regular.ttf</string>
<string>Nunito-Bold.ttf</string>
</array>
<key>UIBackgroundModes</key>
<array>
Expand Down
Loading

0 comments on commit f7743b6

Please sign in to comment.