mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-02 06:35:04 +00:00
Temp commit
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
Reference in New Issue
Block a user