Skip to content

Commit

Permalink
fix(fonts): properly apply fallback fonts
Browse files Browse the repository at this point in the history
bump version to 0.3.1
  • Loading branch information
pylixonly committed May 19, 2024
1 parent bfb0aa6 commit b0b4838
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Resources/payload-base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
globalThis.__PYON_LOADER__ = {
loaderName: "BunnyTweak",
loaderVersion: "0.3.0",
loaderVersion: "0.3.1",
hasThemeSupport: true,
storedTheme: null,
fontPatch: 2
Expand Down
10 changes: 7 additions & 3 deletions Sources/BunnyTweak/Fonts.x.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ var fontMap: [String: String] = [:]
class FontsHook: ClassHook<UIFont> {
class func fontWithName(_ name: String, size: CGFloat) -> UIFont {
if let replacementName = fontMap[name] {
return UIFont(name: replacementName, size: size)!
let replacementDescriptor = UIFontDescriptor(name: replacementName, size: size)
let fallbackDescriptor = replacementDescriptor.addingAttributes([.name: [name]])
let finalDescriptor = replacementDescriptor.addingAttributes([.cascadeList: [fallbackDescriptor]])

return orig.fontWithDescriptor(finalDescriptor, size: size)
}

return orig.fontWithName(name, size: size)
}
class func fontWithDescriptor(_ descriptor: UIFontDescriptor, size: CGFloat) -> UIFont {
if let replacementName = fontMap[descriptor.postscriptName] {
let replacementDescriptor = UIFontDescriptor(name: replacementName, size: size)
.addingAttributes(descriptor.fontAttributes)
let finalDescriptor = replacementDescriptor.addingAttributes([.cascadeList: [descriptor]])

return orig.fontWithDescriptor(replacementDescriptor, size: size)
return orig.fontWithDescriptor(finalDescriptor, size: size)
}

return orig.fontWithDescriptor(descriptor, size: size)
Expand Down
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: io.github.pyoncord.app
Name: Bunny
Version: 0.3.0
Version: 0.3.1
Architecture: iphoneos-arm
Description: A mod for Discord's mobile apps.
Maintainer: Pylix
Expand Down

0 comments on commit b0b4838

Please sign in to comment.