Permalink
Browse files

Add support for ZStrikethroughStyleAttributeName

ZStrikethroughStyleAttributeName takes the same values as
ZUnderlineStyleAttributeName but controls the presence and appearance of
a strikethrough.
  • Loading branch information...
Arvind Kunday authored and kballard committed Apr 25, 2011
1 parent 30d7699 commit a0eb6d9b9083c27e164f55872011f99fad97b153
@@ -343,6 +343,7 @@ static id getValueOrDefaultForRun(ZAttributeRun *run, NSString *key) {
[UIColor blackColor], ZForegroundColorAttributeName,
[UIColor clearColor], ZBackgroundColorAttributeName,
[NSNumber numberWithInt:ZUnderlineStyleNone], ZUnderlineStyleAttributeName,
+ [NSNumber numberWithInt:ZUnderlineStyleNone], ZStrikethroughStyleAttributeName,
nil];
}
value = [defaultValues objectForKey:key];
@@ -695,6 +696,11 @@ static CGSize drawOrSizeTextConstrainedToSize(BOOL performDraw, NSString *string
// we only support single for the time being
UIRectFill(CGRectMake(drawPoint.x, drawPoint.y + lineAscender, fragmentWidth, 1));
}
+ NSNumber *strikeThroughStyle = getValueOrDefaultForRun(currentRun, ZStrikethroughStyleAttributeName);
+ if([strikeThroughStyle integerValue] & ZUnderlineStyleMask) {
+ UIRectFill(CGRectMake(drawPoint.x, drawPoint.y - currentFont.xHeight / 2 + lineAscender, fragmentWidth, 2));
+ }
+
drawPoint.x += fragmentWidth;
glyphIdx += numGlyphs;
}
@@ -64,6 +64,7 @@ extern NSString * const ZFontAttributeName;
extern NSString * const ZForegroundColorAttributeName;
extern NSString * const ZBackgroundColorAttributeName;
extern NSString * const ZUnderlineStyleAttributeName;
+extern NSString * const ZStrikethroughStyleAttributeName;
enum {
ZUnderlineStyleNone = 0x00,
@@ -594,3 +594,4 @@ - (void)dealloc {
NSString * const ZForegroundColorAttributeName = @"ZForegroundColorAttributeName";
NSString * const ZBackgroundColorAttributeName = @"ZBackgroundColorAttributeName";
NSString * const ZUnderlineStyleAttributeName = @"ZUnderlineStyleAttributeName";
+NSString * const ZStrikethroughStyleAttributeName = @"ZStrikethroughStyleAttributeName";
@@ -72,6 +72,7 @@ - (void)loadView {
[str addAttribute:ZFontAttributeName value:[[FontManager sharedManager] zFontWithName:@"Abberancy" pointSize:30] range:NSMakeRange(11, 10)];
[str addAttribute:ZForegroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(11, 10)];
[str addAttribute:ZBackgroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(11, 10)];
+ [str addAttribute:ZStrikethroughStyleAttributeName value:[NSNumber numberWithInt:ZUnderlineStyleSingle] range:NSMakeRange(11, 10)];
[str addAttribute:ZUnderlineStyleAttributeName value:[NSNumber numberWithInt:ZUnderlineStyleSingle] range:NSMakeRange(47, 9)];
label4.zAttributedText = str;
[str release];

0 comments on commit a0eb6d9

Please sign in to comment.