Skip to content

Commit

Permalink
Merge branch 'release-1.6.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Aug 1, 2013
2 parents b1e5a27 + 472b56b commit d28c5f6
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Core/Externals/DTFoundation
Submodule DTFoundation updated 38 files
+1 −1 AppledocSettings.plist
+0 −0 Core/Source/DTASN1/DTASN1BitString.h
+0 −0 Core/Source/DTASN1/DTASN1BitString.m
+0 −0 Core/Source/DTASN1/DTASN1Parser.h
+0 −0 Core/Source/DTASN1/DTASN1Parser.m
+0 −0 Core/Source/DTASN1/DTASN1Serialization.h
+0 −0 Core/Source/DTASN1/DTASN1Serialization.m
+29 −0 Core/Source/DTAWS/NSURL+DTAWS.h
+85 −0 Core/Source/DTAWS/NSURL+DTAWS.m
+1 −1 Core/Source/DTExtendedFileAttributes.m
+0 −0 Core/Source/DTScripting/DTScriptExpression.h
+0 −0 Core/Source/DTScripting/DTScriptExpression.m
+0 −0 Core/Source/DTScripting/DTScriptVariable.h
+0 −0 Core/Source/DTScripting/DTScriptVariable.m
+0 −0 Core/Source/DTScripting/NSScanner+DTScripting.h
+0 −0 Core/Source/DTScripting/NSScanner+DTScripting.m
+6 −5 Core/Source/DTVersion.m
+0 −0 Core/Source/Runtime/DTObjectBlockExecutor.h
+0 −0 Core/Source/Runtime/DTObjectBlockExecutor.m
+0 −0 Core/Source/Runtime/NSObject+DTRuntime.h
+0 −0 Core/Source/Runtime/NSObject+DTRuntime.m
+0 −0 Core/Source/iOS/BlocksAdditions/DTActionSheet.h
+0 −0 Core/Source/iOS/BlocksAdditions/DTActionSheet.m
+0 −0 Core/Source/iOS/BlocksAdditions/DTAlertView.h
+0 −0 Core/Source/iOS/BlocksAdditions/DTAlertView.m
+0 −0 Core/Source/iOS/BlocksAdditions/UIView+DTActionHandlers.h
+0 −0 Core/Source/iOS/BlocksAdditions/UIView+DTActionHandlers.m
+4 −6 Core/Source/iOS/DTActivityTitleView.h
+5 −5 Core/Source/iOS/DTActivityTitleView.m
+7 −1 Core/Source/iOS/DTSmartPagingScrollView.h
+42 −42 Core/Source/iOS/DTSmartPagingScrollView.m
+0 −0 Core/Source/iOS/Debug/UIColor+DTDebug.h
+0 −0 Core/Source/iOS/Debug/UIColor+DTDebug.m
+0 −0 Core/Source/iOS/Debug/UIView+DTDebug.h
+0 −0 Core/Source/iOS/Debug/UIView+DTDebug.m
+28 −8 DTFoundation.podspec
+292 −207 DTFoundation.xcodeproj/project.pbxproj
+15 −0 Documentation/Change Log-template.markdown
1 change: 1 addition & 0 deletions Core/Source/DTCoreTextConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ extern NSString * const DTHorizontalRuleStyleAttribute;
extern NSString * const DTTextBlocksAttribute;
extern NSString * const DTFieldAttribute;
extern NSString * const DTCustomAttributesAttribute;
extern NSString * const DTAscentMultiplierAttribute;

// field constants

Expand Down
1 change: 1 addition & 0 deletions Core/Source/DTCoreTextConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
NSString * const DTTextBlocksAttribute = @"DTTextBlocks";
NSString * const DTFieldAttribute = @"DTField";
NSString * const DTCustomAttributesAttribute = @"DTCustomAttributes";
NSString * const DTAscentMultiplierAttribute = @"DTAscentMultiplierAttribute";

// field constants
NSString * const DTListPrefixField = @"{listprefix}";
Expand Down
5 changes: 5 additions & 0 deletions Core/Source/DTCoreTextLayoutFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ typedef enum
*/
- (CGPoint)baselineOriginToPositionLine:(DTCoreTextLayoutLine *)line afterLine:(DTCoreTextLayoutLine *)previousLine __attribute__((deprecated("use use -[baselineOriginToPositionLine:afterLine:algorithm:] instead")));;

/**
The ratio to decide when to create a justified line
*/
@property (nonatomic, readwrite) CGFloat justifyRatio;

