Permalink
Browse files

Implemented subscript/superscript support in htmlString.

Fixes #214
  • Loading branch information...
1 parent ba229fe commit 29e2c6fe5369caa663cebb8a504d9fff53956365 @odrobnik odrobnik committed Sep 6, 2012
Showing with 30 additions and 0 deletions.
  1. +30 −0 Core/Source/NSAttributedString+DTCoreText.m
View
30 Core/Source/NSAttributedString+DTCoreText.m
@@ -686,6 +686,34 @@ - (NSString *)htmlString
}
}
+ NSNumber *superscript = [attributes objectForKey:(id)kCTSuperscriptAttributeName];
+ if (superscript)
+ {
+ NSInteger style = [superscript integerValue];
+
+ switch (style)
+ {
+ case 1:
+ {
+ fontStyle = [fontStyle stringByAppendingString:@"vertical-align:super;"];
+ break;
+ }
+
+ case -1:
+ {
+ fontStyle = [fontStyle stringByAppendingString:@"vertical-align:sub;"];
+ break;
+ }
+
+ default:
+ {
+ // all other are baseline because we don't support anything else for text
+ fontStyle = [fontStyle stringByAppendingString:@"vertical-align:baseline;"];
+
+ break;
+ }
+ }
+ }
NSURL *url = [attributes objectForKey:DTLinkAttribute];
@@ -738,6 +766,8 @@ - (NSString *)htmlString
while ([closingStyles count]);
}
+ NSLog(@"%@", retString);
+
return retString;
}

0 comments on commit 29e2c6f

Please sign in to comment.