Permalink
Browse files

Merge branch 'master' of github.com:Cocoanetics/DTCoreText

  • Loading branch information...
2 parents 7331163 + 131fe2b commit 985fd27d0be7eb38ba7f9085c97e336521a83423 @odrobnik odrobnik committed Sep 17, 2012
@@ -277,6 +277,7 @@ - (void)layoutSubviewsInRect:(CGRect)rect
if (existingAttachmentView)
{
existingAttachmentView.hidden = NO;
+ frameForSubview.origin.x += 50;
existingAttachmentView.frame = frameForSubview;
existingAttachmentView.alpha = 1;
@@ -243,7 +243,7 @@ - (void)updateFromStyleDictionary:(NSDictionary *)styles
- (NSString *)description
{
- return [NSString stringWithFormat:@"<%@ %p type=%d position=%d>", NSStringFromClass([self class]), self, _type, _position];
+ return [NSString stringWithFormat:@"<%@ %p type=%d position=%d>", NSStringFromClass([self class]), self, (int)_type, (int)_position];
}
#pragma mark Copying
@@ -297,12 +297,12 @@ - (NSString *)prefixWithCounter:(NSInteger)counter
}
case DTCSSListStyleTypeDecimal:
{
- token = [NSString stringWithFormat:@"%d.", counter];
+ token = [NSString stringWithFormat:@"%d.", (int)counter];
break;
}
case DTCSSListStyleTypeDecimalLeadingZero:
{
- token = [NSString stringWithFormat:@"%02d.", counter];
+ token = [NSString stringWithFormat:@"%02d.", (int)counter];
break;
}
case DTCSSListStyleTypeDisc:
@@ -78,20 +78,20 @@
*/
- (NSString *)htmlHexString;
-
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
/**
Converts a CGColorRef into an NSColor by placing each component into an NSColor and pending on the component count to return a grayscale or rgb color. If there are not 2 (grayscale) or 4 (rgba) components the color is from an unsupported color space and nil is returned.
@param cgColor The CGColorRef to convert
@returns An NSColor of this CGColorRef
*/
+ (NSColor *)colorWithCGColor:(CGColorRef)cgColor;
-
/**
Pass through method. This is used for unit testing
@returns This color. Returns self.
*/
- (NSColor *)CGColor;
+#endif
@end
@@ -490,7 +490,7 @@ - (NSString *)htmlHexString
(NSUInteger)(green * (CGFloat)255), (NSUInteger)(blue * (CGFloat)255)];
}
-
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8
+ (NSColor *)colorWithCGColor:(CGColorRef)cgColor
{
size_t count = CGColorGetNumberOfComponents(cgColor);
@@ -517,6 +517,7 @@ - (NSColor *)CGColor
{
return self;
}
+#endif
@end
@@ -532,9 +532,9 @@ - (void)_buildLines
}
// note: building line by line with typesetter
- [self _buildLinesWithTypesetter];
+ //[self _buildLinesWithTypesetter];
- //[self _buildLinesWithStandardFramesetter];
+ [self _buildLinesWithStandardFramesetter];
}
- (NSArray *)lines
@@ -18,6 +18,7 @@
@interface DTLazyImageView : UIImageView
@property (nonatomic, strong) NSURL *url;
+@property (nonatomic, strong) NSMutableURLRequest *urlRequest;
@property (nonatomic, assign) BOOL shouldShowProgressiveDownload;
@property (nonatomic, assign) id<DTLazyImageViewDelegate> delegate; // subtle simulator bug - use assign not __unsafe_unretained
@@ -52,9 +52,14 @@ - (void)loadImageAtURL:(NSURL *)url
@autoreleasepool
{
- NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:10.0];
+ if (_urlRequest == nil) {
+ _urlRequest = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:10.0];
+ } else {
+ [_urlRequest setCachePolicy:NSURLRequestReturnCacheDataElseLoad];
+ [_urlRequest setTimeoutInterval:10.0];
+ }
- _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
+ _connection = [[NSURLConnection alloc] initWithRequest:_urlRequest delegate:self startImmediately:NO];
[_connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
[_connection start];
@@ -67,7 +72,7 @@ - (void)didMoveToSuperview
{
[super didMoveToSuperview];
- if (!self.image && _url && !_connection && self.superview)
+ if (!self.image && (_url || _urlRequest) && !_connection && self.superview)
{
UIImage *image = [_imageCache objectForKey:_url];
@@ -277,5 +282,11 @@ - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)err
@synthesize url = _url;
@synthesize shouldShowProgressiveDownload;
+@synthesize urlRequest = _urlRequest;
+
+- (void) setUrlRequest:(NSMutableURLRequest *)request {
+ _urlRequest = request;
+ self.url = [_urlRequest URL];
+}
@end
@@ -464,7 +464,7 @@ - (NSString *)htmlString
if (headerLevel)
{
- blockElement = [NSString stringWithFormat:@"h%d", [headerLevel integerValue]];
+ blockElement = [NSString stringWithFormat:@"h%d", (int)[headerLevel integerValue]];
}
if ([paragraphs lastObject] == oneParagraph)
@@ -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];
@@ -17,7 +17,7 @@ @implementation NSString (HTML)
- (NSUInteger)integerValueFromHex
{
- NSUInteger result = 0;
+ int result = 0;
sscanf([self UTF8String], "%x", &result);
return result;
}
@@ -10,7 +10,7 @@
#import "DTHTMLAttributedStringBuilder.h"
#import "NSString+SlashEscaping.h"
-#import </usr/include/objc/objc-class.h>
+#import <objc/objc-class.h>
#define TESTCASE_FILE_EXTENSION @"html"
//#define ONLY_TEST_CURRENT 1
@@ -57,6 +57,11 @@ + (void)initialize
{
continue;
}
+#else
+ if ([[testFile lastPathComponent] isEqualToString:@"CurrentTest.html"])
+ {
+ continue;
+ }
#endif
if (![[testFile pathExtension] isEqualToString:TESTCASE_FILE_EXTENSION])
@@ -75,7 +80,7 @@ + (void)initialize
[test internalTestCaseWithURL:URL withTempPath:tempPath];
};
- IMP myIMP = imp_implementationWithBlock((__bridge void *)impBlock);
+ IMP myIMP = imp_implementationWithBlock((__bridge id)((__bridge void *)impBlock));
SEL selector = NSSelectorFromString(selectorName);
@@ -125,8 +130,6 @@ - (void)internalTestCaseWithURL:(NSURL *)URL withTempPath:(NSString *)tempPath
// our own builder
DTHTMLAttributedStringBuilder *doc = [[DTHTMLAttributedStringBuilder alloc] initWithHTML:testData options:nil documentAttributes:NULL];
- [doc buildString];
-
NSAttributedString *iosAttributedString = [doc generatedAttributedString];
NSString *iosString = [iosAttributedString string];
@@ -20,8 +20,6 @@ - (NSAttributedString *)attributedStringFromHTML:(NSString *)html
NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
DTHTMLAttributedStringBuilder*stringBuilder = [[DTHTMLAttributedStringBuilder alloc] initWithHTML:data options:nil documentAttributes:NULL];
- [stringBuilder buildString];
-
return [stringBuilder generatedAttributedString];
}
@@ -120,7 +118,8 @@ - (void)testMissingClosingTagAndSpacing
}
-- (void)testAttributedStringColorToHTML {
+- (void)testAttributedStringColorToHTML
+{
NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString: @"test"];
UIColor *color = [ UIColor colorWithRed: 1.0 green: 0.0 blue: 0.0 alpha: 1.0 ];
@@ -130,7 +129,6 @@ - (void)testAttributedStringColorToHTML {
NSString *expected = @"<span><span style=\"color:#ff0000;\">te</span>st</span>\n";
STAssertEqualObjects([ string htmlString ], expected, @"Output on HTML string color test differs");
-
}
@end
@@ -2058,7 +2058,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 4.2;
SDKROOT = iphoneos;
USER_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/Core/Source\"";
};
@@ -2079,7 +2079,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 4.2;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
USER_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/Core/Source\"";
@@ -1,9 +1 @@
-<head>
-<style>
- a:active {color:#0000FF;} /* selected link */
-</style>
-</head>
- <body>
-<p style="font-size:25px">Some text with a <u>Ag</u> <u>Bg</u> <a href="http://www.drobnik.com">Hg Hg Hg</a></p>
- <p style="font-size:50px">Some text with a <u>Hg</u> <a href="http://www.drobnik.com">Hg Hg Hg</a></p>
-</body>
+This is <sub>subscripted</sub> and <sup>superscripted</sup>
@@ -383,6 +383,7 @@ - (UIView *)attributedTextContentView:(DTAttributedTextContentView *)attributedT
}
else if (attachment.contentType == DTTextAttachmentTypeIframe)
{
+ frame.origin.x += 50;
DTWebVideoView *videoView = [[DTWebVideoView alloc] initWithFrame:frame];
videoView.attachment = attachment;

0 comments on commit 985fd27

Please sign in to comment.