/**
@name Text Attachments
*/
Expand Down
38 changes: 31 additions & 7 deletions Core/Source/DTCoreTextLayoutFrame.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ - (id)initWithFrame:(CGRect)frame layouter:(DTCoreTextLayouter *)layouter range:
// Strange, should have gotten a valid framesetter
return nil;
}

_justifyRatio = 0.6f;
}

return self;
Expand Down Expand Up @@ -486,6 +488,7 @@ - (void)_buildLinesWithTypesetter
(_numberLinesFitInFrame>0 && _numberLinesFitInFrame==[typesetLines count]+1));

CTLineRef line;
BOOL isHyphenatedString = NO;

if (!shouldTruncateLine)
{
Expand All @@ -498,6 +501,7 @@ - (void)_buildLinesWithTypesetter
NSRange replaceRange = NSMakeRange(hyphenatedString.length - 1, 1);
[hyphenatedString replaceCharactersInRange:replaceRange withString:@"-"];
line = CTLineCreateWithAttributedString((__bridge CFAttributedStringRef)hyphenatedString);
isHyphenatedString = YES;
}
else
{
Expand Down Expand Up @@ -607,14 +611,19 @@ - (void)_buildLinesWithTypesetter
BOOL isAtEndOfParagraph = (currentParagraphRange.location+currentParagraphRange.length <= lineRange.location+lineRange.length ||
[[_attributedStringFragment string] characterAtIndex:lineRange.location+lineRange.length-1]==0x2028);

// only justify if not last line, not <br>, and if the line width is longer than 60% of the frame
// only justify if not last line, not <br>, and if the line width is longer than _justifyRatio of the frame
// avoids over-stretching
if( !isAtEndOfParagraph && (currentLineWidth > 0.60 * _frame.size.width) )
if( !isAtEndOfParagraph && (currentLineWidth > _justifyRatio * _frame.size.width) )
{
// create a justified line and replace the current one with it
CTLineRef justifiedLine = CTLineCreateJustifiedLine(line, 1.0f, availableSpace);
CFRelease(line);
line = justifiedLine;

// CTLineCreateJustifiedLine sometimes fails if the line ends with 0x00AD (soft hyphen) and contains cyrillic chars
if (justifiedLine)
{
CFRelease(line);
line = justifiedLine;
}
}

if (isRTL)
Expand All @@ -633,7 +642,8 @@ - (void)_buildLinesWithTypesetter
}

// wrap it
DTCoreTextLayoutLine *newLine = [[DTCoreTextLayoutLine alloc] initWithLine:line];
DTCoreTextLayoutLine *newLine = [[DTCoreTextLayoutLine alloc] initWithLine:line
stringLocationOffset:isHyphenatedString ? lineRange.location : 0];
newLine.writingDirectionIsRightToLeft = isRTL;
CFRelease(line);

Expand Down Expand Up @@ -1205,16 +1215,19 @@ - (void)drawInContext:(CGContextRef)context options:(DTCoreTextLayoutFrameDrawin

NSInteger superscriptStyle = [[oneRun.attributes objectForKey:(id)kCTSuperscriptAttributeName] integerValue];

NSNumber *ascentMultiplier = [oneRun.attributes objectForKey:(id)DTAscentMultiplierAttribute];


switch (superscriptStyle)
{
case 1:
{
textPosition.y += oneRun.ascent * 0.47f;
textPosition.y += oneRun.ascent * (ascentMultiplier ? [ascentMultiplier floatValue] : 0.47f);
break;
}
case -1:
{
textPosition.y -= oneRun.ascent * 0.25f;
textPosition.y -= oneRun.ascent * (ascentMultiplier ? [ascentMultiplier floatValue] : 0.25f);
break;
}
default:
Expand Down Expand Up @@ -1663,9 +1676,20 @@ - (void)setTruncationString:(NSAttributedString *)truncationString
}
}

- (void) setJustifyRatio:(CGFloat)justifyRatio
{
if( _justifyRatio != justifyRatio )
{
_justifyRatio = justifyRatio;
// clear lines cache
_lines = nil;
}
}

@synthesize frame = _frame;
@synthesize lines = _lines;
@synthesize paragraphRanges = _paragraphRanges;
@synthesize textBlockHandler = _textBlockHandler;
@synthesize justifyRatio = _justifyRatio;

@end
9 changes: 9 additions & 0 deletions Core/Source/DTCoreTextLayoutLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
*/
- (id)initWithLine:(CTLineRef)line;

/**
Creates a layout line from a given `CTLine`
@param line The Core Text line to wrap
@param stringLocationOffset Offset to modify internal string location to get actual location
@returns A prepared layout line
*/

- (id)initWithLine:(CTLineRef)line stringLocationOffset:(NSInteger)stringLocationOffset;

