Temp commit

This commit is contained in:
Horcrux
2016-11-05 18:42:49 +08:00
parent ed2da1b364
commit da32b1bb96
21 changed files with 524 additions and 255 deletions
+4 -1
View File
@@ -12,14 +12,17 @@
#import "RNSVGCGFloatArray.h"
#import "RCTConvert.h"
#import "RNSVGCGFCRule.h"
#import "RNSVGVBMOS.h"
#import "RNSVGTextAnchor.h"
@class RNSVGBrush;
@interface RCTConvert (RNSVG)
+ (CGPathRef)CGPath:(id)json;
+ (CTTextAlignment)CTTextAlignment:(id)json;
+ (RNSVGTextAnchor)RNSVGTextAnchor:(id)json;
+ (RNSVGCGFCRule)RNSVGCGFCRule:(id)json;
+ (RNSVGVBMOS)RNSVGVBMOS:(id)json;
+ (CTFontRef)RNSVGFont:(id)json;
+ (RNSVGCGFloatArray)RNSVGCGFloatArray:(id)json;
+ (RNSVGBrush *)RNSVGBrush:(id)json;
+20 -12
View File
@@ -12,8 +12,6 @@
#import "RNSVGPattern.h"
#import "RNSVGSolidColorBrush.h"
#import "RCTLog.h"
#import "RNSVGCGFCRule.h"
#import "RNSVGVBMOS.h"
#import "RCTFont.h"
@implementation RCTConvert (RNSVG)
@@ -65,14 +63,6 @@
return (CGPathRef)CFAutorelease(path);
}
RCT_ENUM_CONVERTER(CTTextAlignment, (@{
@"auto": @(kCTTextAlignmentNatural),
@"left": @(kCTTextAlignmentLeft),
@"center": @(kCTTextAlignmentCenter),
@"right": @(kCTTextAlignmentRight),
@"justify": @(kCTTextAlignmentJustified),
}), kCTTextAlignmentNatural, integerValue)
RCT_ENUM_CONVERTER(RNSVGCGFCRule, (@{
@"evenodd": @(kRNSVGCGFCRuleEvenodd),
@"nonzero": @(kRNSVGCGFCRuleNonzero),
@@ -84,16 +74,34 @@ RCT_ENUM_CONVERTER(RNSVGVBMOS, (@{
@"none": @(kRNSVGVBMOSNone)
}), kRNSVGVBMOSMeet, intValue)
RCT_ENUM_CONVERTER(RNSVGTextAnchor, (@{
@"auto": @(kRNSVGTextAnchorAuto),
@"start": @(kRNSVGTextAnchorStart),
@"middle": @(kRNSVGTextAnchorMiddle),
@"end": @(kRNSVGTextAnchorEnd)
}), kRNSVGTextAnchorAuto, intValue)
+ (CTFontRef)RNSVGFont:(id)json
{
NSDictionary *dict = [self NSDictionary:json];
NSString *fontFamily = dict[@"fontFamily"];
if (![[UIFont familyNames] containsObject:fontFamily]) {
fontFamily = nil;
BOOL fontFound = NO;
NSArray *supportedFontFamilyNames = [UIFont familyNames];
if ([supportedFontFamilyNames containsObject:fontFamily]) {
fontFound = YES;
} else {
for (NSString *fontFamilyName in supportedFontFamilyNames) {
if ([[UIFont fontNamesForFamilyName: fontFamilyName] containsObject:fontFamily]) {
fontFound = YES;
break;
}
}
}
fontFamily = fontFound ? fontFamily : nil;
return (__bridge CTFontRef)[RCTFont updateFont:nil withFamily:fontFamily size:dict[@"fontSize"] weight:dict[@"fontWeight"] style:dict[@"fontStyle"] variant:nil scaleMultiplier:1.0];
}
+14
View File
@@ -0,0 +1,14 @@
/**
* Copyright (c) 2015-present, Horcrux.
* All rights reserved.
*
* This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree.
*/
typedef CF_ENUM(int32_t, RNSVGTextAnchor) {
kRNSVGTextAnchorAuto,
kRNSVGTextAnchorStart,
kRNSVGTextAnchorMiddle,
kRNSVGTextAnchorEnd
};