|
@@ -636,8 +636,8 @@ dispatch_semaphore_signal(_lock);
|
|
size.height += rect.origin.y;
|
|
size.height += rect.origin.y;
|
|
if (size.width < 0) size.width = 0;
|
|
if (size.width < 0) size.width = 0;
|
|
if (size.height < 0) size.height = 0;
|
|
if (size.height < 0) size.height = 0;
|
|
- size.width = YYTextCGFloatPixelCeil(size.width);
|
|
|
|
- size.height = YYTextCGFloatPixelCeil(size.height);
|
|
|
|
|
|
+ size.width = ceil(size.width);
|
|
|
|
+ size.height = ceil(size.height);
|
|
textBoundingSize = size;
|
|
textBoundingSize = size;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2572,11 +2572,13 @@ static void YYTextDrawText(YYTextLayout *layout, CGContextRef context, CGSize si
|
|
YYTextLine *line = lines[l];
|
|
YYTextLine *line = lines[l];
|
|
if (layout.truncatedLine && layout.truncatedLine.index == line.index) line = layout.truncatedLine;
|
|
if (layout.truncatedLine && layout.truncatedLine.index == line.index) line = layout.truncatedLine;
|
|
NSArray *lineRunRanges = line.verticalRotateRange;
|
|
NSArray *lineRunRanges = line.verticalRotateRange;
|
|
- CGContextSetTextMatrix(context, CGAffineTransformIdentity);
|
|
|
|
- CGContextSetTextPosition(context, line.position.x + verticalOffset, size.height - line.position.y);
|
|
|
|
|
|
+ CGFloat posX = line.position.x + verticalOffset;
|
|
|
|
+ CGFloat posY = size.height - line.position.y;
|
|
CFArrayRef runs = CTLineGetGlyphRuns(line.CTLine);
|
|
CFArrayRef runs = CTLineGetGlyphRuns(line.CTLine);
|
|
for (NSUInteger r = 0, rMax = CFArrayGetCount(runs); r < rMax; r++) {
|
|
for (NSUInteger r = 0, rMax = CFArrayGetCount(runs); r < rMax; r++) {
|
|
CTRunRef run = CFArrayGetValueAtIndex(runs, r);
|
|
CTRunRef run = CFArrayGetValueAtIndex(runs, r);
|
|
|
|
+ CGContextSetTextMatrix(context, CGAffineTransformIdentity);
|
|
|
|
+ CGContextSetTextPosition(context, posX, posY);
|
|
YYTextDrawRun(line, run, context, size, isVertical, lineRunRanges[r], verticalOffset);
|
|
YYTextDrawRun(line, run, context, size, isVertical, lineRunRanges[r], verticalOffset);
|
|
}
|
|
}
|
|
if (cancel && cancel()) break;
|
|
if (cancel && cancel()) break;
|
|
@@ -2986,18 +2988,19 @@ static void YYTextDrawShadow(YYTextLayout *layout, CGContextRef context, CGSize
|
|
CGContextTranslateCTM(context, point.x, point.y);
|
|
CGContextTranslateCTM(context, point.x, point.y);
|
|
CGContextTranslateCTM(context, 0, size.height);
|
|
CGContextTranslateCTM(context, 0, size.height);
|
|
CGContextScaleCTM(context, 1, -1);
|
|
CGContextScaleCTM(context, 1, -1);
|
|
- CGContextSetTextMatrix(context, CGAffineTransformIdentity);
|
|
|
|
NSArray *lines = layout.lines;
|
|
NSArray *lines = layout.lines;
|
|
for (NSUInteger l = 0, lMax = layout.lines.count; l < lMax; l++) {
|
|
for (NSUInteger l = 0, lMax = layout.lines.count; l < lMax; l++) {
|
|
if (cancel && cancel()) break;
|
|
if (cancel && cancel()) break;
|
|
-
|
|
|
|
YYTextLine *line = lines[l];
|
|
YYTextLine *line = lines[l];
|
|
if (layout.truncatedLine && layout.truncatedLine.index == line.index) line = layout.truncatedLine;
|
|
if (layout.truncatedLine && layout.truncatedLine.index == line.index) line = layout.truncatedLine;
|
|
NSArray *lineRunRanges = line.verticalRotateRange;
|
|
NSArray *lineRunRanges = line.verticalRotateRange;
|
|
- CGContextSetTextPosition(context, line.position.x, size.height - line.position.y);
|
|
|
|
|
|
+ CGFloat linePosX = line.position.x;
|
|
|
|
+ CGFloat linePosY = size.height - line.position.y;
|
|
CFArrayRef runs = CTLineGetGlyphRuns(line.CTLine);
|
|
CFArrayRef runs = CTLineGetGlyphRuns(line.CTLine);
|
|
for (NSUInteger r = 0, rMax = CFArrayGetCount(runs); r < rMax; r++) {
|
|
for (NSUInteger r = 0, rMax = CFArrayGetCount(runs); r < rMax; r++) {
|
|
CTRunRef run = CFArrayGetValueAtIndex(runs, r);
|
|
CTRunRef run = CFArrayGetValueAtIndex(runs, r);
|
|
|
|
+ CGContextSetTextMatrix(context, CGAffineTransformIdentity);
|
|
|
|
+ CGContextSetTextPosition(context, linePosX, linePosY);
|
|
NSDictionary *attrs = (id)CTRunGetAttributes(run);
|
|
NSDictionary *attrs = (id)CTRunGetAttributes(run);
|
|
YYTextShadow *shadow = attrs[YYTextShadowAttributeName];
|
|
YYTextShadow *shadow = attrs[YYTextShadowAttributeName];
|
|
YYTextShadow *nsShadow = [YYTextShadow shadowWithNSShadow:attrs[NSShadowAttributeName]]; // NSShadow compatible
|
|
YYTextShadow *nsShadow = [YYTextShadow shadowWithNSShadow:attrs[NSShadowAttributeName]]; // NSShadow compatible
|
|
@@ -3042,11 +3045,14 @@ static void YYTextDrawInnerShadow(YYTextLayout *layout, CGContextRef context, CG
|
|
YYTextLine *line = lines[l];
|
|
YYTextLine *line = lines[l];
|
|
if (layout.truncatedLine && layout.truncatedLine.index == line.index) line = layout.truncatedLine;
|
|
if (layout.truncatedLine && layout.truncatedLine.index == line.index) line = layout.truncatedLine;
|
|
NSArray *lineRunRanges = line.verticalRotateRange;
|
|
NSArray *lineRunRanges = line.verticalRotateRange;
|
|
- CGContextSetTextPosition(context, line.position.x, size.height - line.position.y);
|
|
|
|
|
|
+ CGFloat linePosX = line.position.x;
|
|
|
|
+ CGFloat linePosY = size.height - line.position.y;
|
|
CFArrayRef runs = CTLineGetGlyphRuns(line.CTLine);
|
|
CFArrayRef runs = CTLineGetGlyphRuns(line.CTLine);
|
|
for (NSUInteger r = 0, rMax = CFArrayGetCount(runs); r < rMax; r++) {
|
|
for (NSUInteger r = 0, rMax = CFArrayGetCount(runs); r < rMax; r++) {
|
|
CTRunRef run = CFArrayGetValueAtIndex(runs, r);
|
|
CTRunRef run = CFArrayGetValueAtIndex(runs, r);
|
|
if (CTRunGetGlyphCount(run) == 0) continue;
|
|
if (CTRunGetGlyphCount(run) == 0) continue;
|
|
|
|
+ CGContextSetTextMatrix(context, CGAffineTransformIdentity);
|
|
|
|
+ CGContextSetTextPosition(context, linePosX, linePosY);
|
|
NSDictionary *attrs = (id)CTRunGetAttributes(run);
|
|
NSDictionary *attrs = (id)CTRunGetAttributes(run);
|
|
YYTextShadow *shadow = attrs[YYTextInnerShadowAttributeName];
|
|
YYTextShadow *shadow = attrs[YYTextInnerShadowAttributeName];
|
|
while (shadow) {
|
|
while (shadow) {
|