/**
@name Drawing Layout Lines
*/
Expand Down
9 changes: 8 additions & 1 deletion Core/Source/DTCoreTextLayoutLine.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@ @implementation DTCoreTextLayoutLine
}

- (id)initWithLine:(CTLineRef)line
{
return [self initWithLine:line stringLocationOffset:0];
}

- (id)initWithLine:(CTLineRef)line stringLocationOffset:(NSInteger)stringLocationOffset
{
if ((self = [super init]))
{
_line = line;
CFRetain(_line);

// writing direction
_needsToDetectWritingDirection = YES;

_stringLocationOffset = stringLocationOffset;
}
return self;
}
Expand Down
4 changes: 2 additions & 2 deletions Core/Source/DTCoreTextParagraphStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ The distance in points from the margin of a text container to the end of lines.
*/

/**
Text lists containing the paragraph, nested from outermost to innermost, to array.
Text lists containing the paragraph, nested from outermost to innermost. Each text list is a DTCSSListStyle object.
*/
@property (nonatomic, copy) NSArray *textLists;

Expand All @@ -202,7 +202,7 @@ The distance in points from the margin of a text container to the end of lines.
*/

/**
Text lists containing the paragraph, nested from outermost to innermost, to array.
Text blocks containing the paragraph, nested from outermost to innermost, to array. Each text block is a DTTextBlock object.
*/
@property (nonatomic, copy) NSArray *textBlocks;

Expand Down
6 changes: 3 additions & 3 deletions DTCoreText.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Pod::Spec.new do |spec|
spec.license = 'BSD'
spec.source = { :git => 'https://github.com/Cocoanetics/DTCoreText.git', :tag => spec.version.to_s }
spec.source_files = 'Core/Source/*.{h,m,c}'
spec.dependency 'DTFoundation/Core', '~>1.4.3'
spec.dependency 'DTFoundation/UIKit', '~>1.4.3'
spec.dependency 'DTFoundation/DTHMLParser', '~>1.4.3'
spec.dependency 'DTFoundation/Core', '~>1.4.5'
spec.dependency 'DTFoundation/UIKit', '~>1.4.5'
spec.dependency 'DTFoundation/DTHTMLParser', '~>1.4.5'
spec.frameworks = 'MediaPlayer', 'QuartzCore', 'CoreText', 'CoreGraphics', 'ImageIO'
spec.requires_arc = true
spec.homepage = 'https://github.com/Cocoanetics/DTCoreText'
Expand Down
17 changes: 17 additions & 0 deletions DTCoreText.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,13 @@
/* End PBXBuildRule section */

/* Begin PBXContainerItemProxy section */
A70C4FE617AA7E3100000DF5 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A7E383AB160DFEA700CF72D6 /* DTFoundation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A79D999C1792D1F50082BC06;
remoteInfo = "DTAWS (iOS)";
};
A70E62F616C253C6009B47BF /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A7E383AB160DFEA700CF72D6 /* DTFoundation.xcodeproj */;
Expand Down Expand Up @@ -1648,6 +1655,7 @@
A7E383B9160DFEA800CF72D6 /* libDTFoundation.a */,
A7B4E2D21686FDB300717707 /* UnitTests.octest */,
A7B4E2D41686FDB300717707 /* libDTFoundation_Mac.a */,
A70C4FE717AA7E3100000DF5 /* libDTAWS.a */,
A7B4E2D61686FDB300717707 /* libDTHTMLParser_iOS.a */,
A7B4E2D81686FDB300717707 /* libDTHTMLParser_Mac.a */,
A7B4E2DA1686FDB300717707 /* libDTZipArchive_iOS.a */,
Expand Down Expand Up @@ -2109,6 +2117,13 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
A70C4FE717AA7E3100000DF5 /* libDTAWS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libDTAWS.a;
remoteRef = A70C4FE617AA7E3100000DF5 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
A74F6FD316DB9AF600C12307 /* libDTUTI_Mac.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
Expand Down Expand Up @@ -2878,6 +2893,7 @@
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_THUMB_SUPPORT = NO;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = DTCoreText;
PUBLIC_HEADERS_FOLDER_PATH = ../../DTCoreText;
SKIP_INSTALL = YES;
Expand All @@ -2897,6 +2913,7 @@
GCC_PREFIX_HEADER = "Core/DTCoreText-Prefix.pch";
GCC_THUMB_SUPPORT = NO;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = DTCoreText;
PUBLIC_HEADERS_FOLDER_PATH = ../../DTCoreText;
SKIP_INSTALL = YES;
Expand Down

0 comments on commit d28c5f6

Please sign in to comment.