set unrecognized font family to default.

This commit is contained in:
Horcrux
2016-08-13 17:00:15 +08:00
parent b705280326
commit d84b00d02f
2 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -47,8 +47,8 @@
clipPaths = nil;
templates = nil;
brushConverters = nil;
CGContextRef context = UIGraphicsGetCurrentContext();
_boundingBox = rect;
CGContextRef context = UIGraphicsGetCurrentContext();
for (RNSVGNode *node in self.subviews) {
if ([node isKindOfClass:[RNSVGNode class]]) {
+10 -1
View File
@@ -99,7 +99,13 @@ RCT_ENUM_CONVERTER(RNSVGVBMOS, (@{
}
NSDictionary *fontDict = dict[@"font"];
CTFontRef font = (__bridge CTFontRef)[self UIFont:nil withFamily:fontDict[@"fontFamily"] size:fontDict[@"fontSize"] weight:fontDict[@"fontWeight"] style:fontDict[@"fontStyle"] scaleMultiplier:1.0];
NSString *fontFamily = fontDict[@"fontFamily"];
if (![[UIFont familyNames] containsObject:fontFamily]) {
fontFamily = nil;
}
CTFontRef font = (__bridge CTFontRef)[self UIFont:nil withFamily:fontFamily size:fontDict[@"fontSize"] weight:fontDict[@"fontWeight"] style:fontDict[@"fontStyle"] scaleMultiplier:1.0];
if (!font) {
return frame;
}
@@ -262,12 +268,15 @@ RCT_ENUM_CONVERTER(RNSVGVBMOS, (@{
RNSVGCGFloatArray colorsAndOffsets = [self RNSVGCGFloatArray:arr];
size_t stops = colorsAndOffsets.count / 5;
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColorComponents(
rgb,
colorsAndOffsets.array,
colorsAndOffsets.array + stops * 4,
stops
);
CGColorSpaceRelease(rgb);
free(colorsAndOffsets.array);
return (CGGradientRef)CFAutorelease(gradient);