From 0525444a4c9970b67df536b8d0d9236890e99fd0 Mon Sep 17 00:00:00 2001 From: Victoria Park Date: Mon, 2 Dec 2024 11:06:08 -0800 Subject: [PATCH] Silence font registration warning (#308) --- Sources/PaymentButtons/PaymentButton.swift | 2 +- Sources/PaymentButtons/PaymentButtonFont.swift | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/PaymentButtons/PaymentButton.swift b/Sources/PaymentButtons/PaymentButton.swift index b800b8f61..9b0d27c36 100644 --- a/Sources/PaymentButtons/PaymentButton.swift +++ b/Sources/PaymentButtons/PaymentButton.swift @@ -48,6 +48,7 @@ public class PaymentButton: UIButton { self.label = label self.analyticsService.sendEvent("payment-button:initialized", buttonType: fundingSource.rawValue) super.init(frame: .zero) + UIFont.registerFont() customizeAppearance() self.addTarget(self, action: #selector(onTap), for: .touchUpInside) } @@ -180,7 +181,6 @@ public class PaymentButton: UIButton { private func configure() { translatesAutoresizingMaskIntoConstraints = false - UIFont.registerFont() configureStackView() configureBackgroundColor() configurePrefix() diff --git a/Sources/PaymentButtons/PaymentButtonFont.swift b/Sources/PaymentButtons/PaymentButtonFont.swift index 0156bfbbb..2337f9bef 100644 --- a/Sources/PaymentButtons/PaymentButtonFont.swift +++ b/Sources/PaymentButtons/PaymentButtonFont.swift @@ -12,6 +12,10 @@ extension UIFont { var errorRef: Unmanaged? let frameworkBundle = Bundle(for: PaymentButton.self) + guard UIFont(name: name, size: 10.0) == nil else { + return + } + guard let pathForResourceString = frameworkBundle.path(forResource: name, ofType: fileExtension), let fontData = NSData(contentsOfFile: pathForResourceString),