UIFont+YOHO.m 2.04 KB
//
//  UIFont+YOHO.m
//  YH_Mall
//
//  Created by 张同海 on 15/5/29.
//  Copyright (c) 2015年 YOHO. All rights reserved.
//

#import "UIFont+YOHO.h"

@implementation UIFont (YOHO)

+ (UIFont *)yh_lightSystemFontOfSize:(CGFloat)size
{
    return [UIFont fontWithName:@"HelveticaNeue-Light" size:size];
}

+ (UIFont *)yh_blackfaceFontOfSize:(CGFloat)size
{
    //STHeitiSC-Medium  STHeitiSC-Light
    return [UIFont fontWithName:@"STHeitiSC-Light" size:size];
}

+ (UIFont *)yh_mediumBlackfaceFontOfSize:(CGFloat)size
{
    //STHeitiSC-Medium  STHeitiSC-Light
    return [UIFont fontWithName:@"STHeitiSC-Medium" size:size];
}

+ (UIFont *)yh_variationOfFont:(UIFont *)baseFont symbolicTraits:(CTFontSymbolicTraits)trait
{
    CGFloat fontSize = [baseFont pointSize];
    CFStringRef baseFontName = (__bridge CFStringRef)[baseFont fontName];
    CTFontRef baseCTFont = CTFontCreateWithName(baseFontName,
                                                fontSize, NULL);
    CTFontRef ctFont = CTFontCreateCopyWithSymbolicTraits(baseCTFont, 0, NULL,trait, trait);
    NSString *variantFontName = CFBridgingRelease(CTFontCopyName(ctFont, kCTFontPostScriptNameKey));
    
    UIFont *variantFont = [UIFont fontWithName:variantFontName size:fontSize];
    CFRelease(ctFont);
    CFRelease(baseCTFont);
    
    return variantFont;
}

+ (UIFont *)yh_dinMediumFontWithSize:(CGFloat)size
{
    return [UIFont fontWithName:@"DIN-Medium" size:size];
}


+ (UIFont *)yh_dinRegularFontWithSize:(CGFloat)size
{
    return [UIFont fontWithName:@"DIN-Regular" size:size];
}

/**
 *  15-12-02 16:12:50
 *
 *  判断是否有PingFangSC-Light字体
 *
 */
+ (UIFont *)fontOfLightWithSize:(CGFloat)fontSize
{
    UIFont *font = [UIFont fontWithName:@"PingFangSC-Light" size:fontSize];
    if (!font) {
        font = [UIFont systemFontOfSize:fontSize];
    }
    return font;
}

+ (UIFont *)fontOfBoldWithSize:(CGFloat)fontSize
{
    UIFont *font = [UIFont fontWithName:@"PingFangSC-Bold" size:fontSize];
    if (!font) {
        font = [UIFont boldSystemFontOfSize:fontSize];
    }
    return font;
}

@end