Open 0xifarouk opened 2 years ago
How can I achieve apple spacing between lines?
Code I am using:
public func returnAttributedStringForHTMLString( fontFamily: String, fontName: String, fontSize: CGFloat, textColor: UIColor, textAlignment: CTTextAlignment ) -> NSMutableAttributedString { let encodedData = self.data(using: String.Encoding.utf8)! let options = [ DTDefaultFontFamily: fontFamily, DTDefaultFontName: fontName, DTDefaultFontSize: fontSize, DTDefaultTextColor: textColor, DTDefaultTextAlignment: NSNumber(value: textAlignment.rawValue), ] as [String : Any] let builder = DTHTMLAttributedStringBuilder(html: encodedData, options: options, documentAttributes: nil) var returnValue: NSAttributedString? returnValue = builder?.generatedAttributedString() if returnValue != nil { // needed to show link highlighting let mutable = NSMutableAttributedString(attributedString: returnValue!) mutable.removeAttribute(NSAttributedString.Key.foregroundColor, range: NSMakeRange(0, mutable.length)) return mutable } else { return NSMutableAttributedString(string: "") } }
Call site:
Text( AttributedString( html.returnAttributedStringForHTMLString( fontFamily: "SF Text", fontName: "SF Text Regular", fontSize: 17, textColor: .label, textAlignment: .left ) ) )
Also I want to use default apple font that comes with the system, I am using "SF Text" for fontFamily and "SF Text Regular" for fontName, is this correct? or if there is a way to omit the parameters and automatically use the system font.
How can I achieve apple spacing between lines?
Code I am using:
Call site:
Also I want to use default apple font that comes with the system, I am using "SF Text" for fontFamily and "SF Text Regular" for fontName, is this correct? or if there is a way to omit the parameters and automatically use the system font.