Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions NSAttributedString+DDHTML/NSAttributedString+DDHTML.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ + (NSAttributedString *)attributedStringFromNode:(xmlNodePtr)xmlNode boldFont:(U
[nodeAttributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:[fontSize doubleValue]] range:nodeAttributedStringRange];
}
else if (fontName != nil && fontSize == nil) {
[nodeAttributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:fontName size:12.0] range:nodeAttributedStringRange];
[nodeAttributedString addAttribute:NSFontAttributeName value:[self fontOrSystemFontForName:fontName size:12.0] range:nodeAttributedStringRange];
}
else if (fontName != nil && fontSize != nil) {
[nodeAttributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:fontName size:[fontSize doubleValue]] range:nodeAttributedStringRange];
[nodeAttributedString addAttribute:NSFontAttributeName value:[self fontOrSystemFontForName:fontName size:fontSize.floatValue] range:nodeAttributedStringRange];
}

if (foregroundColor) {
Expand Down Expand Up @@ -269,6 +269,14 @@ + (NSAttributedString *)attributedStringFromNode:(xmlNodePtr)xmlNode boldFont:(U
return nodeAttributedString;
}

+ (UIFont *)fontOrSystemFontForName:(NSString *)fontName size:(CGFloat)fontSize {
UIFont * font = [UIFont fontWithName:fontName size:fontSize];
if(font) {
return font;
}
return [UIFont systemFontOfSize:fontSize];
}

+ (UIColor *)colorFromHexString:(NSString *)hexString
{
if (hexString == nil)
Expand Down