From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001
From: 单军华
Date: Wed, 11 Jul 2018 10:47:42 +0800
Subject: [PATCH] 首次上传
---
screendisplay/Pods/YYCategories/YYCategories/UIKit/UIBezierPath+YYAdd.m | 64 ++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/screendisplay/Pods/YYCategories/YYCategories/UIKit/UIBezierPath+YYAdd.m b/screendisplay/Pods/YYCategories/YYCategories/UIKit/UIBezierPath+YYAdd.m
new file mode 100755
index 0000000..7e82fdf
--- /dev/null
+++ b/screendisplay/Pods/YYCategories/YYCategories/UIKit/UIBezierPath+YYAdd.m
@@ -0,0 +1,64 @@
+//
+// UIBezierPath+YYAdd.m
+// YYCategories <https://github.com/ibireme/YYCategories>
+//
+// Created by ibireme on 14/10/30.
+// Copyright (c) 2015 ibireme.
+//
+// This source code is licensed under the MIT-style license found in the
+// LICENSE file in the root directory of this source tree.
+//
+
+#import "UIBezierPath+YYAdd.h"
+#import "UIFont+YYAdd.h"
+#import <CoreText/CoreText.h>
+#import "YYCategoriesMacro.h"
+
+YYSYNTH_DUMMY_CLASS(UIBezierPath_YYAdd)
+
+
+@implementation UIBezierPath (YYAdd)
+
++ (UIBezierPath *)bezierPathWithText:(NSString *)text font:(UIFont *)font {
+ CTFontRef ctFont = font.CTFontRef;
+ if (!ctFont) return nil;
+ NSDictionary *attrs = @{ (__bridge id)kCTFontAttributeName:(__bridge id)ctFont };
+ NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:text attributes:attrs];
+ CFRelease(ctFont);
+
+ CTLineRef line = CTLineCreateWithAttributedString((__bridge CFTypeRef)attrString);
+ if (!line) return nil;
+
+ CGMutablePathRef cgPath = CGPathCreateMutable();
+ CFArrayRef runs = CTLineGetGlyphRuns(line);
+ for (CFIndex iRun = 0, iRunMax = CFArrayGetCount(runs); iRun < iRunMax; iRun++) {
+ CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, iRun);
+ CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName);
+
+ for (CFIndex iGlyph = 0, iGlyphMax = CTRunGetGlyphCount(run); iGlyph < iGlyphMax; iGlyph++) {
+ CFRange glyphRange = CFRangeMake(iGlyph, 1);
+ CGGlyph glyph;
+ CGPoint position;
+ CTRunGetGlyphs(run, glyphRange, &glyph);
+ CTRunGetPositions(run, glyphRange, &position);
+
+ CGPathRef glyphPath = CTFontCreatePathForGlyph(runFont, glyph, NULL);
+ if (glyphPath) {
+ CGAffineTransform transform = CGAffineTransformMakeTranslation(position.x, position.y);
+ CGPathAddPath(cgPath, &transform, glyphPath);
+ CGPathRelease(glyphPath);
+ }
+ }
+ }
+ UIBezierPath *path = [UIBezierPath bezierPathWithCGPath:cgPath];
+ CGRect boundingBox = CGPathGetPathBoundingBox(cgPath);
+ CFRelease(cgPath);
+ CFRelease(line);
+
+ [path applyTransform:CGAffineTransformMakeScale(1.0, -1.0)];
+ [path applyTransform:CGAffineTransformMakeTranslation(0.0, boundingBox.size.height)];
+
+ return path;
+}
+
+@end
--
Gitblit v1.8.0