From 65d125dd3d191de79fc192e0123fbb227e901fed Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Thu, 23 Feb 2017 19:05:47 +0100 Subject: [PATCH 01/20] Fixed warning for AppleTV --- Core/Source/DTHTMLAttributedStringBuilder.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/Source/DTHTMLAttributedStringBuilder.m b/Core/Source/DTHTMLAttributedStringBuilder.m index b58127e0c..8bf17ae4c 100644 --- a/Core/Source/DTHTMLAttributedStringBuilder.m +++ b/Core/Source/DTHTMLAttributedStringBuilder.m @@ -8,6 +8,7 @@ #import #import +#import #import "DTHTMLAttributedStringBuilder.h" @@ -421,7 +422,7 @@ - (void)_registerTagStartHandlers NSURL *link = [NSURL URLWithString:cleanString]; if (link == nil) { - link = [NSURL URLWithString:[cleanString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + link = [NSURL URLWithString:[cleanString stringByURLEncoding]]; } // deal with relative URL From be92d41ce5d2548f59a8f6d60735c6713696488e Mon Sep 17 00:00:00 2001 From: lisi Date: Wed, 1 Mar 2017 14:53:27 +0800 Subject: [PATCH 02/20] support

text-indent --- Core/Source/DTHTMLAttributedStringBuilder.m | 10 +++++++++- Core/Source/DTHTMLElement.h | 8 ++++++++ Core/Source/DTHTMLElement.m | 7 +++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Core/Source/DTHTMLAttributedStringBuilder.m b/Core/Source/DTHTMLAttributedStringBuilder.m index 8bf17ae4c..8e9d2e512 100644 --- a/Core/Source/DTHTMLAttributedStringBuilder.m +++ b/Core/Source/DTHTMLAttributedStringBuilder.m @@ -589,7 +589,15 @@ - (void)_registerTagStartHandlers void (^pBlock)(void) = ^ { - _currentTag.paragraphStyle.firstLineHeadIndent = _currentTag.paragraphStyle.headIndent + _defaultParagraphStyle.firstLineHeadIndent; + // if have the custom headIndent + if (_defaultParagraphStyle.firstLineHeadIndent > 0) + { + _currentTag.paragraphStyle.firstLineHeadIndent = _currentTag.paragraphStyle.headIndent + _defaultParagraphStyle.firstLineHeadIndent; + } + else + { + _currentTag.paragraphStyle.firstLineHeadIndent = _currentTag.paragraphStyle.headIndent + _currentTag.pTextIndent; + } }; [_tagStartHandlers setObject:[pBlock copy] forKey:@"p"]; diff --git a/Core/Source/DTHTMLElement.h b/Core/Source/DTHTMLElement.h index 5fa68576b..5aa91f76c 100644 --- a/Core/Source/DTHTMLElement.h +++ b/Core/Source/DTHTMLElement.h @@ -76,6 +76,9 @@ // indent of lists CGFloat _listIndent; + // indent of tag

+ CGFloat _pTextIndent; + BOOL _shouldProcessCustomHTMLAttributes; } @@ -169,6 +172,11 @@ */ @property (nonatomic, assign) CGFloat backgroundCornerRadius; +/** + Tag

text indent + */ +@property (nonatomic, assign) CGFloat pTextIndent; + /** The custom letter spacing of the receiver, default is 0px */ diff --git a/Core/Source/DTHTMLElement.m b/Core/Source/DTHTMLElement.m index 22064d044..49c59d06c 100644 --- a/Core/Source/DTHTMLElement.m +++ b/Core/Source/DTHTMLElement.m @@ -1328,6 +1328,12 @@ - (void)applyStyleDictionary:(NSDictionary *)styles _backgroundCornerRadius = 0.0f; } + NSString *textIndentStr = [styles objectForKey:@"text-indent"]; + if (textIndentStr && [textIndentStr isCSSLengthValue]) + { + _pTextIndent = [textIndentStr pixelSizeOfCSSMeasureRelativeToCurrentTextSize:_currentTextSize textScale:_textScale]; + } + BOOL needsTextBlock = (_backgroundColor!=nil || _backgroundStrokeColor!=nil || _backgroundCornerRadius > 0 || _backgroundStrokeWidth > 0); BOOL hasMargins = NO; @@ -1727,6 +1733,7 @@ - (DTHTMLElement *)parentElement @synthesize backgroundStrokeWidth = _backgroundStrokeWidth; @synthesize backgroundCornerRadius = _backgroundCornerRadius; @synthesize letterSpacing = _letterSpacing; +@synthesize pTextIndent = _pTextIndent; @end From eb422ab43ec3052bb288e6e0aaf46e7370da2161 Mon Sep 17 00:00:00 2001 From: keremerkan Date: Sat, 18 Mar 2017 09:45:26 +0200 Subject: [PATCH 03/20] File name case correction It looks like upcoming versions of Xcode will complain on case sensitivity for included or imported files. This is a fix for the only warning on this project. --- Core/Source/DTHTMLAttributedStringBuilder.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Source/DTHTMLAttributedStringBuilder.m b/Core/Source/DTHTMLAttributedStringBuilder.m index 8e9d2e512..bf5500a61 100644 --- a/Core/Source/DTHTMLAttributedStringBuilder.m +++ b/Core/Source/DTHTMLAttributedStringBuilder.m @@ -15,7 +15,7 @@ #import "DTTextHTMLElement.h" #import "DTBreakHTMLElement.h" #import "DTStylesheetHTMLElement.h" -#import "DTCSSStyleSheet.h" +#import "DTCSSStylesheet.h" #import "DTCoreTextFontDescriptor.h" #import "DTHTMLParserTextNode.h" From b1c4d99744670ff58cede7af0425ad2042aab055 Mon Sep 17 00:00:00 2001 From: Mark Zeller Date: Tue, 28 Mar 2017 19:31:32 +0200 Subject: [PATCH 04/20] Fix HTML generation with multiline links When link and other attributes (i.e. background) overlap in the attributed string the first closing -tag is not rendered when the link contains a line break. --- Core/Source/DTHTMLWriter.m | 4 +- Test/Source/DTHTMLWriterTest.m | 298 +++++++++++++++++++++++++++++++++ 2 files changed, 300 insertions(+), 2 deletions(-) diff --git a/Core/Source/DTHTMLWriter.m b/Core/Source/DTHTMLWriter.m index fcd4a7f1b..c0f7e69b3 100644 --- a/Core/Source/DTHTMLWriter.m +++ b/Core/Source/DTHTMLWriter.m @@ -607,8 +607,8 @@ - (void)_buildOutputAsHTMLFragment:(BOOL)fragment }]; } - // check if previous link is over yet - if (NSMaxRange(spanRange) >= NSMaxRange(currentLinkRange)) + // check if the current link tag needs to be closed + if (currentLinkRange.location != NSNotFound && (NSMaxRange(spanRange) >= MIN(NSMaxRange(currentLinkRange), NSMaxRange(paragraphRange)))) { isLastPartOfHyperlink = YES; } diff --git a/Test/Source/DTHTMLWriterTest.m b/Test/Source/DTHTMLWriterTest.m index 7ee28a373..783dc399d 100644 --- a/Test/Source/DTHTMLWriterTest.m +++ b/Test/Source/DTHTMLWriterTest.m @@ -239,4 +239,302 @@ - (void)testKerningWithTextScale NSRange letterSpacingRange = [html rangeOfString:@"letter-spacing:10px;"]; XCTAssertTrue(letterSpacingRange.location == NSNotFound, @"Letter-spacing missing"); } + +#pragma mark - Link generation + +/** + * Text: first second third + * Link: [----] + */ +- (void)testSingleLineAnchor +{ + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"first second third"]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameValue" range:NSMakeRange(6, 6)]; // word "second" + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"" + "first " + "" + "second" + "" + " third" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} + +/** + * Text: single line blue link blue link + * Background: [------------] + * Link: [--] + */ +- (void)testSingleLineAnchorWithBackgroundColorAround +{ + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"single line blue link blue link"]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameValue" range:NSMakeRange(17, 4)]; // "link" + DTColor *color = DTColorCreateWithHexString(@"0000FF"); + [attributedString addAttribute:DTBackgroundColorAttribute value:(id)color.CGColor range:NSMakeRange(12, 14)]; // "blue link blue" + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"" + "single line " + "blue " + "" + "link" + "" + " blue" + " link" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} + +/** + * Text: 111222333444 + * Background: [-----] + * Link: [-----] + */ +- (void)testSingleLineAnchorWithBackgroundColorAround2 +{ + DTColor *backgroundColor = DTColorCreateWithHexString(@"9b57b5"); + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"111222333444"]; + [attributedString addAttribute:DTBackgroundColorAttribute value:(id)backgroundColor.CGColor range:NSMakeRange(3, 7)]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameAttribute" range:NSMakeRange(2, 7)]; + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"" + "11" + "" + "1" + "222333" + "" + "4" + "44" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} + +/** + * Text: 111222333444 + * Background: [-----] + * Link: [-----] + */ +- (void)testSingleLineAnchorWithBackgroundColorAround3 +{ + DTColor *backgroundColor = DTColorCreateWithHexString(@"9b57b5"); + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"111222333444"]; + [attributedString addAttribute:DTBackgroundColorAttribute value:(id)backgroundColor.CGColor range:NSMakeRange(2, 7)]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameAttribute" range:NSMakeRange(3, 7)]; + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"" + "11" + "1" + "" + "222333" + "4" + "" + "44" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} + +/** + * Text: first line\nsecond line\nthird line + * Link: [---------------------] + */ +- (void)testMultiLineAnchor +{ + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"first line\nsecond line\nthird line"]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameValue" range:NSMakeRange(0, 22)]; // first and second line + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"

