From b0b4838c6f7c0b4320796ffae9678b55a9fcc376 Mon Sep 17 00:00:00 2001 From: amsyarasyiq <82711525+amsyarasyiq@users.noreply.github.com> Date: Sun, 19 May 2024 17:41:59 +0800 Subject: [PATCH] fix(fonts): properly apply fallback fonts bump version to 0.3.1 --- Resources/payload-base.js | 2 +- Sources/BunnyTweak/Fonts.x.swift | 10 +++++++--- control | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Resources/payload-base.js b/Resources/payload-base.js index 66b4fb8..298e5af 100644 --- a/Resources/payload-base.js +++ b/Resources/payload-base.js @@ -1,6 +1,6 @@ globalThis.__PYON_LOADER__ = { loaderName: "BunnyTweak", - loaderVersion: "0.3.0", + loaderVersion: "0.3.1", hasThemeSupport: true, storedTheme: null, fontPatch: 2 diff --git a/Sources/BunnyTweak/Fonts.x.swift b/Sources/BunnyTweak/Fonts.x.swift index 14f9b71..acb6b16 100644 --- a/Sources/BunnyTweak/Fonts.x.swift +++ b/Sources/BunnyTweak/Fonts.x.swift @@ -16,7 +16,11 @@ var fontMap: [String: String] = [:] class FontsHook: ClassHook { 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) @@ -24,9 +28,9 @@ class FontsHook: ClassHook { 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) diff --git a/control b/control index 5fe9316..6506668 100644 --- a/control +++ b/control @@ -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