mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-04 23:54:53 +00:00
refactor Use and Defs element with native code support(iOS)
This commit is contained in:
@@ -81,7 +81,7 @@ static void RNSVGFreeTextFrame(RNSVGTextFrame frame)
|
||||
}
|
||||
// We should consider snapping this shift to device pixels to improve rendering quality
|
||||
// when a line has subpixel width.
|
||||
CGAffineTransform offset = CGAffineTransformMakeTranslation(-shift, frame.baseLine + frame.lineHeight * i + (self.path == NULL ? 0 : -frame.lineHeight));
|
||||
CGAffineTransform offset = CGAffineTransformMakeTranslation(-shift, frame.baseLine + frame.lineHeight * i + (self.path ? -frame.lineHeight : 0));
|
||||
CGPathAddPath(path, &offset, [self setLinePath:frame.lines[i]]);
|
||||
}
|
||||
|
||||
@@ -115,11 +115,11 @@ static void RNSVGFreeTextFrame(RNSVGTextFrame frame)
|
||||
for(CFIndex j = 0; j < runGlyphCount; ++j, ++glyphIndex) {
|
||||
CGPathRef letter = [cache pathForGlyph:glyphs[j] fromFont:runFont];
|
||||
CGPoint point = positions[j];
|
||||
if (letter != NULL) {
|
||||
if (letter) {
|
||||
CGAffineTransform transform;
|
||||
|
||||
// draw glyphs along path
|
||||
if (self.path != NULL) {
|
||||
if (self.path) {
|
||||
CGPoint slope;
|
||||
CGRect bounding = CGPathGetBoundingBox(letter);
|
||||
UIBezierPath* path = [UIBezierPath bezierPathWithCGPath:self.path];
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
-(id)init
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
if(self)
|
||||
{
|
||||
cache = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
|
||||
}
|
||||
@@ -29,7 +29,7 @@
|
||||
{
|
||||
// First we lookup the font to get to its glyph dictionary
|
||||
CFMutableDictionaryRef glyphDict = (CFMutableDictionaryRef)CFDictionaryGetValue(cache, font);
|
||||
if(glyphDict == NULL)
|
||||
if(!glyphDict)
|
||||
{
|
||||
// And if this font hasn't been seen before, we'll create and set the dictionary for it
|
||||
glyphDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, &kCFTypeDictionaryValueCallBacks);
|
||||
@@ -38,11 +38,11 @@
|
||||
}
|
||||
// Next we try to get a path for the given glyph from the glyph dictionary
|
||||
CGPathRef path = (CGPathRef)CFDictionaryGetValue(glyphDict, (const void *)(uintptr_t)glyph);
|
||||
if(path == NULL)
|
||||
if(!path)
|
||||
{
|
||||
// If the path hasn't been seen before, then we'll create the path from the font & glyph and cache it.
|
||||
path = CTFontCreatePathForGlyph(font, glyph, NULL);
|
||||
if(path == NULL)
|
||||
if(!path)
|
||||
{
|
||||
// If a glyph does not have a path, then we need a placeholder to set in the dictionary
|
||||
path = (CGPathRef)kCFNull;
|
||||
|
||||
Reference in New Issue
Block a user