" + "" + "first line" + "" + "

\n" + "

" + "" + "second line" + "" + "

\n" + "" + "third line" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} + +/** + * Text: single line blue newline\nlink blue link + * Background: [---------------------] + * Link: [-----------] + */ +- (void)testMultiLineAnchorWithBackgroundColorAround +{ + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"single line blue newline\nlink blue link"]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameValue" range:NSMakeRange(17, 12)]; // "link" + DTColor *color = DTColorCreateWithHexString(@"0000FF"); + [attributedString addAttribute:DTBackgroundColorAttribute value:(id)color.CGColor range:NSMakeRange(12, 22)]; // "blue link blue" + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"

" + "single line " + "blue " + "" + "newline" + "" + "

\n" + "" + "" + "link" + "" + " blue" + " link" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} + +/** + * Text: 111\n222\n333\n444 + * Background: [------------] + * Link: [-------] + */ +- (void)testMultiLineAnchorWithExtendedBackgroundColorAround { + DTColor *backgroundColor = DTColorCreateWithHexString(@"9b57b5"); + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"111\n222\n333\n444"]; + [attributedString addAttribute:DTBackgroundColorAttribute value:(id)backgroundColor.CGColor range:NSMakeRange(2, 11)]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameAttribute" range:NSMakeRange(4, 7)]; + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"

" + "11" + "1" + "

\n" + "

" + "" + "222" + "" + "

\n" + "

" + "" + "333" + "" + "

\n" + "" + "4" + "44" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} + +/** + * Text: 111\n222\n333\n444 + * Background: [---] + * Link: [---] + */ +- (void)testMultiLineAnchorWithExtendedBackgroundColorAround2 +{ + DTColor *backgroundColor = DTColorCreateWithHexString(@"9b57b5"); + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"111\n222\n333\n444"]; + [attributedString addAttribute:DTBackgroundColorAttribute value:(id)backgroundColor.CGColor range:NSMakeRange(5, 4)]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameAttribute" range:NSMakeRange(6, 4)]; + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"

" + "111" + "

\n" + "

" + "2" + "2" + "" + "2" + "" + "

\n" + "

" + "" + "3" + "3" + "" + "3" + "

\n" + "" + "444" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} + +/** + * Text: 111\n222\n333\n444 + * Background: [---] + * Link: [---] + */ +- (void)testMultiLineAnchorWithExtendedBackgroundColorAround3 { + DTColor *backgroundColor = DTColorCreateWithHexString(@"9b57b5"); + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"111\n222\n333\n444"]; + [attributedString addAttribute:DTBackgroundColorAttribute value:(id)backgroundColor.CGColor range:NSMakeRange(6, 4)]; + [attributedString addAttribute:DTAnchorAttribute value:@"nameAttribute" range:NSMakeRange(5, 4)]; + + DTHTMLWriter *writer = [[DTHTMLWriter alloc] initWithAttributedString:attributedString]; + + NSString *generatedHTMLFragment = [writer HTMLFragment]; + NSString *expectedHTMLFragment = [NSString stringWithFormat: + @"

" + "111" + "

\n" + "

" + "2" + "" + "2" + "2" + "" + "

\n" + "

" + "" + "3" + "" + "3" + "3" + "

\n" + "" + "444" + "\n"]; + + XCTAssertTrue([generatedHTMLFragment isEqualToString:expectedHTMLFragment], @"Strings are not equal %@ %@", expectedHTMLFragment, generatedHTMLFragment); +} @end From 48a61b49a22858c6c59cc92461ec94e42758f13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=9C=89=E9=98=B3?= Date: Fri, 31 Mar 2017 15:48:14 +0800 Subject: [PATCH 05/20] remove redundant semicolon --- Core/Source/DTHTMLAttributedStringBuilder.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Source/DTHTMLAttributedStringBuilder.m b/Core/Source/DTHTMLAttributedStringBuilder.m index bf5500a61..4090cdf41 100644 --- a/Core/Source/DTHTMLAttributedStringBuilder.m +++ b/Core/Source/DTHTMLAttributedStringBuilder.m @@ -66,7 +66,7 @@ @implementation DTHTMLAttributedStringBuilder dispatch_group_t _stringAssemblyGroup; dispatch_queue_t _dataParsingQueue; dispatch_group_t _dataParsingGroup; - dispatch_queue_t _treeBuildingQueue;; + dispatch_queue_t _treeBuildingQueue; dispatch_group_t _treeBuildingGroup; // lookup table for blocks that deal with begin and end tags From cac13bbcce1862ec2bf44adb9f477fb2a3423e08 Mon Sep 17 00:00:00 2001 From: Mark Zeller Date: Sat, 1 Apr 2017 18:17:38 +0200 Subject: [PATCH 06/20] =?UTF-8?q?Do=20not=20add=20=E2=80=98Apple-converted?= =?UTF-8?q?-space=E2=80=99=20to=20attributed=20string=20when=20processing?= =?UTF-8?q?=20custom=20HTML=20attributes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The processing of whitespace wrapped in an ‘Apple-converted-space’-span is completely handled internally and should not be contained in the resulting attributed string. --- Core/Source/DTHTMLElement.m | 3 +++ .../DTHTMLAttributedStringBuilderTest.m | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Core/Source/DTHTMLElement.m b/Core/Source/DTHTMLElement.m index 49c59d06c..c489e641e 100644 --- a/Core/Source/DTHTMLElement.m +++ b/Core/Source/DTHTMLElement.m @@ -386,7 +386,10 @@ - (void)_addCustomHTMLAttributesToAttributedString:(NSMutableAttributedString *) [_attributes enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) { + // Ignore attributes on global ignore list if ([attributesToIgnore containsObject:key]) return; + // Ignore Apple-converted-space helper CSS class + if ([@"class" isEqualToString:key] && [@"Apple-converted-space" isEqualToString:value]) return; if (_CSSClassNamesToIgnoreForCustomAttributes && [key isEqualToString:@"class"]) { diff --git a/Test/Source/DTHTMLAttributedStringBuilderTest.m b/Test/Source/DTHTMLAttributedStringBuilderTest.m index 04bd519f3..afb2fe60c 100644 --- a/Test/Source/DTHTMLAttributedStringBuilderTest.m +++ b/Test/Source/DTHTMLAttributedStringBuilderTest.m @@ -7,6 +7,7 @@ // #import "DTHTMLAttributedStringBuilderTest.h" +#import "DTCoreTextConstants.h" @implementation DTHTMLAttributedStringBuilderTest @@ -134,6 +135,26 @@ - (void)testSuperfluousParagraphBreakAfterBR XCTAssertFalse([charBeforeTwo isEqualToString:@"\n"], @"Superfluous NL following BR"); } +/** + * Test converting HTML with 'Apple-converted-space' span into attributes strings. + * Even with 'DTProcessCustomHTMLAttributes' on there should be no reference in the resulting + * attributed string as the conversion is handled internally by DTCoreText. + */ +- (void)testCustomAttributeProcessingWithAppleConvertedSpaces +{ + NSDictionary *options = @{DTProcessCustomHTMLAttributes: @(YES)}; + NSAttributedString *attributedString = [self attributedStringFromHTMLString:@"

