From 2d0252311a872c61f8159a8af143d9cdc60edd52 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Jul 2023 10:44:06 -0500 Subject: [PATCH] updated attributedString Signed-off-by: Matt Bruce --- VDS/Extensions/NSAttributedString.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/VDS/Extensions/NSAttributedString.swift b/VDS/Extensions/NSAttributedString.swift index 814f3c98..871f6b18 100644 --- a/VDS/Extensions/NSAttributedString.swift +++ b/VDS/Extensions/NSAttributedString.swift @@ -19,20 +19,28 @@ extension NSAttributedString { } extension NSMutableAttributedString { - public static func mutableText(for text: String, textStyle: TextStyle, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { + public static func mutableText(for text: String, textStyle: TextStyle, useScaledFont: Bool = true, textColor: UIColor, alignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode) -> NSMutableAttributedString { //create the paragraph for specific properties let paragraph = NSMutableParagraphStyle() paragraph.alignment = alignment paragraph.lineBreakMode = lineBreakMode + var defaultFont = textStyle.font + var lineHeight = textStyle.lineHeight + + if useScaledFont { + lineHeight = textStyle.scaledLineHeight + defaultFont = defaultFont.scaledFont + } + //set lineHeight if textStyle.lineHeight > 0.0 { - paragraph.maximumLineHeight = textStyle.lineHeight + paragraph.maximumLineHeight = lineHeight } //create the attributeArray - var attributes: [NSAttributedString.Key : Any] = [.font: textStyle.font, + var attributes: [NSAttributedString.Key : Any] = [.font: defaultFont, .foregroundColor: textColor, .paragraphStyle: paragraph]