I have an issue with thousand separator when I used bold font.
I have two fonts, 1 regular and 1 bold.
When I used regular one, thousand grouping separator (space) is displayed, when I used bold, thousand separator disappear.
extension Float {
/// Prints a Float as a currency token displayed like 1 000,00 €. The way it's displayed depends on the locale and currency symbol in its arguments
/// - Parameters:
/// - localeIdentitfier: Default to "fr_FR". It's the locale the float will be formated to
/// - currencySymbol: If nil defaults to the locale's default (€ if locale is "fr_FR", $ if locale if "en_US"). Use it to return a foreign
/// amount expressed in the locale format (eg "1 000.00 $" instead of "1 000.00 €")
/// - Returns: An amount expressed in a locale format and currency
public func toLocalCurrencyFormat(localeIdentitfier: String? = DefaultConstants.localeIdentitfier, currencyCode: String? = nil) -> String? {
let formatter: NumberFormatter = .defaultCurrency(currencyCode: currencyCode)
if let locale = localeIdentitfier {
formatter.locale = Locale(identifier: locale)
}
return toFormat(definedBy: formatter)
}
}
func createModel(balance: Double?) -> SubCardModel {
var label: String? = ""
if let balance = balance,
let balanceToLocalCurrency = Float(balance).toLocalCurrencyFormat() {
label = "(balanceToLocalCurrency)"
}
return SubCardModel(label: label)
}
public class SubCardView: NibView {
@IBOutlet weak var subTitleLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
subTitleLabel.font = Style.Fonts.title1
}
func initWith(model: SubCardModel) {
subTitleLabel.text = model.subtitle
}
}
public struct Style {
public struct Fonts {
public static let title1 = font(ofSize: 14.0, weight: .bold)
public static let title2 = font(ofSize: 14.0, weight: .regular)
internal static func font(ofSize: CGFloat, weight: UIFont.Weight) -> UIFont {
let font = weight == .regular ? FontFamily.MavenPro.regular:
FontFamily.MavenPro.bold
return font.font(size: ofSize)
}
}
}
Not space separator for thousand with bold font:
Space separator for thousand with regular font:
EDIT 1
Same bug with smaller amount
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…