Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
s2mh committed Oct 13, 2016
1 parent 4c8ab55 commit 19d72fa
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 18 deletions.
Binary file not shown.
21 changes: 18 additions & 3 deletions Fonty-Demo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,22 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="写点什么" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="jco-6H-458">
<frame key="frameInset" minY="226" width="375" height="49"/>
<constraints>
<constraint firstAttribute="height" constant="49" id="r6F-cd-W07"/>
</constraints>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uYp-9U-ANh">
<constraints>
<constraint firstAttribute="height" constant="163" id="1Cm-Os-QnG"/>
</constraints>
<string key="text">枫桥夜泊

月落乌啼霜满天,江枫渔火对愁眠。
Expand All @@ -48,9 +60,11 @@
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="uYp-9U-ANh" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="711-ht-F2p"/>
<constraint firstItem="jco-6H-458" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="Pmy-cc-iZv"/>
<constraint firstAttribute="trailing" secondItem="uYp-9U-ANh" secondAttribute="trailing" id="dsD-lm-mP7"/>
<constraint firstItem="jco-6H-458" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="163" id="eLx-XK-H1T"/>
<constraint firstItem="uYp-9U-ANh" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="fT0-Bb-NyU"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="uYp-9U-ANh" secondAttribute="bottom" id="g8G-LZ-fis"/>
<constraint firstAttribute="trailing" secondItem="jco-6H-458" secondAttribute="trailing" id="ovL-Ll-A5h"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="qIY-i7-AI9">
Expand All @@ -62,11 +76,12 @@
</navigationItem>
<connections>
<outlet property="label" destination="uYp-9U-ANh" id="LWY-v1-ZkI"/>
<outlet property="textField" destination="jco-6H-458" id="IXj-AQ-0hw"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="80.799999999999997" y="228.93553223388307"/>
<point key="canvasLocation" x="79.200000000000003" y="228.03598200899552"/>
</scene>
</scenes>
</document>
5 changes: 4 additions & 1 deletion Fonty-Demo/FYSelectFontTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
- (void)layoutSubviews {
[super layoutSubviews];
if (self.downloadProgress == 1.0f) {
if ([self.textLabel.text hasPrefix:@"http"]) {
NSLog(@"self.textLabel.text %@", self.textLabel.text);
}
[self.stripesLayer removeFromSuperlayer];
[self.progressLayer removeFromSuperlayer];
return;
Expand Down Expand Up @@ -132,7 +135,7 @@ - (CAShapeLayer *)progressLayer {
if (!_progressLayer) {
_progressLayer = [CAShapeLayer layer];
_progressLayer.fillColor = [UIColor grayColor].CGColor;
_progressLayer.frame = CGRectMake(0.0f, 0.0f, self.bounds.size.width, self.bounds.size.height);
_progressLayer.path = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
_progressLayer.opacity = 0.5f;
_progressLayer.speed = 0.0f;

Expand Down
5 changes: 4 additions & 1 deletion Fonty-Demo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@interface ViewController ()

@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UITextField *textField;

@end

Expand All @@ -29,7 +30,9 @@ - (void)viewDidLoad {
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

[self.label setFont:[UIFont fy_mainFontOfSize:18.0f]];
[self.label setFont:[UIFont fy_mainFontOfSize:20.0f]];
[self.textField setFont:[UIFont fy_mainFontOfSize:20.0f]];
[self.textField becomeFirstResponder];
}

- (IBAction)barButtonItemAction:(UIBarButtonItem *)sender {
Expand Down
2 changes: 1 addition & 1 deletion Fonty.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "Fonty"
s.version = "1.0.0"
s.version = "1.0.1"
s.summary = "Web Font Tool"

# This description is used to generate tags and improve search results.
Expand Down
8 changes: 4 additions & 4 deletions Fonty/FYFontCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (instancetype)init
#pragma mark - Public

- (NSString *)cachedFilePathWithWebURL:(NSURL *)webURL {
NSString *filePath = [self cachedFilePathForWebURLString:webURL.absoluteString];
NSString *filePath = [self filePathForWebURLString:webURL.absoluteString];
if ([self.fileManager fileExistsAtPath:filePath]) {
return filePath;
} else {
Expand All @@ -54,7 +54,7 @@ - (NSString *)cachedFilePathWithWebURL:(NSURL *)webURL {
}

- (NSString *)cacheFileAtLocolURL:(NSURL *)locolURL fromWebURL:(NSURL *)webURL {
NSString *filePath = [self cachedFilePathForWebURLString:webURL.absoluteString];
NSString *filePath = [self filePathForWebURLString:webURL.absoluteString];
if (![self.fileManager fileExistsAtPath:filePath]) {
[self.fileManager removeItemAtPath:filePath error:NULL];
}
Expand All @@ -66,7 +66,7 @@ - (NSString *)cacheFileAtLocolURL:(NSURL *)locolURL fromWebURL:(NSURL *)webURL {
}

- (void)cleanCachedFileWithWebURL:(NSURL *)webURL {
NSString *filePath = [self cachedFilePathForWebURLString:webURL.absoluteString];
NSString *filePath = [self filePathForWebURLString:webURL.absoluteString];
[[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
FYFontModel *model = [[FYFontModel alloc] init];
Expand All @@ -78,7 +78,7 @@ - (void)cleanCachedFileWithWebURL:(NSURL *)webURL {

#pragma mark - Private

- (NSString *)cachedFilePathForWebURLString:(NSString *)URLString {
- (NSString *)filePathForWebURLString:(NSString *)URLString {
NSString *fontFileName = [self.cachePaths objectForKey:URLString];
if (!fontFileName) {
const char *str = [URLString UTF8String];
Expand Down
10 changes: 5 additions & 5 deletions Fonty/FYFontManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ - (void)cancelDownloadingFontWithURLString:(NSString *)URLString {
}

- (void)deleteFontWithURL:(NSURL *)URL {
for (FYFontModel *model in self.fontModelArray) {
[self.fontModelArray enumerateObjectsUsingBlock:^(FYFontModel * _Nonnull model, NSUInteger idx, BOOL * _Nonnull stop) {
if ([model.URL isEqual:URL]) {
model.status = FYFontModelDownloadStatusDeleting;
if (idx == self.mainFontIndex) {
self.mainFontIndex = 0;
}
}
}
}];
if ([URL isKindOfClass:[NSURL class]]) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *cachePath = [self.fontCache cachedFilePathWithWebURL:URL];
Expand Down Expand Up @@ -160,9 +163,6 @@ - (void)handleModelInNotification:(NSNotification *)notification {
for (FYFontModel *model in self.fontModelArray) {
if ([model.URL isEqual:newModel.URL]) {
[model setModel:newModel];
if (model.status == FYFontModelDownloadStatusToBeDownloaded) {
self.mainFontIndex = 0;
}
break;
}
}
Expand Down
6 changes: 4 additions & 2 deletions Fonty/FYFontModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ + (instancetype)modelWithSessionDownloadTask:(NSURLSessionDownloadTask *)task {
if (task.countOfBytesExpectedToReceive == NSURLSessionTransferSizeUnknown) {
model.fileSizeUnknown = YES;
} else {
model.downloadProgress = (double)task.countOfBytesReceived / task.countOfBytesExpectedToReceive;
if (task.countOfBytesExpectedToReceive) {
model.downloadProgress = (double)task.countOfBytesReceived / task.countOfBytesExpectedToReceive;
}
}

switch (task.state) {
Expand Down Expand Up @@ -80,7 +82,7 @@ - (NSString *)description
if (self.URL) {
return self.URL.absoluteString;
} else {
return @"system default font";
return @"Default Font";
}
}

Expand Down
1 change: 0 additions & 1 deletion Fonty/FYFontRegister.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ - (void)unregisterFontWithPath:(NSString *)path completeBlock:(void(^)())complet
}
CGFontRelease(fontRef);
if (completeBlock) {
NSLog(@"completeBlock");
completeBlock();
}
}
Expand Down

0 comments on commit 19d72fa

Please sign in to comment.