2 2

" options:options]; + + __block BOOL appleConvertedSpaceFound = NO; + [attributedString enumerateAttributesInRange:NSMakeRange(0, attributedString.length) options:NSAttributedStringEnumerationReverse usingBlock:^(NSDictionary * _Nonnull attrs, NSRange range, BOOL * _Nonnull stop) { + if([attrs[DTCustomAttributesAttribute][@"class"] isEqualToString:@"Apple-converted-space"]) { + appleConvertedSpaceFound |= YES; + } + }]; + + XCTAssertFalse(appleConvertedSpaceFound, @"There should be no custom class 'Apple-converted-space' as apple converted spaces are handled internally"); +} + #pragma mark - General Tests // tests functionality of dir attribute From 635c727028863bb1f0a71ceb20791604759b549c Mon Sep 17 00:00:00 2001 From: lisi Date: Mon, 17 Apr 2017 18:46:20 +0800 Subject: [PATCH 07/20] DTTextAttachmentHTMLElement to fit 100% width --- Core/Source/DTTextAttachmentHTMLElement.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/Source/DTTextAttachmentHTMLElement.m b/Core/Source/DTTextAttachmentHTMLElement.m index d971a34f2..cc0d26633 100644 --- a/Core/Source/DTTextAttachmentHTMLElement.m +++ b/Core/Source/DTTextAttachmentHTMLElement.m @@ -100,6 +100,15 @@ - (void)applyStyleDictionary:(NSDictionary *)styles _textAttachment.originalSize = _size; } + NSString *widthString = [styles objectForKey:@"width"]; + + if (widthString.length > 1 && [widthString hasSuffix:@"%"]) + { + CGFloat scale = (CGFloat)([[widthString substringToIndex:widthString.length - 1] floatValue] / 100.0); + + _size.width = _maxDisplaySize.width * scale; + } + // update the display size [_textAttachment setDisplaySize:_size withMaxDisplaySize:_maxDisplaySize]; } From 1d6ff46dee612dbc57b8b57320ed254d1f9109c7 Mon Sep 17 00:00:00 2001 From: lisi Date: Mon, 17 Apr 2017 20:07:53 +0800 Subject: [PATCH 08/20] add a test for DTTextAttachmentHTMLElement to fit 100% width --- Test/Source/DTHTMLElementTest.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Test/Source/DTHTMLElementTest.m b/Test/Source/DTHTMLElementTest.m index 595c9e916..cf05d8cf8 100644 --- a/Test/Source/DTHTMLElementTest.m +++ b/Test/Source/DTHTMLElementTest.m @@ -80,4 +80,30 @@ - (void)testAttachmentWithDisplayNone XCTAssertNil(attributedString, @"Text attachment should be invisible"); } +- (void)testAttachmentWithPercentWidth +{ + NSDictionary *styles1 = @{@"width" : @"100%"}; + NSDictionary *styles2 = @{@"width" : @"80%"}; + NSDictionary *styles3 = @{@"width" : @"110%"}; + + CGSize maxImageSize = CGSizeMake(500,500); + + NSMutableDictionary *options = [NSMutableDictionary dictionaryWithObjectsAndKeys: + [NSValue valueWithCGSize:maxImageSize], DTMaxImageSize, + [NSNumber numberWithFloat:16.0],DTDefaultFontSize, + nil]; + + DTHTMLElement *attachment = [DTHTMLElement elementWithName:@"img" attributes:nil options:options]; + + [attachment applyStyleDictionary:styles1]; + XCTAssertEqual(attachment.textAttachment.displaySize.width, 500, @"Text attachment width incorrect"); + + [attachment applyStyleDictionary:styles2]; + XCTAssertEqual(attachment.textAttachment.displaySize.width, 400, @"Text attachment width incorrect"); + + [attachment applyStyleDictionary:styles3]; + XCTAssertEqual(attachment.textAttachment.displaySize.width, 500, @"Text attachment width incorrect"); + +} + @end From e31dd6fcb90633beb1bfda75dc8c462c8343ef23 Mon Sep 17 00:00:00 2001 From: lisi Date: Wed, 19 Apr 2017 11:07:17 +0800 Subject: [PATCH 09/20] add NSString type of protection in DTCSSStylesheet --- Core/Source/DTCSSStylesheet.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/Source/DTCSSStylesheet.m b/Core/Source/DTCSSStylesheet.m index 664ce1485..f344ccc79 100644 --- a/Core/Source/DTCSSStylesheet.m +++ b/Core/Source/DTCSSStylesheet.m @@ -99,7 +99,7 @@ - (void)_uncompressShorthands:(NSMutableDictionary *)styles // list-style shorthand NSString *shortHand = [[styles objectForKey:@"list-style"] lowercaseString]; - if (shortHand) + if (shortHand && [shortHand isKindOfClass:[NSString class]]) { [styles removeObjectForKey:@"list-style"]; @@ -166,7 +166,7 @@ - (void)_uncompressShorthands:(NSMutableDictionary *)styles // font shorthand, see http://www.w3.org/TR/CSS21/fonts.html#font-shorthand shortHand = [styles objectForKey:@"font"]; - if (shortHand) + if (shortHand && [shortHand isKindOfClass:[NSString class]]) { NSString *fontStyle = @"normal"; NSArray *validFontStyles = [NSArray arrayWithObjects:@"italic", @"oblique", nil]; @@ -277,7 +277,7 @@ - (void)_uncompressShorthands:(NSMutableDictionary *)styles shortHand = [styles objectForKey:@"margin"]; - if (shortHand) + if (shortHand && [shortHand isKindOfClass:[NSString class]]) { NSArray *parts = [shortHand componentsSeparatedByString:@" "]; @@ -345,7 +345,7 @@ - (void)_uncompressShorthands:(NSMutableDictionary *)styles shortHand = [styles objectForKey:@"padding"]; - if (shortHand) + if (shortHand && [shortHand isKindOfClass:[NSString class]]) { NSArray *parts = [shortHand componentsSeparatedByString:@" "]; @@ -413,7 +413,7 @@ - (void)_uncompressShorthands:(NSMutableDictionary *)styles shortHand = [styles objectForKey:@"background"]; - if (shortHand) + if (shortHand && [shortHand isKindOfClass:[NSString class]]) { // ignore most tokens except background-color From 769b4b9139c79a1429719e459ac1ae4b71c67cee Mon Sep 17 00:00:00 2001 From: lisi Date: Wed, 19 Apr 2017 15:05:48 +0800 Subject: [PATCH 10/20] adapter DTTextAttachment height 100% --- Core/Source/DTTextAttachmentHTMLElement.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Core/Source/DTTextAttachmentHTMLElement.m b/Core/Source/DTTextAttachmentHTMLElement.m index cc0d26633..82b33a17f 100644 --- a/Core/Source/DTTextAttachmentHTMLElement.m +++ b/Core/Source/DTTextAttachmentHTMLElement.m @@ -101,7 +101,8 @@ - (void)applyStyleDictionary:(NSDictionary *)styles } NSString *widthString = [styles objectForKey:@"width"]; - + NSString *heightString = [styles objectForKey:@"height"]; + if (widthString.length > 1 && [widthString hasSuffix:@"%"]) { CGFloat scale = (CGFloat)([[widthString substringToIndex:widthString.length - 1] floatValue] / 100.0); @@ -109,6 +110,12 @@ - (void)applyStyleDictionary:(NSDictionary *)styles _size.width = _maxDisplaySize.width * scale; } + if (heightString.length > 1 && [heightString hasSuffix:@"%"]) + { + CGFloat scale = (CGFloat)([[heightString substringToIndex:heightString.length - 1] floatValue] / 100.0); + + _size.height = _maxDisplaySize.height * scale; + } // update the display size [_textAttachment setDisplaySize:_size withMaxDisplaySize:_maxDisplaySize]; } From 2a78af29fc8585cb5fb59165be4554185c7db58a Mon Sep 17 00:00:00 2001 From: lisi Date: Thu, 20 Apr 2017 09:47:48 +0800 Subject: [PATCH 11/20] add a test for DTTextAttachment height:100% --- Test/Source/DTHTMLElementTest.m | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Test/Source/DTHTMLElementTest.m b/Test/Source/DTHTMLElementTest.m index cf05d8cf8..be66e38e5 100644 --- a/Test/Source/DTHTMLElementTest.m +++ b/Test/Source/DTHTMLElementTest.m @@ -80,12 +80,13 @@ - (void)testAttachmentWithDisplayNone XCTAssertNil(attributedString, @"Text attachment should be invisible"); } -- (void)testAttachmentWithPercentWidth +- (void)testAttachmentWithPercentWidthAndHeight { - NSDictionary *styles1 = @{@"width" : @"100%"}; - NSDictionary *styles2 = @{@"width" : @"80%"}; - NSDictionary *styles3 = @{@"width" : @"110%"}; - + NSDictionary *styles1 = @{@"width" : @"100%",@"height" : @"100%"}; + NSDictionary *styles2 = @{@"width" : @"80%",@"height" : @"100%"}; + NSDictionary *styles3 = @{@"width" : @"110%",@"height" : @"80%"}; + NSDictionary *styles4 = @{@"width" : @"100%",@"height" : @"110%"}; + CGSize maxImageSize = CGSizeMake(500,500); NSMutableDictionary *options = [NSMutableDictionary dictionaryWithObjectsAndKeys: @@ -94,16 +95,24 @@ - (void)testAttachmentWithPercentWidth nil]; DTHTMLElement *attachment = [DTHTMLElement elementWithName:@"img" attributes:nil options:options]; + attachment.textAttachment.originalSize = CGSizeMake(1000, 800); [attachment applyStyleDictionary:styles1]; XCTAssertEqual(attachment.textAttachment.displaySize.width, 500, @"Text attachment width incorrect"); - + XCTAssertEqual(attachment.textAttachment.displaySize.height, 500, @"Text attachment height incorrect"); + [attachment applyStyleDictionary:styles2]; XCTAssertEqual(attachment.textAttachment.displaySize.width, 400, @"Text attachment width incorrect"); - + XCTAssertEqual(attachment.textAttachment.displaySize.height, 500, @"Text attachment height incorrect"); + [attachment applyStyleDictionary:styles3]; XCTAssertEqual(attachment.textAttachment.displaySize.width, 500, @"Text attachment width incorrect"); - + XCTAssertEqual(attachment.textAttachment.displaySize.height, 364, @"Text attachment height incorrect"); + + [attachment applyStyleDictionary:styles4]; + XCTAssertEqual(attachment.textAttachment.displaySize.width, 455, @"Text attachment width incorrect"); + XCTAssertEqual(attachment.textAttachment.displaySize.height, 500, @"Text attachment height incorrect"); } + @end From 3a5dcd94fde907d2ad18b1b92b3a8fab4519ff33 Mon Sep 17 00:00:00 2001 From: lisi Date: Fri, 21 Apr 2017 18:36:38 +0800 Subject: [PATCH 12/20] implemented Archiving --- Core/Source/NSAttributedString+HTML.h | 19 ++++++++ Core/Source/NSAttributedString+HTML.m | 69 +++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/Core/Source/NSAttributedString+HTML.h b/Core/Source/NSAttributedString+HTML.h index ce836cbf8..b7a6e799a 100644 --- a/Core/Source/NSAttributedString+HTML.h +++ b/Core/Source/NSAttributedString+HTML.h @@ -72,4 +72,23 @@ */ - (NSRange)rangeOfHTMLAttribute:(NSString *)name atIndex:(NSUInteger)index; +/** + Retrieves the NSAttributedString with NSData + + Currently only supports iOS by `___useiOS6Attributes`, if error occur return nil. + + @param data The data must generate by `convertToData` function + @return NSAttributedString from unarchiveObjectWithData, the data must generate by `convertToData` function + */ ++ (NSAttributedString *)attributedStringWithData:(NSData *)data; + +/** + Retrieves NSData with self + + Currently only supports iOS by `___useiOS6Attributes`, if error occur return nil. + + @return NSData from NSAttributedString execute archivedDataWithRootObject: + */ +- (NSData *)convertToData; + @end diff --git a/Core/Source/NSAttributedString+HTML.m b/Core/Source/NSAttributedString+HTML.m index 62691ba04..11f90fe70 100644 --- a/Core/Source/NSAttributedString+HTML.m +++ b/Core/Source/NSAttributedString+HTML.m @@ -14,6 +14,11 @@ #import "DTHTMLElement.h" #import "DTCoreTextConstants.h" #import "DTHTMLAttributedStringBuilder.h" +#import "DTTextAttachment.h" + +#if TARGET_OS_IPHONE +#import "NSAttributedStringRunDelegates.h" +#endif @implementation NSAttributedString (HTML) @@ -58,6 +63,70 @@ - (id)initWithHTMLData:(NSData *)data options:(NSDictionary *)options documentAt return string; } +#pragma mark - NSAttributedString Archiving + +- (NSData *)convertToData +{ + NSMutableAttributedString *appendString = [self mutableCopy]; +#if DTCORETEXT_SUPPORT_NS_ATTRIBUTES && TARGET_OS_IPHONE + NSUInteger length = [self length]; + if (length) + { + [self enumerateAttributesInRange:NSMakeRange(0, length-1) options:0 usingBlock:^(NSDictionary * _Nonnull attrs, NSRange range, BOOL * _Nonnull stop) { + + if (attrs[NSAttachmentAttributeName]) + { + [appendString removeAttribute:(id)kCTRunDelegateAttributeName range:range]; + } + }]; + } +#endif + + NSData *data = nil; + @try + { + data = [NSKeyedArchiver archivedDataWithRootObject:appendString]; + } + @catch (NSException *exception) + { + data = nil; + } + + return data; +} + ++ (NSAttributedString *)attributedStringWithData:(NSData *)data +{ + NSMutableAttributedString *appendString = nil; +#if DTCORETEXT_SUPPORT_NS_ATTRIBUTES && TARGET_OS_IPHONE + @try + { + appendString = (NSMutableAttributedString *)[NSKeyedUnarchiver unarchiveObjectWithData:data]; + } + @catch (NSException *exception) + { + appendString = nil; + } + + NSUInteger length = [appendString length]; + if (length) + { + [appendString enumerateAttributesInRange:NSMakeRange(0, length-1) options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(NSDictionary * _Nonnull attrs, NSRange range, BOOL * _Nonnull stop) { + + if (attrs[NSAttachmentAttributeName]) + { + DTTextAttachment *attatchment = attrs[NSAttachmentAttributeName]; + CTRunDelegateRef embeddedObjectRunDelegate = createEmbeddedObjectRunDelegate(attatchment); + + [appendString addAttribute:(id)kCTRunDelegateAttributeName value:CFBridgingRelease(embeddedObjectRunDelegate) range:range]; + } + + }]; + } +#endif + return [appendString copy]; +} + #pragma mark - Working with Custom HTML Attributes - (NSDictionary *)HTMLAttributesAtIndex:(NSUInteger)index From 88b8c4e2c5e9831b0f9ea5c9037c06064a3eb714 Mon Sep 17 00:00:00 2001 From: lisi Date: Mon, 24 Apr 2017 11:48:14 +0800 Subject: [PATCH 13/20] support `DTBackgroundStrokeColorAttribute` archiving --- Core/Source/DTCoreTextConstants.h | 1 + Core/Source/DTCoreTextConstants.m | 1 + Core/Source/NSAttributedString+HTML.m | 47 +++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Core/Source/DTCoreTextConstants.h b/Core/Source/DTCoreTextConstants.h index bca8e9557..a475d960b 100644 --- a/Core/Source/DTCoreTextConstants.h +++ b/Core/Source/DTCoreTextConstants.h @@ -82,6 +82,7 @@ extern NSString * const DTAscentMultiplierAttribute; extern NSString * const DTBackgroundStrokeColorAttribute; extern NSString * const DTBackgroundStrokeWidthAttribute; extern NSString * const DTBackgroundCornerRadiusAttribute; +extern NSString * const DTArchivingAttribute; // field constants diff --git a/Core/Source/DTCoreTextConstants.m b/Core/Source/DTCoreTextConstants.m index 1e609db0b..161977484 100644 --- a/Core/Source/DTCoreTextConstants.m +++ b/Core/Source/DTCoreTextConstants.m @@ -54,6 +54,7 @@ NSString * const DTBackgroundStrokeColorAttribute = @"DTBackgroundStrokeColor"; NSString * const DTBackgroundStrokeWidthAttribute = @"DTBackgroundStrokeWidth"; NSString * const DTBackgroundCornerRadiusAttribute = @"DTBackgroundCornerRadius"; +NSString * const DTArchivingAttribute = @"DTArchivingAttribute"; // field constants NSString * const DTListPrefixField = @"{listprefix}"; diff --git a/Core/Source/NSAttributedString+HTML.m b/Core/Source/NSAttributedString+HTML.m index 11f90fe70..d19fe4297 100644 --- a/Core/Source/NSAttributedString+HTML.m +++ b/Core/Source/NSAttributedString+HTML.m @@ -64,6 +64,24 @@ - (id)initWithHTMLData:(NSData *)data options:(NSDictionary *)options documentAt } #pragma mark - NSAttributedString Archiving ++ (NSMutableDictionary *)getArchivingDictionaryWith:(NSDictionary *)attrs +{ + + NSDictionary *archiveDict = attrs[DTArchivingAttribute]; + NSMutableDictionary *dict = nil; + + if (![archiveDict isKindOfClass:[NSDictionary class]]) + { + dict = [NSMutableDictionary dictionary]; + } + else + { + dict = [archiveDict mutableCopy]; + } + + + return dict; +} - (NSData *)convertToData { @@ -78,6 +96,18 @@ - (NSData *)convertToData { [appendString removeAttribute:(id)kCTRunDelegateAttributeName range:range]; } + // if there will others attribute to archiving , implement like this. + if (attrs[DTBackgroundStrokeColorAttribute]) + { + NSMutableDictionary *dict = [[self class] getArchivingDictionaryWith:attrs]; + CGColorRef strokeColor = (__bridge CGColorRef)(attrs[DTBackgroundStrokeColorAttribute]); + + UIColor *stoke = [[UIColor alloc] initWithCGColor:strokeColor]; + [dict setObject:stoke forKey:DTBackgroundStrokeColorAttribute]; + + [appendString setAttributes:dict range:range]; + [appendString removeAttribute:(id)DTBackgroundStrokeColorAttribute range:range]; + } }]; } #endif @@ -98,7 +128,6 @@ - (NSData *)convertToData + (NSAttributedString *)attributedStringWithData:(NSData *)data { NSMutableAttributedString *appendString = nil; -#if DTCORETEXT_SUPPORT_NS_ATTRIBUTES && TARGET_OS_IPHONE @try { appendString = (NSMutableAttributedString *)[NSKeyedUnarchiver unarchiveObjectWithData:data]; @@ -113,6 +142,8 @@ + (NSAttributedString *)attributedStringWithData:(NSData *)data { [appendString enumerateAttributesInRange:NSMakeRange(0, length-1) options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(NSDictionary * _Nonnull attrs, NSRange range, BOOL * _Nonnull stop) { +#if DTCORETEXT_SUPPORT_NS_ATTRIBUTES && TARGET_OS_IPHONE + if (attrs[NSAttachmentAttributeName]) { DTTextAttachment *attatchment = attrs[NSAttachmentAttributeName]; @@ -120,10 +151,22 @@ + (NSAttributedString *)attributedStringWithData:(NSData *)data [appendString addAttribute:(id)kCTRunDelegateAttributeName value:CFBridgingRelease(embeddedObjectRunDelegate) range:range]; } + // if there will others attribute to archiving , implement like this. + if (attrs[DTBackgroundStrokeColorAttribute]) + { + NSMutableDictionary *dict = [self getArchivingDictionaryWith:attrs]; + UIColor *stroke = dict[DTBackgroundStrokeColorAttribute]; + CGColorRef strokeColor = stroke.CGColor; + + [appendString addAttribute:DTBackgroundStrokeColorAttribute value:(__bridge id)strokeColor range:range]; + + [dict removeObjectForKey:DTBackgroundStrokeColorAttribute]; + [appendString setAttributes:dict range:range]; + } +#endif }]; } -#endif return [appendString copy]; } From 6af9de35df1d1c91e56206740cb534bebc837c12 Mon Sep 17 00:00:00 2001 From: lisi Date: Wed, 26 Apr 2017 10:22:05 +0800 Subject: [PATCH 14/20] public func abortParsing in DTHTMLParser --- Core/Source/DTHTMLAttributedStringBuilder.h | 14 +++++++ Core/Source/DTHTMLAttributedStringBuilder.m | 44 ++++++++++++++------- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/Core/Source/DTHTMLAttributedStringBuilder.h b/Core/Source/DTHTMLAttributedStringBuilder.h index 865b56db5..5227484a7 100644 --- a/Core/Source/DTHTMLAttributedStringBuilder.h +++ b/Core/Source/DTHTMLAttributedStringBuilder.h @@ -15,6 +15,11 @@ */ typedef void(^DTHTMLAttributedStringBuilderWillFlushCallback)(DTHTMLElement *); +/** + The block that gets executed whenever html tag parsing error + */ +typedef void(^DTHTMLAttributedStringBuilderParseErrorCallback)(NSAttributedString *attr, NSError *); + /** Class for building an `NSAttributedString` from an HTML document. @@ -71,10 +76,19 @@ typedef void(^DTHTMLAttributedStringBuilderWillFlushCallback)(DTHTMLElement *); This block is called before the element is written to the output attributed string */ @property (nonatomic, copy) DTHTMLAttributedStringBuilderWillFlushCallback willFlushCallback; +/** + The block that gets executed whenever html tag parsing error + */ +@property (nonatomic, copy) DTHTMLAttributedStringBuilderParseErrorCallback parseErrorCallback; /** Setting this property to `YES` causes the tree of parse nodes to be preserved until the end of the generation process. This allows to output the HTML structure of the document for debugging. */ @property (nonatomic, assign) BOOL shouldKeepDocumentNodeTree; +/** + This func can abort AttributedString building. + */ +- (void)abortParsing; + @end diff --git a/Core/Source/DTHTMLAttributedStringBuilder.m b/Core/Source/DTHTMLAttributedStringBuilder.m index 4090cdf41..1e21d92fc 100644 --- a/Core/Source/DTHTMLAttributedStringBuilder.m +++ b/Core/Source/DTHTMLAttributedStringBuilder.m @@ -74,6 +74,8 @@ @implementation DTHTMLAttributedStringBuilder NSMutableDictionary *_tagEndHandlers; DTHTMLAttributedStringBuilderWillFlushCallback _willFlushCallback; + DTHTMLAttributedStringBuilderParseErrorCallback _parseErrorCallback; + BOOL _shouldProcessCustomHTMLAttributes; // new parsing @@ -83,6 +85,8 @@ @implementation DTHTMLAttributedStringBuilder BOOL _ignoreParseEvents; // ignores events from parser after first HTML tag was finished BOOL _ignoreInlineStyles; // ignores style blocks attached on elements BOOL _preserverDocumentTrailingSpaces; // don't remove spaces at end of document + + DTHTMLParser *_parser; } - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary * __autoreleasing*)docAttributes @@ -94,6 +98,17 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib _options = options; // documentAttributes ignored for now + // Specify the appropriate text encoding for the passed data, default is UTF8 + NSString *textEncodingName = [_options objectForKey:NSTextEncodingNameDocumentOption]; + NSStringEncoding encoding = NSUTF8StringEncoding; // default + + if (textEncodingName) + { + CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)textEncodingName); + encoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding); + } + _parser = [[DTHTMLParser alloc] initWithData:_data encoding:encoding]; + _parser.delegate = (id)self; // GCD setup _stringAssemblyQueue = dispatch_queue_create("DTHTMLAttributedStringBuilder", 0); @@ -136,16 +151,6 @@ - (BOOL)_buildString [self _registerTagStartHandlers]; [self _registerTagEndHandlers]; - // Specify the appropriate text encoding for the passed data, default is UTF8 - NSString *textEncodingName = [_options objectForKey:NSTextEncodingNameDocumentOption]; - NSStringEncoding encoding = NSUTF8StringEncoding; // default - - if (textEncodingName) - { - CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)textEncodingName); - encoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding); - } - #if DTCORETEXT_SUPPORT_NS_ATTRIBUTES // custom option to use iOS 6 attributes if running on iOS 6 @@ -340,12 +345,8 @@ - (BOOL)_buildString // don't remove spaces at end of document _preserverDocumentTrailingSpaces = [[_options objectForKey:DTDocumentPreserveTrailingSpaces] boolValue]; - // create a parser - DTHTMLParser *parser = [[DTHTMLParser alloc] initWithData:_data encoding:encoding]; - parser.delegate = (id)self; - __block BOOL result; - dispatch_group_async(_dataParsingGroup, _dataParsingQueue, ^{ result = [parser parse]; }); + dispatch_group_async(_dataParsingGroup, _dataParsingQueue, ^{ result = [_parser parse]; }); // wait until all string assembly is complete dispatch_group_wait(_dataParsingGroup, DISPATCH_TIME_FOREVER); @@ -1000,9 +1001,22 @@ - (void)parserDidEndDocument:(DTHTMLParser *)parser }); } +- (void)parser:(DTHTMLParser *)parser parseErrorOccurred:(NSError *)parseError; +{ + if(_parseErrorCallback) + { + _parseErrorCallback(_tmpString,parseError); + } +} + +- (void)abortParsing +{ + [_parser abortParsing]; +} #pragma mark Properties @synthesize willFlushCallback = _willFlushCallback; @synthesize shouldKeepDocumentNodeTree = _shouldKeepDocumentNodeTree; +@synthesize parseErrorCallback = _parseErrorCallback; @end From 800b1ef407cd83a07d2ccbce8588c318d0748044 Mon Sep 17 00:00:00 2001 From: lisi Date: Mon, 22 May 2017 11:08:58 +0800 Subject: [PATCH 15/20] fix archive image url about NSHomeDirectory() --- Core/Source/NSAttributedString+HTML.m | 60 ++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/Core/Source/NSAttributedString+HTML.m b/Core/Source/NSAttributedString+HTML.m index d19fe4297..4e296bac2 100644 --- a/Core/Source/NSAttributedString+HTML.m +++ b/Core/Source/NSAttributedString+HTML.m @@ -48,7 +48,7 @@ - (id)initWithHTMLData:(NSData *)data options:(NSDictionary *)options documentAt } DTHTMLAttributedStringBuilder *stringBuilder = [[DTHTMLAttributedStringBuilder alloc] initWithHTML:data options:options documentAttributes:docAttributes]; - + void (^callBackBlock)(DTHTMLElement *element) = [options objectForKey:DTWillFlushBlockCallBack]; if (callBackBlock) @@ -66,7 +66,7 @@ - (id)initWithHTMLData:(NSData *)data options:(NSDictionary *)options documentAt #pragma mark - NSAttributedString Archiving + (NSMutableDictionary *)getArchivingDictionaryWith:(NSDictionary *)attrs { - + NSDictionary *archiveDict = attrs[DTArchivingAttribute]; NSMutableDictionary *dict = nil; @@ -78,7 +78,7 @@ + (NSMutableDictionary *)getArchivingDictionaryWith:(NSDictionary *)attrs { dict = [archiveDict mutableCopy]; } - + return dict; } @@ -92,26 +92,53 @@ - (NSData *)convertToData { [self enumerateAttributesInRange:NSMakeRange(0, length-1) options:0 usingBlock:^(NSDictionary * _Nonnull attrs, NSRange range, BOOL * _Nonnull stop) { + NSMutableDictionary *dict = [[self class] getArchivingDictionaryWith:attrs]; + if (attrs[NSAttachmentAttributeName]) { + DTTextAttachment *attatchment = attrs[NSAttachmentAttributeName]; + + NSString *imgPath = nil; + + if ([[attatchment.contentURL scheme] isEqualToString:@"file"]) + { + imgPath = [attatchment.contentURL path]; + NSUInteger homeDirLength = [NSHomeDirectory() length]; + + if ([imgPath hasPrefix:NSHomeDirectory()] && [imgPath length] > homeDirLength) + { + imgPath = [imgPath substringFromIndex:homeDirLength]; + } + } + else + { + imgPath = [attatchment.contentURL absoluteString]; + } + + if (imgPath) + { + [dict setObject:imgPath forKey:NSAttachmentAttributeName]; + [appendString addAttribute:DTArchivingAttribute value:dict range:range]; + } + [appendString removeAttribute:(id)kCTRunDelegateAttributeName range:range]; } // if there will others attribute to archiving , implement like this. if (attrs[DTBackgroundStrokeColorAttribute]) { - NSMutableDictionary *dict = [[self class] getArchivingDictionaryWith:attrs]; CGColorRef strokeColor = (__bridge CGColorRef)(attrs[DTBackgroundStrokeColorAttribute]); UIColor *stoke = [[UIColor alloc] initWithCGColor:strokeColor]; [dict setObject:stoke forKey:DTBackgroundStrokeColorAttribute]; - [appendString setAttributes:dict range:range]; + [appendString addAttribute:DTArchivingAttribute value:dict range:range]; [appendString removeAttribute:(id)DTBackgroundStrokeColorAttribute range:range]; } + }]; } #endif - + NSData *data = nil; @try { @@ -143,10 +170,26 @@ + (NSAttributedString *)attributedStringWithData:(NSData *)data [appendString enumerateAttributesInRange:NSMakeRange(0, length-1) options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(NSDictionary * _Nonnull attrs, NSRange range, BOOL * _Nonnull stop) { #if DTCORETEXT_SUPPORT_NS_ATTRIBUTES && TARGET_OS_IPHONE - + if (attrs[NSAttachmentAttributeName]) { DTTextAttachment *attatchment = attrs[NSAttachmentAttributeName]; + + if ([[attatchment.contentURL scheme] isEqualToString:@"file"]) + { + NSMutableDictionary *dict = [[self class] getArchivingDictionaryWith:attrs]; + + NSString *imgPath = dict[NSAttachmentAttributeName]; + if (imgPath) + { + if (![imgPath hasPrefix:NSHomeDirectory()]) + { + imgPath = [NSHomeDirectory() stringByAppendingPathComponent:imgPath]; + } + attatchment.contentURL = [NSURL fileURLWithPath:imgPath]; + } + } + CTRunDelegateRef embeddedObjectRunDelegate = createEmbeddedObjectRunDelegate(attatchment); [appendString addAttribute:(id)kCTRunDelegateAttributeName value:CFBridgingRelease(embeddedObjectRunDelegate) range:range]; @@ -159,9 +202,6 @@ + (NSAttributedString *)attributedStringWithData:(NSData *)data CGColorRef strokeColor = stroke.CGColor; [appendString addAttribute:DTBackgroundStrokeColorAttribute value:(__bridge id)strokeColor range:range]; - - [dict removeObjectForKey:DTBackgroundStrokeColorAttribute]; - [appendString setAttributes:dict range:range]; } #endif From 8b11d5c61782959a83e82d3f21693924c826b1c2 Mon Sep 17 00:00:00 2001 From: liaowei Date: Thu, 27 Jul 2017 14:51:22 +0800 Subject: [PATCH 16/20] fix issues #1050 use attributed truncationString DTAttributedTextContentView will pass wrong attributed string to delegate. https://github.com/Cocoanetics/DTCoreText/issues/1050 --- Core/Source/DTAttributedTextContentView.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/Source/DTAttributedTextContentView.m b/Core/Source/DTAttributedTextContentView.m index 049938a8b..4932e1de5 100644 --- a/Core/Source/DTAttributedTextContentView.m +++ b/Core/Source/DTAttributedTextContentView.m @@ -341,7 +341,8 @@ - (void)layoutSubviewsInRect:(CGRect)rect } else if (_delegateFlags.delegateSupportsGenericCustomViews) { - NSAttributedString *string = [layoutString attributedSubstringFromRange:runRange]; + NSMutableAttributedString *string = [layoutString attributedSubstringFromRange:runRange].mutableCopy; + [string addAttributes:oneRun.attributes range:NSMakeRange(0, string.length)]; newCustomAttachmentView = [_delegate attributedTextContentView:self viewForAttributedString:string frame:frameForSubview]; } @@ -398,7 +399,8 @@ - (void)layoutSubviewsInRect:(CGRect)rect } else if (_delegateFlags.delegateSupportsGenericCustomViews) { - NSAttributedString *string = [layoutString attributedSubstringFromRange:runRange]; + NSMutableAttributedString *string = [layoutString attributedSubstringFromRange:runRange].mutableCopy; + [string addAttributes:oneRun.attributes range:NSMakeRange(0, string.length)]; newCustomLinkView = [_delegate attributedTextContentView:self viewForAttributedString:string frame:frameForSubview]; } From e793cc0e44eb3c448cd2663fdb5ec18dbdafbfff Mon Sep 17 00:00:00 2001 From: liaowei Date: Thu, 24 Aug 2017 14:48:20 +0800 Subject: [PATCH 17/20] stop drawing when DTAttributedTextContentView dealloc --- Core/Source/DTAttributedTextContentView.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Core/Source/DTAttributedTextContentView.m b/Core/Source/DTAttributedTextContentView.m index 4932e1de5..7f1b5cc30 100644 --- a/Core/Source/DTAttributedTextContentView.m +++ b/Core/Source/DTAttributedTextContentView.m @@ -165,6 +165,12 @@ - (void)awakeFromNib - (void)dealloc { + if (_isTiling) + { + self.layer.contents = nil; + self.layer.delegate = nil; + } + [self removeAllCustomViews]; } From 71168fa37bf55eaa141197f447ed73438fbfb69d Mon Sep 17 00:00:00 2001 From: liaowei Date: Thu, 24 Aug 2017 15:24:54 +0800 Subject: [PATCH 18/20] if set _shouldCacheLayoutFrames YES , DTCoreTextLayoutFrame will be cached. so when numberOfLines or lineBreakMode or truncationString changed, call suggestedFrameSizeToFitEntireStringConstraintedToWidth always return old size. --- Core/Source/DTCoreTextLayoutFrame.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/Source/DTCoreTextLayoutFrame.m b/Core/Source/DTCoreTextLayoutFrame.m index 5f1d953d8..c8143ab36 100644 --- a/Core/Source/DTCoreTextLayoutFrame.m +++ b/Core/Source/DTCoreTextLayoutFrame.m @@ -1909,6 +1909,7 @@ - (void)setNumberOfLines:(NSInteger)numberOfLines _numberOfLines = numberOfLines; // clear lines cache _lines = nil; + _frame.size.height = CGFLOAT_HEIGHT_UNKNOWN; } } @@ -1919,6 +1920,7 @@ - (void)setLineBreakMode:(NSLineBreakMode)lineBreakMode _lineBreakMode = lineBreakMode; // clear lines cache _lines = nil; + _frame.size.height = CGFLOAT_HEIGHT_UNKNOWN; } } @@ -1932,6 +1934,7 @@ - (void)setTruncationString:(NSAttributedString *)truncationString { // clear lines cache _lines = nil; + _frame.size.height = CGFLOAT_HEIGHT_UNKNOWN; } } } @@ -1944,6 +1947,7 @@ - (void)setJustifyRatio:(CGFloat)justifyRatio // clear lines cache _lines = nil; + _frame.size.height = CGFLOAT_HEIGHT_UNKNOWN; } } From 3c47fb62f95ad84c2079e1726be7d73593d0e5eb Mon Sep 17 00:00:00 2001 From: cntrump Date: Sat, 26 Aug 2017 12:38:06 +0800 Subject: [PATCH 19/20] fix build error for DTCoreText(Mac) target --- Core/Source/DTColor+Compatibility.h | 2 ++ Core/Source/DTCoreText.h | 15 ++++++------ Core/Source/DTCoreTextGlyphRun.m | 1 + Core/Source/DTCoreTextLayoutFrame.m | 6 +++++ Core/Source/DTCoreTextLayoutLine.m | 1 + Core/Source/DTCoreTextLayouter.m | 1 + Core/Source/DTImage+HTML.h | 2 ++ Core/Source/DTImageTextAttachment.m | 2 -- DTCoreText.xcodeproj/project.pbxproj | 35 ++++++++++++++++++++++++++++ 9 files changed, 56 insertions(+), 9 deletions(-) diff --git a/Core/Source/DTColor+Compatibility.h b/Core/Source/DTColor+Compatibility.h index 8c2c27606..8742ddc7a 100755 --- a/Core/Source/DTColor+Compatibility.h +++ b/Core/Source/DTColor+Compatibility.h @@ -28,6 +28,8 @@ #else +#import + /** Methods used to work with HTML representations of colors. */ diff --git a/Core/Source/DTCoreText.h b/Core/Source/DTCoreText.h index 2e27aeb4b..9f90e7d49 100644 --- a/Core/Source/DTCoreText.h +++ b/Core/Source/DTCoreText.h @@ -62,24 +62,25 @@ #import "DTObjectTextAttachment.h" #import "DTVideoTextAttachment.h" +#import "NSAttributedStringRunDelegates.h" + +#import "DTCoreTextGlyphRun.h" +#import "DTCoreTextLayoutFrame.h" +#import "DTCoreTextLayoutFrame+Cursor.h" +#import "DTCoreTextLayoutLine.h" +#import "DTCoreTextLayouter.h" + // TARGET_OS_IPHONE is both tvOS and iOS #if TARGET_OS_IPHONE #import "DTLazyImageView.h" #import "DTLinkButton.h" -#import "NSAttributedStringRunDelegates.h" - #import "DTAttributedLabel.h" #import "DTAttributedTextCell.h" #import "DTAttributedTextContentView.h" #import "DTAttributedTextView.h" #import "DTCoreTextFontCollection.h" -#import "DTCoreTextGlyphRun.h" -#import "DTCoreTextLayoutFrame.h" -#import "DTCoreTextLayoutFrame+Cursor.h" -#import "DTCoreTextLayoutLine.h" -#import "DTCoreTextLayouter.h" #import "DTDictationPlaceholderView.h" diff --git a/Core/Source/DTCoreTextGlyphRun.m b/Core/Source/DTCoreTextGlyphRun.m index 64c81a325..d986987ab 100644 --- a/Core/Source/DTCoreTextGlyphRun.m +++ b/Core/Source/DTCoreTextGlyphRun.m @@ -6,6 +6,7 @@ // Copyright 2011 Drobnik.com. All rights reserved. // +#import "DTCompatibility.h" #import "DTCoreTextGlyphRun.h" #import "DTCoreTextLayoutLine.h" #import "DTTextAttachment.h" diff --git a/Core/Source/DTCoreTextLayoutFrame.m b/Core/Source/DTCoreTextLayoutFrame.m index c8143ab36..c397d6232 100644 --- a/Core/Source/DTCoreTextLayoutFrame.m +++ b/Core/Source/DTCoreTextLayoutFrame.m @@ -1339,6 +1339,10 @@ - (void)drawInContext:(CGContextRef)context options:(DTCoreTextLayoutFrameDrawin #if TARGET_OS_IPHONE // need to push the CG context so that the UI* based colors can be set UIGraphicsPushContext(context); +#elif TARGET_OS_MAC + NSGraphicsContext *c = [NSGraphicsContext graphicsContextWithCGContext:context flipped:YES]; + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:c]; #endif // need to draw all text boxes because the the there might be the padding region of a box outside the clip rect visible @@ -1553,6 +1557,8 @@ - (void)drawInContext:(CGContextRef)context options:(DTCoreTextLayoutFrameDrawin #if TARGET_OS_IPHONE UIGraphicsPopContext(); +#elif TARGET_OS_MAC + [NSGraphicsContext restoreGraphicsState]; #endif CGContextRestoreGState(context); diff --git a/Core/Source/DTCoreTextLayoutLine.m b/Core/Source/DTCoreTextLayoutLine.m index 77a0a2e3c..98f066b23 100644 --- a/Core/Source/DTCoreTextLayoutLine.m +++ b/Core/Source/DTCoreTextLayoutLine.m @@ -6,6 +6,7 @@ // Copyright 2011 Drobnik.com. All rights reserved. // +#import "DTCompatibility.h" #import "DTCoreTextLayoutLine.h" #import "DTCoreTextGlyphRun.h" #import "DTCoreTextLayoutFrame.h" diff --git a/Core/Source/DTCoreTextLayouter.m b/Core/Source/DTCoreTextLayouter.m index e91298af9..72c32d8a5 100644 --- a/Core/Source/DTCoreTextLayouter.m +++ b/Core/Source/DTCoreTextLayouter.m @@ -6,6 +6,7 @@ // Copyright 2011 Drobnik.com. All rights reserved. // +#import "DTCompatibility.h" #import "DTCoreTextLayouter.h" @interface DTCoreTextLayouter () diff --git a/Core/Source/DTImage+HTML.h b/Core/Source/DTImage+HTML.h index c4ad5e39b..894c689f1 100644 --- a/Core/Source/DTImage+HTML.h +++ b/Core/Source/DTImage+HTML.h @@ -26,6 +26,8 @@ #else +#import + /** Category used to have the same method available for unit testing on Mac on iOS. */ diff --git a/Core/Source/DTImageTextAttachment.m b/Core/Source/DTImageTextAttachment.m index 966cfca49..20a2fe313 100644 --- a/Core/Source/DTImageTextAttachment.m +++ b/Core/Source/DTImageTextAttachment.m @@ -336,9 +336,7 @@ - (NSString *)dataURLRepresentation - (void)drawInRect:(CGRect)rect context:(CGContextRef)context { -#if TARGET_OS_IPHONE [self.image drawInRect:rect]; -#endif } #pragma mark - DTTextAttachmentHTMLEncoding diff --git a/DTCoreText.xcodeproj/project.pbxproj b/DTCoreText.xcodeproj/project.pbxproj index 8d612146d..a30051e30 100644 --- a/DTCoreText.xcodeproj/project.pbxproj +++ b/DTCoreText.xcodeproj/project.pbxproj @@ -777,6 +777,22 @@ E2262E031638346200BFDAD7 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A7C1CC0E14D6CFD5008D6468 /* AppKit.framework */; }; E2262E0B1638351C00BFDAD7 /* default.css in Sources */ = {isa = PBXBuildFile; fileRef = A76994F914DBB5F70047CC8D /* default.css */; }; E2262EA41638485F00BFDAD7 /* DTCoreText.h in Headers */ = {isa = PBXBuildFile; fileRef = A70B4C9E1486558200873A4A /* DTCoreText.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FD3C5FEB1F510E9D000352CE /* DTCoreTextLayouter.m in Sources */ = {isa = PBXBuildFile; fileRef = A788C91F14863E8700E1AFD9 /* DTCoreTextLayouter.m */; }; + FD3C5FEC1F510E9D000352CE /* DTCoreTextLayoutFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = A788C92114863E8700E1AFD9 /* DTCoreTextLayoutFrame.m */; }; + FD3C5FED1F510E9D000352CE /* DTCoreTextLayoutFrame+Cursor.m in Sources */ = {isa = PBXBuildFile; fileRef = A78E3C50178D674300D17DCD /* DTCoreTextLayoutFrame+Cursor.m */; }; + FD3C5FEE1F510E9D000352CE /* DTCoreTextLayoutLine.m in Sources */ = {isa = PBXBuildFile; fileRef = A788C92314863E8700E1AFD9 /* DTCoreTextLayoutLine.m */; }; + FD3C5FEF1F510EB7000352CE /* DTCoreTextLayouter.h in Headers */ = {isa = PBXBuildFile; fileRef = A788C91E14863E8700E1AFD9 /* DTCoreTextLayouter.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FD3C5FF01F510EB7000352CE /* DTCoreTextLayoutFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = A788C92014863E8700E1AFD9 /* DTCoreTextLayoutFrame.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FD3C5FF11F510EB7000352CE /* DTCoreTextLayoutLine.h in Headers */ = {isa = PBXBuildFile; fileRef = A788C92214863E8700E1AFD9 /* DTCoreTextLayoutLine.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FD3C5FF21F510F49000352CE /* DTCoreTextGlyphRun.m in Sources */ = {isa = PBXBuildFile; fileRef = A788C91D14863E8700E1AFD9 /* DTCoreTextGlyphRun.m */; }; + FD3C5FF31F510F49000352CE /* NSAttributedStringRunDelegates.m in Sources */ = {isa = PBXBuildFile; fileRef = A788C93F14863E8700E1AFD9 /* NSAttributedStringRunDelegates.m */; }; + FD3C5FF41F510F55000352CE /* DTCoreTextGlyphRun.h in Headers */ = {isa = PBXBuildFile; fileRef = A788C91C14863E8700E1AFD9 /* DTCoreTextGlyphRun.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FD3C5FF51F510F55000352CE /* NSAttributedStringRunDelegates.h in Headers */ = {isa = PBXBuildFile; fileRef = A788C93E14863E8700E1AFD9 /* NSAttributedStringRunDelegates.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FDAE5F6D1F511D18003A5F0B /* DTCoreTextMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = A717BDE319E5A06C0024EF95 /* DTCoreTextMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FDAE5F841F511D62003A5F0B /* DTColor+Compatibility.h in Headers */ = {isa = PBXBuildFile; fileRef = A788C95214863E8700E1AFD9 /* DTColor+Compatibility.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FDAE5F851F511DA6003A5F0B /* DTImage+HTML.h in Headers */ = {isa = PBXBuildFile; fileRef = A7C5D01314D7E3BB00AF1D75 /* DTImage+HTML.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FDAE5F861F511DEB003A5F0B /* DTStylesheetHTMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A7EB8537168FA33000D686B7 /* DTStylesheetHTMLElement.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FDAE5F871F511E26003A5F0B /* NSAttributedString+HTML.h in Headers */ = {isa = PBXBuildFile; fileRef = A788C93A14863E8700E1AFD9 /* NSAttributedString+HTML.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXBuildRule section */ @@ -2356,6 +2372,16 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + FDAE5F871F511E26003A5F0B /* NSAttributedString+HTML.h in Headers */, + FDAE5F861F511DEB003A5F0B /* DTStylesheetHTMLElement.h in Headers */, + FDAE5F851F511DA6003A5F0B /* DTImage+HTML.h in Headers */, + FDAE5F841F511D62003A5F0B /* DTColor+Compatibility.h in Headers */, + FDAE5F6D1F511D18003A5F0B /* DTCoreTextMacros.h in Headers */, + FD3C5FF41F510F55000352CE /* DTCoreTextGlyphRun.h in Headers */, + FD3C5FF51F510F55000352CE /* NSAttributedStringRunDelegates.h in Headers */, + FD3C5FEF1F510EB7000352CE /* DTCoreTextLayouter.h in Headers */, + FD3C5FF01F510EB7000352CE /* DTCoreTextLayoutFrame.h in Headers */, + FD3C5FF11F510EB7000352CE /* DTCoreTextLayoutLine.h in Headers */, E2262DD71638337D00BFDAD7 /* DTCoreTextConstants.h in Headers */, E2262DDB1638337D00BFDAD7 /* DTHTMLAttributedStringBuilder.h in Headers */, E2262DDD1638337D00BFDAD7 /* DTHTMLElement.h in Headers */, @@ -3290,6 +3316,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + FD3C5FF21F510F49000352CE /* DTCoreTextGlyphRun.m in Sources */, + FD3C5FF31F510F49000352CE /* NSAttributedStringRunDelegates.m in Sources */, + FD3C5FEB1F510E9D000352CE /* DTCoreTextLayouter.m in Sources */, + FD3C5FEC1F510E9D000352CE /* DTCoreTextLayoutFrame.m in Sources */, + FD3C5FED1F510E9D000352CE /* DTCoreTextLayoutFrame+Cursor.m in Sources */, + FD3C5FEE1F510E9D000352CE /* DTCoreTextLayoutLine.m in Sources */, E2262E0B1638351C00BFDAD7 /* default.css in Sources */, 426693AE1B56F98500F9DBFC /* CTLineUtils.m in Sources */, E2262DD51638336700BFDAD7 /* DTColor+Compatibility.m in Sources */, @@ -4150,6 +4182,7 @@ GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; INFOPLIST_FILE = "Core/DTCoreText-Info.plist"; + INSTALL_PATH = "@rpath"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = "com.drobnik.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = DTCoreText; @@ -4312,6 +4345,7 @@ GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; INFOPLIST_FILE = "Core/DTCoreText-Info.plist"; + INSTALL_PATH = "@rpath"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = "com.drobnik.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = DTCoreText; @@ -4341,6 +4375,7 @@ GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; INFOPLIST_FILE = "Core/DTCoreText-Info.plist"; + INSTALL_PATH = "@rpath"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = "com.drobnik.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = DTCoreText; From 9560bf1ecf64b4aff182aa31dd018042dae01f5d Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Mon, 28 Aug 2017 15:33:31 +0200 Subject: [PATCH 20/20] Updated version in podspec --- DTCoreText.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DTCoreText.podspec b/DTCoreText.podspec index 7199eaaec..ab385154a 100644 --- a/DTCoreText.podspec +++ b/DTCoreText.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'DTCoreText' - spec.version = '1.6.20' + spec.version = '1.6.21' spec.platforms = {:ios => '4.3', :tvos => '9.0' } spec.license = 'BSD' spec.source = { :git => 'https://github.com/Cocoanetics/DTCoreText.git', :tag => spec.version.to_s }