From b217dcaff84659516ae8fe7c5c0e0e0623e7dea7 Mon Sep 17 00:00:00 2001 From: Ben Roth Date: Wed, 14 Feb 2018 11:53:27 -0800 Subject: [PATCH] Prefix iOS symbols with RNSVG fixes https://github.com/react-native-community/react-native-svg/issues/603 --- ios/Elements/RNSVGGroup.h | 4 +- ios/Elements/RNSVGGroup.m | 8 +- ios/RNSVG.xcodeproj/project.pbxproj | 150 +++---------- ios/RNSVGNode.h | 2 +- ios/RNSVGNode.m | 42 ++-- ios/Text/AlignmentBaseline.h | 63 ------ ios/Text/AlignmentBaseline.m | 17 -- ios/Text/FontStyle.h | 19 -- ios/Text/FontStyle.m | 17 -- ios/Text/FontVariantLigatures.h | 18 -- ios/Text/FontVariantLigatures.m | 17 -- ios/Text/FontWeight.h | 30 --- ios/Text/FontWeight.m | 17 -- ios/Text/{FontData.h => RNSVGFontData.h} | 24 +-- ios/Text/{FontData.m => RNSVGFontData.m} | 86 ++++---- .../{GlyphContext.h => RNSVGGlyphContext.h} | 8 +- .../{GlyphContext.m => RNSVGGlyphContext.m} | 80 +++---- ios/Text/{PropHelper.h => RNSVGPropHelper.h} | 6 +- ios/Text/{PropHelper.m => RNSVGPropHelper.m} | 4 +- ios/Text/RNSVGTSpan.h | 6 - ios/Text/RNSVGTSpan.m | 106 +++++----- ios/Text/RNSVGText.h | 1 - ios/Text/RNSVGText.m | 13 +- ios/Text/RNSVGTextPath.m | 6 +- ios/Text/RNSVGTextProperties.h | 200 ++++++++++++++++++ ios/Text/RNSVGTextProperties.m | 199 +++++++++++++++++ ios/Text/TextAnchor.h | 19 -- ios/Text/TextAnchor.m | 17 -- ios/Text/TextDecoration.h | 21 -- ios/Text/TextDecoration.m | 17 -- ios/Text/TextLengthAdjust.h | 18 -- ios/Text/TextLengthAdjust.m | 17 -- ios/Text/TextPathMethod.h | 18 -- ios/Text/TextPathMethod.m | 17 -- ios/Text/TextPathMidLine.h | 18 -- ios/Text/TextPathMidLine.m | 17 -- ios/Text/TextPathSide.h | 18 -- ios/Text/TextPathSide.m | 17 -- ios/Text/TextPathSpacing.h | 18 -- ios/Text/TextPathSpacing.m | 17 -- .../{BezierElement.h => RNSVGBezierElement.h} | 4 +- .../{BezierElement.m => RNSVGBezierElement.m} | 16 +- ios/Utils/RNSVGPathParser.m | 4 +- 43 files changed, 632 insertions(+), 784 deletions(-) delete mode 100644 ios/Text/AlignmentBaseline.h delete mode 100644 ios/Text/AlignmentBaseline.m delete mode 100644 ios/Text/FontStyle.h delete mode 100644 ios/Text/FontStyle.m delete mode 100644 ios/Text/FontVariantLigatures.h delete mode 100644 ios/Text/FontVariantLigatures.m delete mode 100644 ios/Text/FontWeight.h delete mode 100644 ios/Text/FontWeight.m rename ios/Text/{FontData.h => RNSVGFontData.h} (56%) rename ios/Text/{FontData.m => RNSVGFontData.m} (53%) rename ios/Text/{GlyphContext.h => RNSVGGlyphContext.h} (88%) rename ios/Text/{GlyphContext.m => RNSVGGlyphContext.m} (85%) rename ios/Text/{PropHelper.h => RNSVGPropHelper.h} (79%) rename ios/Text/{PropHelper.m => RNSVGPropHelper.m} (96%) create mode 100644 ios/Text/RNSVGTextProperties.h create mode 100644 ios/Text/RNSVGTextProperties.m delete mode 100644 ios/Text/TextAnchor.h delete mode 100644 ios/Text/TextAnchor.m delete mode 100644 ios/Text/TextDecoration.h delete mode 100644 ios/Text/TextDecoration.m delete mode 100644 ios/Text/TextLengthAdjust.h delete mode 100644 ios/Text/TextLengthAdjust.m delete mode 100644 ios/Text/TextPathMethod.h delete mode 100644 ios/Text/TextPathMethod.m delete mode 100644 ios/Text/TextPathMidLine.h delete mode 100644 ios/Text/TextPathMidLine.m delete mode 100644 ios/Text/TextPathSide.h delete mode 100644 ios/Text/TextPathSide.m delete mode 100644 ios/Text/TextPathSpacing.h delete mode 100644 ios/Text/TextPathSpacing.m rename ios/Utils/{BezierElement.h => RNSVGBezierElement.h} (87%) rename ios/Utils/{BezierElement.m => RNSVGBezierElement.m} (80%) diff --git a/ios/Elements/RNSVGGroup.h b/ios/Elements/RNSVGGroup.h index 2db11ec4..163d8477 100644 --- a/ios/Elements/RNSVGGroup.h +++ b/ios/Elements/RNSVGGroup.h @@ -12,7 +12,7 @@ #import "RNSVGCGFCRule.h" #import "RNSVGSvgView.h" #import "RNSVGPath.h" -#import "GlyphContext.h" +#import "RNSVGGlyphContext.h" @interface RNSVGGroup : RNSVGPath @@ -21,7 +21,7 @@ - (void)renderPathTo:(CGContextRef)context; - (void)renderGroupTo:(CGContextRef)context; -- (GlyphContext *)getGlyphContext; +- (RNSVGGlyphContext *)getGlyphContext; - (void)pushGlyphContext; - (void)popGlyphContext; @end diff --git a/ios/Elements/RNSVGGroup.m b/ios/Elements/RNSVGGroup.m index 3f2fd159..c2ec51ae 100644 --- a/ios/Elements/RNSVGGroup.m +++ b/ios/Elements/RNSVGGroup.m @@ -10,7 +10,7 @@ @implementation RNSVGGroup { - GlyphContext *_glyphContext; + RNSVGGlyphContext *_glyphContext; } - (void)setFont:(NSDictionary*)font @@ -61,11 +61,11 @@ CGFloat width = CGRectGetWidth(clipBounds); CGFloat height = CGRectGetHeight(clipBounds); - _glyphContext = [[GlyphContext alloc] initWithScale:1 width:width - height:height]; + _glyphContext = [[RNSVGGlyphContext alloc] initWithScale:1 width:width + height:height]; } -- (GlyphContext *)getGlyphContext +- (RNSVGGlyphContext *)getGlyphContext { return _glyphContext; } diff --git a/ios/RNSVG.xcodeproj/project.pbxproj b/ios/RNSVG.xcodeproj/project.pbxproj index aaaa6675..c15148b8 100644 --- a/ios/RNSVG.xcodeproj/project.pbxproj +++ b/ios/RNSVG.xcodeproj/project.pbxproj @@ -45,7 +45,6 @@ 10ED4A9E1CF0656A0078BC02 /* RNSVGClipPathManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 10ED4A9D1CF0656A0078BC02 /* RNSVGClipPathManager.m */; }; 10ED4AA21CF078830078BC02 /* RNSVGNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 10ED4AA11CF078830078BC02 /* RNSVGNode.m */; }; 10FDEEB21D3FB60500A5C46C /* RNSVGPainterBrush.m in Sources */ = {isa = PBXBuildFile; fileRef = 10FDEEB11D3FB60500A5C46C /* RNSVGPainterBrush.m */; }; - 2DE5BD1C201C5CC1008DC1FE /* BezierElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 94C70B171FF6B1C0004DFD49 /* BezierElement.m */; }; 7F08CE9A1E23476900650F83 /* RNSVGTextPathManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F08CE971E23476900650F83 /* RNSVGTextPathManager.m */; }; 7F08CE9B1E23476900650F83 /* RNSVGTSpanManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F08CE991E23476900650F83 /* RNSVGTSpanManager.m */; }; 7F08CEA01E23479700650F83 /* RNSVGTextPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F08CE9D1E23479700650F83 /* RNSVGTextPath.m */; }; @@ -54,41 +53,12 @@ 7FC260CE1E3499BC00A39833 /* RNSVGViewBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FC260CD1E3499BC00A39833 /* RNSVGViewBox.m */; }; 7FC260D11E34A12000A39833 /* RNSVGSymbol.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FC260D01E34A12000A39833 /* RNSVGSymbol.m */; }; 7FC260D41E34A12A00A39833 /* RNSVGSymbolManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FC260D31E34A12A00A39833 /* RNSVGSymbolManager.m */; }; - 945A8AF81F4CE3E8004BBF6B /* AlignmentBaseline.m in Sources */ = {isa = PBXBuildFile; fileRef = 945A8AF71F4CE3E8004BBF6B /* AlignmentBaseline.m */; }; - 945A8AF91F4CE3E8004BBF6B /* AlignmentBaseline.m in Sources */ = {isa = PBXBuildFile; fileRef = 945A8AF71F4CE3E8004BBF6B /* AlignmentBaseline.m */; }; 9494C4D81F473BA700D5BCFD /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9494C4D71F473BA700D5BCFD /* QuartzCore.framework */; }; 9494C4DA1F473BCB00D5BCFD /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9494C4D91F473BCB00D5BCFD /* CoreText.framework */; }; 9494C4DC1F473BD900D5BCFD /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9494C4DB1F473BD900D5BCFD /* CoreGraphics.framework */; }; 9494C4DE1F473BDD00D5BCFD /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9494C4DD1F473BDD00D5BCFD /* UIKit.framework */; }; 9494C4E01F473BED00D5BCFD /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9494C4DF1F473BED00D5BCFD /* Accelerate.framework */; }; 9494C4E21F473BF500D5BCFD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9494C4E11F473BF500D5BCFD /* Foundation.framework */; }; - 9494C4FF1F4B5BE800D5BCFD /* FontData.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C4E81F4B5BE700D5BCFD /* FontData.m */; }; - 9494C5001F4B5BE800D5BCFD /* FontData.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C4E81F4B5BE700D5BCFD /* FontData.m */; }; - 9494C5051F4B5BE800D5BCFD /* FontWeight.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C4EE1F4B5BE700D5BCFD /* FontWeight.m */; }; - 9494C5061F4B5BE800D5BCFD /* FontWeight.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C4EE1F4B5BE700D5BCFD /* FontWeight.m */; }; - 9494C5071F4B5BE800D5BCFD /* PropHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C4F01F4B5BE700D5BCFD /* PropHelper.m */; }; - 9494C5081F4B5BE800D5BCFD /* PropHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C4F01F4B5BE700D5BCFD /* PropHelper.m */; }; - 9494C5251F4B605F00D5BCFD /* GlyphContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C51A1F4B605F00D5BCFD /* GlyphContext.m */; }; - 9494C5261F4B605F00D5BCFD /* GlyphContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C51A1F4B605F00D5BCFD /* GlyphContext.m */; }; - 9494C5381F4C44DD00D5BCFD /* FontStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C52F1F4C44DD00D5BCFD /* FontStyle.m */; }; - 9494C5391F4C44DD00D5BCFD /* FontStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C52F1F4C44DD00D5BCFD /* FontStyle.m */; }; - 9494C53A1F4C44DD00D5BCFD /* FontVariantLigatures.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5301F4C44DD00D5BCFD /* FontVariantLigatures.m */; }; - 9494C53B1F4C44DD00D5BCFD /* FontVariantLigatures.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5301F4C44DD00D5BCFD /* FontVariantLigatures.m */; }; - 9494C53C1F4C44DD00D5BCFD /* TextAnchor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5311F4C44DD00D5BCFD /* TextAnchor.m */; }; - 9494C53D1F4C44DD00D5BCFD /* TextAnchor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5311F4C44DD00D5BCFD /* TextAnchor.m */; }; - 9494C53E1F4C44DD00D5BCFD /* TextDecoration.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5321F4C44DD00D5BCFD /* TextDecoration.m */; }; - 9494C53F1F4C44DD00D5BCFD /* TextDecoration.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5321F4C44DD00D5BCFD /* TextDecoration.m */; }; - 9494C5401F4C44DD00D5BCFD /* TextLengthAdjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5331F4C44DD00D5BCFD /* TextLengthAdjust.m */; }; - 9494C5411F4C44DD00D5BCFD /* TextLengthAdjust.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5331F4C44DD00D5BCFD /* TextLengthAdjust.m */; }; - 9494C5421F4C44DD00D5BCFD /* TextPathMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5341F4C44DD00D5BCFD /* TextPathMethod.m */; }; - 9494C5431F4C44DD00D5BCFD /* TextPathMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5341F4C44DD00D5BCFD /* TextPathMethod.m */; }; - 9494C5441F4C44DD00D5BCFD /* TextPathMidLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5351F4C44DD00D5BCFD /* TextPathMidLine.m */; }; - 9494C5451F4C44DD00D5BCFD /* TextPathMidLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5351F4C44DD00D5BCFD /* TextPathMidLine.m */; }; - 9494C5461F4C44DD00D5BCFD /* TextPathSide.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5361F4C44DD00D5BCFD /* TextPathSide.m */; }; - 9494C5471F4C44DD00D5BCFD /* TextPathSide.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5361F4C44DD00D5BCFD /* TextPathSide.m */; }; - 9494C5481F4C44DD00D5BCFD /* TextPathSpacing.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5371F4C44DD00D5BCFD /* TextPathSpacing.m */; }; - 9494C5491F4C44DD00D5BCFD /* TextPathSpacing.m in Sources */ = {isa = PBXBuildFile; fileRef = 9494C5371F4C44DD00D5BCFD /* TextPathSpacing.m */; }; - 94C70B1A1FF6B1C0004DFD49 /* BezierElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 94C70B171FF6B1C0004DFD49 /* BezierElement.m */; }; A361E76E1EB0C33D00646005 /* RNSVGTextManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 10BA0D331CE74E3100887C2B /* RNSVGTextManager.m */; }; A361E76F1EB0C33D00646005 /* RNSVGImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 1039D2841CE71EB7001E90A8 /* RNSVGImage.m */; }; A361E7701EB0C33D00646005 /* RNSVGRect.m in Sources */ = {isa = PBXBuildFile; fileRef = 10BA0D471CE74E3D00887C2B /* RNSVGRect.m */; }; @@ -135,6 +105,11 @@ A361E79B1EB0C33D00646005 /* RNSVGSvgView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1039D2881CE71EB7001E90A8 /* RNSVGSvgView.m */; }; A361E79C1EB0C33D00646005 /* RNSVGUseManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B4951D3DF57D0051496D /* RNSVGUseManager.m */; }; A361E79D1EB0C33D00646005 /* RNSVGDefsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1023B48C1D3DDCCE0051496D /* RNSVGDefsManager.m */; }; + B56895A720352750004DBF1E /* RNSVGTextProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = B56895A62035274F004DBF1E /* RNSVGTextProperties.m */; }; + B56895AA20352B36004DBF1E /* RNSVGBezierElement.m in Sources */ = {isa = PBXBuildFile; fileRef = B56895A820352B35004DBF1E /* RNSVGBezierElement.m */; }; + B56895B120352B9C004DBF1E /* RNSVGPropHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = B56895AB20352B9B004DBF1E /* RNSVGPropHelper.m */; }; + B56895B220352B9C004DBF1E /* RNSVGGlyphContext.m in Sources */ = {isa = PBXBuildFile; fileRef = B56895AF20352B9B004DBF1E /* RNSVGGlyphContext.m */; }; + B56895B320352B9C004DBF1E /* RNSVGFontData.m in Sources */ = {isa = PBXBuildFile; fileRef = B56895B020352B9B004DBF1E /* RNSVGFontData.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -258,43 +233,23 @@ 7FC260D01E34A12000A39833 /* RNSVGSymbol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGSymbol.m; path = Elements/RNSVGSymbol.m; sourceTree = ""; }; 7FC260D21E34A12A00A39833 /* RNSVGSymbolManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSVGSymbolManager.h; sourceTree = ""; }; 7FC260D31E34A12A00A39833 /* RNSVGSymbolManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSVGSymbolManager.m; sourceTree = ""; }; - 945A8AF71F4CE3E8004BBF6B /* AlignmentBaseline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AlignmentBaseline.m; path = Text/AlignmentBaseline.m; sourceTree = ""; }; - 945A8AFA1F4CE41E004BBF6B /* AlignmentBaseline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AlignmentBaseline.h; path = Text/AlignmentBaseline.h; sourceTree = ""; }; 9494C4D71F473BA700D5BCFD /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 9494C4D91F473BCB00D5BCFD /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; 9494C4DB1F473BD900D5BCFD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 9494C4DD1F473BDD00D5BCFD /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9494C4DF1F473BED00D5BCFD /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; 9494C4E11F473BF500D5BCFD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 9494C4E71F4B5BE700D5BCFD /* FontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FontData.h; path = Text/FontData.h; sourceTree = ""; }; - 9494C4E81F4B5BE700D5BCFD /* FontData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FontData.m; path = Text/FontData.m; sourceTree = ""; }; - 9494C4E91F4B5BE700D5BCFD /* FontStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FontStyle.h; path = Text/FontStyle.h; sourceTree = ""; }; - 9494C4EB1F4B5BE700D5BCFD /* FontVariantLigatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FontVariantLigatures.h; path = Text/FontVariantLigatures.h; sourceTree = ""; }; - 9494C4ED1F4B5BE700D5BCFD /* FontWeight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FontWeight.h; path = Text/FontWeight.h; sourceTree = ""; }; - 9494C4EE1F4B5BE700D5BCFD /* FontWeight.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FontWeight.m; path = Text/FontWeight.m; sourceTree = ""; }; - 9494C4EF1F4B5BE700D5BCFD /* PropHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PropHelper.h; path = Text/PropHelper.h; sourceTree = ""; }; - 9494C4F01F4B5BE700D5BCFD /* PropHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PropHelper.m; path = Text/PropHelper.m; sourceTree = ""; }; - 9494C4F11F4B5BE700D5BCFD /* TextAnchor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextAnchor.h; path = Text/TextAnchor.h; sourceTree = ""; }; - 9494C4F31F4B5BE700D5BCFD /* TextDecoration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextDecoration.h; path = Text/TextDecoration.h; sourceTree = ""; }; - 9494C4F51F4B5BE700D5BCFD /* TextLengthAdjust.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextLengthAdjust.h; path = Text/TextLengthAdjust.h; sourceTree = ""; }; - 9494C4F71F4B5BE700D5BCFD /* TextPathMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextPathMethod.h; path = Text/TextPathMethod.h; sourceTree = ""; }; - 9494C4F91F4B5BE700D5BCFD /* TextPathMidLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextPathMidLine.h; path = Text/TextPathMidLine.h; sourceTree = ""; }; - 9494C4FB1F4B5BE700D5BCFD /* TextPathSide.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextPathSide.h; path = Text/TextPathSide.h; sourceTree = ""; }; - 9494C4FD1F4B5BE700D5BCFD /* TextPathSpacing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextPathSpacing.h; path = Text/TextPathSpacing.h; sourceTree = ""; }; - 9494C5191F4B605F00D5BCFD /* GlyphContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GlyphContext.h; path = Text/GlyphContext.h; sourceTree = ""; }; - 9494C51A1F4B605F00D5BCFD /* GlyphContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GlyphContext.m; path = Text/GlyphContext.m; sourceTree = ""; }; - 9494C52F1F4C44DD00D5BCFD /* FontStyle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FontStyle.m; path = Text/FontStyle.m; sourceTree = ""; }; - 9494C5301F4C44DD00D5BCFD /* FontVariantLigatures.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FontVariantLigatures.m; path = Text/FontVariantLigatures.m; sourceTree = ""; }; - 9494C5311F4C44DD00D5BCFD /* TextAnchor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextAnchor.m; path = Text/TextAnchor.m; sourceTree = ""; }; - 9494C5321F4C44DD00D5BCFD /* TextDecoration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextDecoration.m; path = Text/TextDecoration.m; sourceTree = ""; }; - 9494C5331F4C44DD00D5BCFD /* TextLengthAdjust.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextLengthAdjust.m; path = Text/TextLengthAdjust.m; sourceTree = ""; }; - 9494C5341F4C44DD00D5BCFD /* TextPathMethod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextPathMethod.m; path = Text/TextPathMethod.m; sourceTree = ""; }; - 9494C5351F4C44DD00D5BCFD /* TextPathMidLine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextPathMidLine.m; path = Text/TextPathMidLine.m; sourceTree = ""; }; - 9494C5361F4C44DD00D5BCFD /* TextPathSide.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextPathSide.m; path = Text/TextPathSide.m; sourceTree = ""; }; - 9494C5371F4C44DD00D5BCFD /* TextPathSpacing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextPathSpacing.m; path = Text/TextPathSpacing.m; sourceTree = ""; }; - 94C70B151FF6B1BF004DFD49 /* BezierElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BezierElement.h; path = Utils/BezierElement.h; sourceTree = ""; }; - 94C70B171FF6B1C0004DFD49 /* BezierElement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BezierElement.m; path = Utils/BezierElement.m; sourceTree = ""; }; 94DDAC5C1F3D024300EED511 /* libRNSVG-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libRNSVG-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B56895A52035274F004DBF1E /* RNSVGTextProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGTextProperties.h; path = ../../../../ios/Text/RNSVGTextProperties.h; sourceTree = ""; }; + B56895A62035274F004DBF1E /* RNSVGTextProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGTextProperties.m; path = ../../../../ios/Text/RNSVGTextProperties.m; sourceTree = ""; }; + B56895A820352B35004DBF1E /* RNSVGBezierElement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGBezierElement.m; path = ../../../../ios/Utils/RNSVGBezierElement.m; sourceTree = ""; }; + B56895A920352B36004DBF1E /* RNSVGBezierElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGBezierElement.h; path = ../../../../ios/Utils/RNSVGBezierElement.h; sourceTree = ""; }; + B56895AB20352B9B004DBF1E /* RNSVGPropHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGPropHelper.m; path = ../../../../ios/Text/RNSVGPropHelper.m; sourceTree = ""; }; + B56895AC20352B9B004DBF1E /* RNSVGFontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGFontData.h; path = ../../../../ios/Text/RNSVGFontData.h; sourceTree = ""; }; + B56895AD20352B9B004DBF1E /* RNSVGGlyphContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGGlyphContext.h; path = ../../../../ios/Text/RNSVGGlyphContext.h; sourceTree = ""; }; + B56895AE20352B9B004DBF1E /* RNSVGPropHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RNSVGPropHelper.h; path = ../../../../ios/Text/RNSVGPropHelper.h; sourceTree = ""; }; + B56895AF20352B9B004DBF1E /* RNSVGGlyphContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGGlyphContext.m; path = ../../../../ios/Text/RNSVGGlyphContext.m; sourceTree = ""; }; + B56895B020352B9B004DBF1E /* RNSVGFontData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RNSVGFontData.m; path = ../../../../ios/Text/RNSVGFontData.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -428,40 +383,20 @@ 1039D27F1CE71D9B001E90A8 /* Text */ = { isa = PBXGroup; children = ( - 945A8AFA1F4CE41E004BBF6B /* AlignmentBaseline.h */, - 945A8AF71F4CE3E8004BBF6B /* AlignmentBaseline.m */, - 9494C4E71F4B5BE700D5BCFD /* FontData.h */, - 9494C4E81F4B5BE700D5BCFD /* FontData.m */, - 9494C4E91F4B5BE700D5BCFD /* FontStyle.h */, - 9494C52F1F4C44DD00D5BCFD /* FontStyle.m */, - 9494C4EB1F4B5BE700D5BCFD /* FontVariantLigatures.h */, - 9494C5301F4C44DD00D5BCFD /* FontVariantLigatures.m */, - 9494C4ED1F4B5BE700D5BCFD /* FontWeight.h */, - 9494C4EE1F4B5BE700D5BCFD /* FontWeight.m */, - 9494C5191F4B605F00D5BCFD /* GlyphContext.h */, - 9494C51A1F4B605F00D5BCFD /* GlyphContext.m */, - 9494C4EF1F4B5BE700D5BCFD /* PropHelper.h */, - 9494C4F01F4B5BE700D5BCFD /* PropHelper.m */, + B56895AC20352B9B004DBF1E /* RNSVGFontData.h */, + B56895B020352B9B004DBF1E /* RNSVGFontData.m */, + B56895AD20352B9B004DBF1E /* RNSVGGlyphContext.h */, + B56895AF20352B9B004DBF1E /* RNSVGGlyphContext.m */, + B56895AE20352B9B004DBF1E /* RNSVGPropHelper.h */, + B56895AB20352B9B004DBF1E /* RNSVGPropHelper.m */, 1039D28F1CE71EC2001E90A8 /* RNSVGText.h */, 1039D2901CE71EC2001E90A8 /* RNSVGText.m */, 7F08CE9C1E23479700650F83 /* RNSVGTextPath.h */, 7F08CE9D1E23479700650F83 /* RNSVGTextPath.m */, + B56895A52035274F004DBF1E /* RNSVGTextProperties.h */, + B56895A62035274F004DBF1E /* RNSVGTextProperties.m */, 7F08CE9E1E23479700650F83 /* RNSVGTSpan.h */, 7F08CE9F1E23479700650F83 /* RNSVGTSpan.m */, - 9494C4F11F4B5BE700D5BCFD /* TextAnchor.h */, - 9494C5311F4C44DD00D5BCFD /* TextAnchor.m */, - 9494C4F31F4B5BE700D5BCFD /* TextDecoration.h */, - 9494C5321F4C44DD00D5BCFD /* TextDecoration.m */, - 9494C4F51F4B5BE700D5BCFD /* TextLengthAdjust.h */, - 9494C5331F4C44DD00D5BCFD /* TextLengthAdjust.m */, - 9494C4F71F4B5BE700D5BCFD /* TextPathMethod.h */, - 9494C5341F4C44DD00D5BCFD /* TextPathMethod.m */, - 9494C4F91F4B5BE700D5BCFD /* TextPathMidLine.h */, - 9494C5351F4C44DD00D5BCFD /* TextPathMidLine.m */, - 9494C4FB1F4B5BE700D5BCFD /* TextPathSide.h */, - 9494C5361F4C44DD00D5BCFD /* TextPathSide.m */, - 9494C4FD1F4B5BE700D5BCFD /* TextPathSpacing.h */, - 9494C5371F4C44DD00D5BCFD /* TextPathSpacing.m */, ); name = Text; sourceTree = ""; @@ -496,8 +431,8 @@ 1039D29A1CE7212C001E90A8 /* Utils */ = { isa = PBXGroup; children = ( - 94C70B151FF6B1BF004DFD49 /* BezierElement.h */, - 94C70B171FF6B1C0004DFD49 /* BezierElement.m */, + B56895A920352B36004DBF1E /* RNSVGBezierElement.h */, + B56895A820352B35004DBF1E /* RNSVGBezierElement.m */, 7F69160D1E3703D800DA6EDC /* RNSVGUnits.h */, 10ABC7381D43982B006CCF6E /* RNSVGVBMOS.h */, 10ABC7371D439779006CCF6E /* RNSVGCGFCRule.h */, @@ -600,16 +535,14 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + B56895AA20352B36004DBF1E /* RNSVGBezierElement.m in Sources */, 10BA0D3F1CE74E3100887C2B /* RNSVGTextManager.m in Sources */, 1039D28A1CE71EB7001E90A8 /* RNSVGImage.m in Sources */, 10BA0D4B1CE74E3D00887C2B /* RNSVGRect.m in Sources */, 10BA0D341CE74E3100887C2B /* RNSVGCircleManager.m in Sources */, 10BEC1BC1D3F66F500FDCB19 /* RNSVGLinearGradient.m in Sources */, - 9494C5461F4C44DD00D5BCFD /* TextPathSide.m in Sources */, 1039D2B01CE72F27001E90A8 /* RNSVGPercentageConverter.m in Sources */, - 9494C53C1F4C44DD00D5BCFD /* TextAnchor.m in Sources */, 10BA0D491CE74E3D00887C2B /* RNSVGEllipse.m in Sources */, - 9494C5051F4B5BE800D5BCFD /* FontWeight.m in Sources */, 1039D28B1CE71EB7001E90A8 /* RNSVGPath.m in Sources */, 7F08CEA01E23479700650F83 /* RNSVGTextPath.m in Sources */, 1023B4931D3DF5060051496D /* RNSVGUse.m in Sources */, @@ -619,48 +552,40 @@ 0CF68B071AF0549300FF9E5C /* RNSVGRenderable.m in Sources */, 1039D2891CE71EB7001E90A8 /* RNSVGGroup.m in Sources */, 10ED4A9E1CF0656A0078BC02 /* RNSVGClipPathManager.m in Sources */, - 945A8AF81F4CE3E8004BBF6B /* AlignmentBaseline.m in Sources */, 10BEC1C61D3F7BD300FDCB19 /* RNSVGPainter.m in Sources */, - 9494C5381F4C44DD00D5BCFD /* FontStyle.m in Sources */, - 9494C5071F4B5BE800D5BCFD /* PropHelper.m in Sources */, 10ED4AA21CF078830078BC02 /* RNSVGNode.m in Sources */, 10ED4A9B1CF065260078BC02 /* RNSVGClipPath.m in Sources */, 10BA0D3E1CE74E3100887C2B /* RNSVGSvgViewManager.m in Sources */, 0CF68B0F1AF0549300FF9E5C /* RNSVGSolidColorBrush.m in Sources */, 10BA0D3A1CE74E3100887C2B /* RNSVGPathManager.m in Sources */, + B56895B220352B9C004DBF1E /* RNSVGGlyphContext.m in Sources */, 10BA0D3C1CE74E3100887C2B /* RNSVGRenderableManager.m in Sources */, 10BEC1BD1D3F66F500FDCB19 /* RNSVGRadialGradient.m in Sources */, 10BEC1C31D3F680F00FDCB19 /* RNSVGRadialGradientManager.m in Sources */, - 9494C5441F4C44DD00D5BCFD /* TextPathMidLine.m in Sources */, 10BA0D371CE74E3100887C2B /* RNSVGImageManager.m in Sources */, 10BA0D391CE74E3100887C2B /* RNSVGNodeManager.m in Sources */, 7FC260D11E34A12000A39833 /* RNSVGSymbol.m in Sources */, 1023B4901D3DF4C40051496D /* RNSVGDefs.m in Sources */, 10BA0D381CE74E3100887C2B /* RNSVGLineManager.m in Sources */, - 9494C5251F4B605F00D5BCFD /* GlyphContext.m in Sources */, 10BA0D481CE74E3D00887C2B /* RNSVGCircle.m in Sources */, - 9494C5401F4C44DD00D5BCFD /* TextLengthAdjust.m in Sources */, - 94C70B1A1FF6B1C0004DFD49 /* BezierElement.m in Sources */, 10BA0D351CE74E3100887C2B /* RNSVGEllipseManager.m in Sources */, 1039D2A01CE72177001E90A8 /* RCTConvert+RNSVG.m in Sources */, - 9494C4FF1F4B5BE800D5BCFD /* FontData.m in Sources */, 0CF68B0B1AF0549300FF9E5C /* RNSVGBrush.m in Sources */, + B56895A720352750004DBF1E /* RNSVGTextProperties.m in Sources */, 7FC260D41E34A12A00A39833 /* RNSVGSymbolManager.m in Sources */, 7F9CDAFA1E1F809C00E0C805 /* RNSVGPathParser.m in Sources */, 10BA0D361CE74E3100887C2B /* RNSVGGroupManager.m in Sources */, 7F08CE9A1E23476900650F83 /* RNSVGTextPathManager.m in Sources */, 7F08CE9B1E23476900650F83 /* RNSVGTSpanManager.m in Sources */, + B56895B120352B9C004DBF1E /* RNSVGPropHelper.m in Sources */, 7FC260CE1E3499BC00A39833 /* RNSVGViewBox.m in Sources */, - 9494C53E1F4C44DD00D5BCFD /* TextDecoration.m in Sources */, 7F08CEA11E23479700650F83 /* RNSVGTSpan.m in Sources */, - 9494C5421F4C44DD00D5BCFD /* TextPathMethod.m in Sources */, 10BA0D4A1CE74E3D00887C2B /* RNSVGLine.m in Sources */, 10FDEEB21D3FB60500A5C46C /* RNSVGPainterBrush.m in Sources */, 1039D28C1CE71EB7001E90A8 /* RNSVGSvgView.m in Sources */, 1023B4961D3DF57D0051496D /* RNSVGUseManager.m in Sources */, + B56895B320352B9C004DBF1E /* RNSVGFontData.m in Sources */, 1023B48D1D3DDCCE0051496D /* RNSVGDefsManager.m in Sources */, - 9494C53A1F4C44DD00D5BCFD /* FontVariantLigatures.m in Sources */, - 9494C5481F4C44DD00D5BCFD /* TextPathSpacing.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -674,13 +599,11 @@ A361E7711EB0C33D00646005 /* RNSVGCircleManager.m in Sources */, A361E7721EB0C33D00646005 /* RNSVGLinearGradient.m in Sources */, A361E7731EB0C33D00646005 /* RNSVGPercentageConverter.m in Sources */, - 9494C53F1F4C44DD00D5BCFD /* TextDecoration.m in Sources */, A361E7751EB0C33D00646005 /* RNSVGEllipse.m in Sources */, A361E7761EB0C33D00646005 /* RNSVGPath.m in Sources */, A361E7771EB0C33D00646005 /* RNSVGTextPath.m in Sources */, A361E7781EB0C33D00646005 /* RNSVGUse.m in Sources */, A361E7791EB0C33D00646005 /* RNSVGLinearGradientManager.m in Sources */, - 9494C5061F4B5BE800D5BCFD /* FontWeight.m in Sources */, A361E77A1EB0C33D00646005 /* RNSVGText.m in Sources */, A361E77B1EB0C33D00646005 /* RNSVGRectManager.m in Sources */, A361E77C1EB0C33D00646005 /* RNSVGRenderable.m in Sources */, @@ -689,31 +612,18 @@ A361E77F1EB0C33D00646005 /* RNSVGPainter.m in Sources */, A361E7801EB0C33D00646005 /* RNSVGNode.m in Sources */, A361E7811EB0C33D00646005 /* RNSVGClipPath.m in Sources */, - 9494C5081F4B5BE800D5BCFD /* PropHelper.m in Sources */, A361E7821EB0C33D00646005 /* RNSVGSvgViewManager.m in Sources */, - 9494C5411F4C44DD00D5BCFD /* TextLengthAdjust.m in Sources */, - 9494C5261F4B605F00D5BCFD /* GlyphContext.m in Sources */, A361E7831EB0C33D00646005 /* RNSVGSolidColorBrush.m in Sources */, - 9494C5391F4C44DD00D5BCFD /* FontStyle.m in Sources */, A361E7841EB0C33D00646005 /* RNSVGPathManager.m in Sources */, A361E7861EB0C33D00646005 /* RNSVGRenderableManager.m in Sources */, - 2DE5BD1C201C5CC1008DC1FE /* BezierElement.m in Sources */, A361E7871EB0C33D00646005 /* RNSVGRadialGradient.m in Sources */, - 945A8AF91F4CE3E8004BBF6B /* AlignmentBaseline.m in Sources */, A361E7881EB0C33D00646005 /* RNSVGRadialGradientManager.m in Sources */, A361E7891EB0C33D00646005 /* RNSVGImageManager.m in Sources */, A361E78A1EB0C33D00646005 /* RNSVGNodeManager.m in Sources */, A361E78B1EB0C33D00646005 /* RNSVGSymbol.m in Sources */, - 9494C5431F4C44DD00D5BCFD /* TextPathMethod.m in Sources */, A361E78C1EB0C33D00646005 /* RNSVGDefs.m in Sources */, - 9494C53B1F4C44DD00D5BCFD /* FontVariantLigatures.m in Sources */, - 9494C5001F4B5BE800D5BCFD /* FontData.m in Sources */, - 9494C5491F4C44DD00D5BCFD /* TextPathSpacing.m in Sources */, A361E78D1EB0C33D00646005 /* RNSVGLineManager.m in Sources */, - 9494C53D1F4C44DD00D5BCFD /* TextAnchor.m in Sources */, - 9494C5471F4C44DD00D5BCFD /* TextPathSide.m in Sources */, A361E78E1EB0C33D00646005 /* RNSVGCircle.m in Sources */, - 9494C5451F4C44DD00D5BCFD /* TextPathMidLine.m in Sources */, A361E78F1EB0C33D00646005 /* RNSVGEllipseManager.m in Sources */, A361E7901EB0C33D00646005 /* RCTConvert+RNSVG.m in Sources */, A361E7911EB0C33D00646005 /* RNSVGBrush.m in Sources */, diff --git a/ios/RNSVGNode.h b/ios/RNSVGNode.h index fdae8169..7acf495d 100644 --- a/ios/RNSVGNode.h +++ b/ios/RNSVGNode.h @@ -24,7 +24,7 @@ Provide enough digits for the 128-bit IEEE quad (36 significant digits). */ extern CGFloat const M_SQRT1_2l; -extern CGFloat const DEFAULT_FONT_SIZE; +extern CGFloat const RNSVG_DEFAULT_FONT_SIZE; @property (nonatomic, strong) NSString *name; @property (nonatomic, assign) CGFloat opacity; diff --git a/ios/RNSVGNode.m b/ios/RNSVGNode.m index a9679be0..564e6b27 100644 --- a/ios/RNSVGNode.m +++ b/ios/RNSVGNode.m @@ -10,19 +10,19 @@ #import "RNSVGContainer.h" #import "RNSVGClipPath.h" #import "RNSVGGroup.h" -#import "GlyphContext.h" +#import "RNSVGGlyphContext.h" @implementation RNSVGNode { RNSVGGroup *_textRoot; - GlyphContext *glyphContext; + RNSVGGlyphContext *glyphContext; BOOL _transparent; CGPathRef _cachedClipPath; RNSVGSvgView *_svgView; } CGFloat const M_SQRT1_2l = 0.707106781186547524400844362104849039; -CGFloat const DEFAULT_FONT_SIZE = 12; +CGFloat const RNSVG_DEFAULT_FONT_SIZE = 12; - (instancetype)init { @@ -93,7 +93,7 @@ CGFloat const DEFAULT_FONT_SIZE = 12; { RNSVGGroup* root = [self getTextRoot]; if (root == nil) { - return DEFAULT_FONT_SIZE; + return RNSVG_DEFAULT_FONT_SIZE; } if (glyphContext == nil) { @@ -240,20 +240,20 @@ CGFloat const DEFAULT_FONT_SIZE = 12; - (CGFloat)relativeOnWidth:(NSString *)length { - return [PropHelper fromRelativeWithNSString:length - relative:[self getContextWidth] - offset:0 - scale:1 - fontSize:[self getFontSizeFromContext]]; + return [RNSVGPropHelper fromRelativeWithNSString:length + relative:[self getContextWidth] + offset:0 + scale:1 + fontSize:[self getFontSizeFromContext]]; } - (CGFloat)relativeOnHeight:(NSString *)length { - return [PropHelper fromRelativeWithNSString:length - relative:[self getContextHeight] - offset:0 - scale:1 - fontSize:[self getFontSizeFromContext]]; + return [RNSVGPropHelper fromRelativeWithNSString:length + relative:[self getContextHeight] + offset:0 + scale:1 + fontSize:[self getFontSizeFromContext]]; } - (CGFloat)relativeOnOther:(NSString *)length @@ -263,17 +263,17 @@ CGFloat const DEFAULT_FONT_SIZE = 12; CGFloat powX = width * width; CGFloat powY = height * height; CGFloat r = sqrt(powX + powY) * M_SQRT1_2l; - return [PropHelper fromRelativeWithNSString:length - relative:r - offset:0 - scale:1 - fontSize:[self getFontSizeFromContext]]; + return [RNSVGPropHelper fromRelativeWithNSString:length + relative:r + offset:0 + scale:1 + fontSize:[self getFontSizeFromContext]]; } - (CGFloat)getContextWidth { RNSVGGroup * root = [self getTextRoot]; - GlyphContext * gc = [root getGlyphContext]; + RNSVGGlyphContext * gc = [root getGlyphContext]; if (root == nil || gc == nil) { return CGRectGetWidth([[self getSvgView] getContextBounds]); } else { @@ -284,7 +284,7 @@ CGFloat const DEFAULT_FONT_SIZE = 12; - (CGFloat)getContextHeight { RNSVGGroup * root = [self getTextRoot]; - GlyphContext * gc = [root getGlyphContext]; + RNSVGGlyphContext * gc = [root getGlyphContext]; if (root == nil || gc == nil) { return CGRectGetHeight([[self getSvgView] getContextBounds]); } else { diff --git a/ios/Text/AlignmentBaseline.h b/ios/Text/AlignmentBaseline.h deleted file mode 100644 index f3e8f0e4..00000000 --- a/ios/Text/AlignmentBaseline.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef AlignmentBaseline_h -#define AlignmentBaseline_h - -#import - -typedef NS_ENUM(NSInteger, AlignmentBaseline) { - AlignmentBaselineBaseline, - AlignmentBaselineTextBottom, - AlignmentBaselineAlphabetic, - AlignmentBaselineIdeographic, - AlignmentBaselineMiddle, - AlignmentBaselineCentral, - AlignmentBaselineMathematical, - AlignmentBaselineTextTop, - AlignmentBaselineBottom, - AlignmentBaselineCenter, - AlignmentBaselineTop, - /* - SVG implementations may support the following aliases in order to support legacy content: - - text-before-edge = text-top - text-after-edge = text-bottom - */ - AlignmentBaselineTextBeforeEdge, - AlignmentBaselineTextAfterEdge, - // SVG 1.1 - AlignmentBaselineBeforeEdge, - AlignmentBaselineAfterEdge, - AlignmentBaselineHanging, - AlignmentBaselineDEFAULT = AlignmentBaselineBaseline -}; - -static NSString* const AlignmentBaselineStrings[] = { - @"baseline", - @"text-bottom", - @"alphabetic", - @"ideographic", - @"middle", - @"central", - @"mathematical", - @"text-top", - @"bottom", - @"center", - @"top", - @"text-before-edge", - @"text-after-edge", - @"before-edge", - @"after-edge", - @"hanging", - @"central", - @"mathematical", - @"text-top", - @"bottom", - @"center", - @"top", - nil -}; - -NSString* AlignmentBaselineToString( enum AlignmentBaseline fw ); - -enum AlignmentBaseline AlignmentBaselineFromString( NSString* s ); - -#endif /* AlignmentBaseline_h */ diff --git a/ios/Text/AlignmentBaseline.m b/ios/Text/AlignmentBaseline.m deleted file mode 100644 index b1985c63..00000000 --- a/ios/Text/AlignmentBaseline.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "AlignmentBaseline.h" - -NSString* AlignmentBaselineToString( enum AlignmentBaseline fw ) -{ - return AlignmentBaselineStrings[fw]; -} - -enum AlignmentBaseline AlignmentBaselineFromString( NSString* s ) -{ - const NSUInteger l = sizeof(AlignmentBaselineStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:AlignmentBaselineStrings[i]]) { - return i; - } - } - return AlignmentBaselineDEFAULT; -} diff --git a/ios/Text/FontStyle.h b/ios/Text/FontStyle.h deleted file mode 100644 index 1dd5c9bb..00000000 --- a/ios/Text/FontStyle.h +++ /dev/null @@ -1,19 +0,0 @@ -#import - -#ifndef FontStyle_h -#define FontStyle_h - -typedef NS_ENUM(NSInteger, FontStyle) { - FontStyleNormal, - FontStyleItalic, - FontStyleOblique, - FontStyleDEFAULT = FontStyleNormal, -}; - -static NSString* const FontStyleStrings[] = {@"normal", @"italic", @"oblique", nil}; - -NSString* FontStyleToString( enum FontStyle fw ); - -enum FontStyle FontStyleFromString( NSString* s ); - -#endif diff --git a/ios/Text/FontStyle.m b/ios/Text/FontStyle.m deleted file mode 100644 index a1c0a2b7..00000000 --- a/ios/Text/FontStyle.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "FontStyle.h" - -NSString* FontStyleToString( enum FontStyle fw ) -{ - return FontStyleStrings[fw]; -} - -enum FontStyle FontStyleFromString( NSString* s ) -{ - const NSUInteger l = sizeof(FontStyleStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:FontStyleStrings[i]]) { - return i; - } - } - return FontStyleDEFAULT; -} diff --git a/ios/Text/FontVariantLigatures.h b/ios/Text/FontVariantLigatures.h deleted file mode 100644 index 81206bba..00000000 --- a/ios/Text/FontVariantLigatures.h +++ /dev/null @@ -1,18 +0,0 @@ -#import - -#ifndef FontVariantLigatures_h -#define FontVariantLigatures_h - -typedef NS_ENUM(NSInteger, FontVariantLigatures) { - FontVariantLigaturesNormal, - FontVariantLigaturesNone, - FontVariantLigaturesDEFAULT = FontVariantLigaturesNormal, -}; - -static NSString* const FontVariantLigaturesStrings[] = {@"normal", @"none", nil}; - -NSString* FontVariantLigaturesToString( enum FontVariantLigatures fw ); - -enum FontVariantLigatures FontVariantLigaturesFromString( NSString* s ); - -#endif diff --git a/ios/Text/FontVariantLigatures.m b/ios/Text/FontVariantLigatures.m deleted file mode 100644 index 73c0ac8b..00000000 --- a/ios/Text/FontVariantLigatures.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "FontVariantLigatures.h" - -NSString* FontVariantLigaturesToString( enum FontVariantLigatures fw ) -{ - return FontVariantLigaturesStrings[fw]; -} - -enum FontVariantLigatures FontVariantLigaturesFromString( NSString* s ) -{ - const NSUInteger l = sizeof(FontVariantLigaturesStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:FontVariantLigaturesStrings[i]]) { - return i; - } - } - return FontVariantLigaturesDEFAULT; -} diff --git a/ios/Text/FontWeight.h b/ios/Text/FontWeight.h deleted file mode 100644 index 2750fd0f..00000000 --- a/ios/Text/FontWeight.h +++ /dev/null @@ -1,30 +0,0 @@ -#import - -#ifndef FontWeight_h -#define FontWeight_h - -typedef NS_ENUM(NSInteger, FontWeight) { - FontWeightNormal, - FontWeightBold, - FontWeightBolder, - FontWeightLighter, - FontWeight100, - FontWeight200, - FontWeight300, - FontWeight400, - FontWeight500, - FontWeight600, - FontWeight700, - FontWeight800, - FontWeight900, - FontWeightDEFAULT = FontWeightNormal, -}; - -static NSString* const FontWeightStrings[] = {@"Normal", @"Bold", @"Bolder", @"Lighter", @"100", @"200", @"300", @"400", @"500", @"600", @"700", @"800", @"900", nil}; - - -NSString* FontWeightToString( enum FontWeight fw ); - -enum FontWeight FontWeightFromString( NSString* s ); - -#endif diff --git a/ios/Text/FontWeight.m b/ios/Text/FontWeight.m deleted file mode 100644 index 3bf1d5a5..00000000 --- a/ios/Text/FontWeight.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "FontWeight.h" - -NSString* FontWeightToString( enum FontWeight fw ) -{ - return FontWeightStrings[fw]; -} - -enum FontWeight FontWeightFromString( NSString* s ) -{ - const NSUInteger l = sizeof(FontWeightStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([[s capitalizedString] isEqualToString:FontWeightStrings[i]]) { - return i; - } - } - return FontWeightDEFAULT; -} diff --git a/ios/Text/FontData.h b/ios/Text/RNSVGFontData.h similarity index 56% rename from ios/Text/FontData.h rename to ios/Text/RNSVGFontData.h index 4658026b..67be3217 100644 --- a/ios/Text/FontData.h +++ b/ios/Text/RNSVGFontData.h @@ -1,25 +1,21 @@ #import #import -#import "FontStyle.h" -#import "FontVariantLigatures.h" -#import "FontWeight.h" -#import "PropHelper.h" -#import "TextAnchor.h" -#import "TextDecoration.h" +#import "RNSVGTextProperties.h" +#import "RNSVGPropHelper.h" -@interface FontData : NSObject { +@interface RNSVGFontData : NSObject { @public double fontSize; NSString * fontSize_; NSString *fontFamily; - enum FontStyle fontStyle; + enum RNSVGFontStyle fontStyle; NSDictionary * fontData; - enum FontWeight fontWeight; + enum RNSVGFontWeight fontWeight; NSString *fontFeatureSettings; - enum FontVariantLigatures fontVariantLigatures; - enum TextAnchor textAnchor; - enum TextDecoration textDecoration; + enum RNSVGFontVariantLigatures fontVariantLigatures; + enum RNSVGTextAnchor textAnchor; + enum RNSVGTextDecoration textDecoration; double kerning; double wordSpacing; double letterSpacing; @@ -33,9 +29,9 @@ fontSize:(double)fontSize; + (instancetype)initWithNSDictionary:(NSDictionary *)font - parent:(FontData *)parent + parent:(RNSVGFontData *)parent scale:(double)scale; @end -#define FontData_DEFAULT_FONT_SIZE 12.0 +#define RNSVGFontData_DEFAULT_FONT_SIZE 12.0 diff --git a/ios/Text/FontData.m b/ios/Text/RNSVGFontData.m similarity index 53% rename from ios/Text/FontData.m rename to ios/Text/RNSVGFontData.m index e1c2b266..715d1eb8 100644 --- a/ios/Text/FontData.m +++ b/ios/Text/RNSVGFontData.m @@ -1,15 +1,11 @@ -#import "FontData.h" -#import "FontStyle.h" -#import "FontVariantLigatures.h" -#import "FontWeight.h" -#import "PropHelper.h" -#import "TextAnchor.h" -#import "TextDecoration.h" +#import "RNSVGFontData.h" +#import "RNSVGPropHelper.h" +#import "RNSVGTextProperties.h" #import "RNSVGNode.h" -#define DEFAULT_KERNING 0.0 -#define DEFAULT_WORD_SPACING 0.0 -#define DEFAULT_LETTER_SPACING 0.0 +#define RNSVG_DEFAULT_KERNING 0.0 +#define RNSVG_DEFAULT_WORD_SPACING 0.0 +#define RNSVG_DEFAULT_LETTER_SPACING 0.0 static NSString *KERNING = @"kerning"; static NSString *FONT_SIZE = @"fontSize"; static NSString *FONT_DATA = @"fontData"; @@ -23,53 +19,53 @@ static NSString *TEXT_DECORATION = @"textDecoration"; static NSString *FONT_FEATURE_SETTINGS = @"fontFeatureSettings"; static NSString *FONT_VARIANT_LIGATURES = @"fontVariantLigatures"; -FontData *FontData_Defaults; +RNSVGFontData *RNSVGFontData_Defaults; -@implementation FontData +@implementation RNSVGFontData + (instancetype)Defaults { - if (!FontData_Defaults) { - FontData *self = [FontData alloc]; + if (!RNSVGFontData_Defaults) { + RNSVGFontData *self = [RNSVGFontData alloc]; self->fontData = nil; self->fontFamily = @""; - self->fontStyle = FontStyleNormal; - self->fontWeight = FontWeightNormal; + self->fontStyle = RNSVGFontStyleNormal; + self->fontWeight = RNSVGFontWeightNormal; self->fontFeatureSettings = @""; - self->fontVariantLigatures = FontVariantLigaturesNormal; - self->textAnchor = TextAnchorStart; - self->textDecoration = TextDecorationNone; + self->fontVariantLigatures = RNSVGFontVariantLigaturesNormal; + self->textAnchor = RNSVGTextAnchorStart; + self->textDecoration = RNSVGTextDecorationNone; self->manualKerning = false; - self->kerning = DEFAULT_KERNING; - self->fontSize = DEFAULT_FONT_SIZE; - self->wordSpacing = DEFAULT_WORD_SPACING; - self->letterSpacing = DEFAULT_LETTER_SPACING; - FontData_Defaults = self; + self->kerning = RNSVG_DEFAULT_KERNING; + self->fontSize = RNSVG_DEFAULT_FONT_SIZE; + self->wordSpacing = RNSVG_DEFAULT_WORD_SPACING; + self->letterSpacing = RNSVG_DEFAULT_LETTER_SPACING; + RNSVGFontData_Defaults = self; } - return FontData_Defaults; + return RNSVGFontData_Defaults; } + (double)toAbsoluteWithNSString:(NSString *)string scale:(double)scale fontSize:(double)fontSize { - return [PropHelper fromRelativeWithNSString:string - relative:0 - offset:0 - scale:scale - fontSize:fontSize]; + return [RNSVGPropHelper fromRelativeWithNSString:string + relative:0 + offset:0 + scale:scale + fontSize:fontSize]; } + (instancetype)initWithNSDictionary:(NSDictionary *)font - parent:(FontData *)parent + parent:(RNSVGFontData *)parent scale:(double)scale { - FontData *data = [FontData alloc]; + RNSVGFontData *data = [RNSVGFontData alloc]; double parentFontSize = parent->fontSize; if ([font objectForKey:FONT_SIZE]) { NSString *string = [font objectForKey:FONT_SIZE]; - data->fontSize = [PropHelper fromRelativeWithNSString:string - relative:parentFontSize - offset:0 - scale:scale - fontSize:parentFontSize]; + data->fontSize = [RNSVGPropHelper fromRelativeWithNSString:string + relative:parentFontSize + offset:0 + scale:scale + fontSize:parentFontSize]; } else { data->fontSize = parentFontSize; @@ -77,28 +73,28 @@ FontData *FontData_Defaults; data->fontData = [font objectForKey:FONT_DATA] ? [font objectForKey:FONT_DATA] : parent->fontData; data->fontFamily = [font objectForKey:FONT_FAMILY] ? [font objectForKey:FONT_FAMILY] : parent->fontFamily; NSString* style = [font objectForKey:FONT_STYLE]; - data->fontStyle = style ? FontStyleFromString(style) : parent->fontStyle; + data->fontStyle = style ? RNSVGFontStyleFromString(style) : parent->fontStyle; NSString* weight = [font objectForKey:FONT_WEIGHT]; - data->fontWeight = weight ? FontWeightFromString(weight) : parent->fontWeight; + data->fontWeight = weight ? RNSVGFontWeightFromString(weight) : parent->fontWeight; NSString* feature = [font objectForKey:FONT_FEATURE_SETTINGS]; data->fontFeatureSettings = feature ? [font objectForKey:FONT_FEATURE_SETTINGS] : parent->fontFeatureSettings; NSString* variant = [font objectForKey:FONT_VARIANT_LIGATURES]; - data->fontVariantLigatures = variant ? FontVariantLigaturesFromString(variant) : parent->fontVariantLigatures; + data->fontVariantLigatures = variant ? RNSVGFontVariantLigaturesFromString(variant) : parent->fontVariantLigatures; NSString* anchor = [font objectForKey:TEXT_ANCHOR]; - data->textAnchor = anchor ? TextAnchorFromString(anchor) : parent->textAnchor; + data->textAnchor = anchor ? RNSVGTextAnchorFromString(anchor) : parent->textAnchor; NSString* decoration = [font objectForKey:TEXT_DECORATION]; - data->textDecoration = decoration ? TextDecorationFromString(decoration) : parent->textDecoration; + data->textDecoration = decoration ? RNSVGTextDecorationFromString(decoration) : parent->textDecoration; NSString* kerning = [font objectForKey:KERNING]; data->manualKerning = (kerning || parent->manualKerning ); - data->kerning = kerning ? [FontData toAbsoluteWithNSString:kerning + data->kerning = kerning ? [RNSVGFontData toAbsoluteWithNSString:kerning scale:scale fontSize:data->fontSize ] : parent->kerning; NSString* wordSpacing = [font objectForKey:WORD_SPACING]; - data->wordSpacing = wordSpacing ? [FontData toAbsoluteWithNSString:wordSpacing + data->wordSpacing = wordSpacing ? [RNSVGFontData toAbsoluteWithNSString:wordSpacing scale:scale fontSize:data->fontSize ] : parent->wordSpacing; NSString* letterSpacing = [font objectForKey:LETTER_SPACING]; - data->letterSpacing = letterSpacing ? [FontData toAbsoluteWithNSString:letterSpacing + data->letterSpacing = letterSpacing ? [RNSVGFontData toAbsoluteWithNSString:letterSpacing scale:scale fontSize:data->fontSize ] : parent->letterSpacing; return data; diff --git a/ios/Text/GlyphContext.h b/ios/Text/RNSVGGlyphContext.h similarity index 88% rename from ios/Text/GlyphContext.h rename to ios/Text/RNSVGGlyphContext.h index 912c400c..b99718c5 100644 --- a/ios/Text/GlyphContext.h +++ b/ios/Text/RNSVGGlyphContext.h @@ -1,12 +1,12 @@ #import #import -#import "FontData.h" +#import "RNSVGFontData.h" @class RNSVGText; @class RNSVGGroup; -@class GlyphContext; +@class RNSVGGlyphContext; -@interface GlyphContext : NSObject +@interface RNSVGGlyphContext : NSObject - (CTFontRef)getGlyphFont; @@ -14,7 +14,7 @@ width:(float)width height:(float)height; -- (FontData *)getFont; +- (RNSVGFontData *)getFont; - (double)getFontSize; diff --git a/ios/Text/GlyphContext.m b/ios/Text/RNSVGGlyphContext.m similarity index 85% rename from ios/Text/GlyphContext.m rename to ios/Text/RNSVGGlyphContext.m index 1fba6917..8dc21486 100644 --- a/ios/Text/GlyphContext.m +++ b/ios/Text/RNSVGGlyphContext.m @@ -1,12 +1,12 @@ -#import "GlyphContext.h" +#import "RNSVGGlyphContext.h" #import #import "RNSVGNode.h" -#import "PropHelper.h" -#import "FontData.h" +#import "RNSVGPropHelper.h" +#import "RNSVGFontData.h" #import "RNSVGText.h" // https://www.w3.org/TR/SVG/text.html#TSpanElement -@interface GlyphContext () { +@interface RNSVGGlyphContext () { @public // Current stack (one per node push/pop) NSMutableArray *mFontContext_; @@ -34,7 +34,7 @@ // Calculated on push context, percentage and em length depends on parent font size double mFontSize_; - FontData *topFont_; + RNSVGFontData *topFont_; // Current accumulated values // https://www.w3.org/TR/SVG/types.html#DataTypeCoordinate @@ -106,7 +106,7 @@ font:(NSDictionary *)font; @end -@implementation GlyphContext +@implementation RNSVGGlyphContext - (CTFontRef)getGlyphFont @@ -114,8 +114,8 @@ NSString *fontFamily = topFont_->fontFamily; NSNumber * fontSize = [NSNumber numberWithDouble:topFont_->fontSize]; - NSString * fontWeight = [FontWeightToString(topFont_->fontWeight) lowercaseString]; - NSString * fontStyle = FontStyleStrings[topFont_->fontStyle]; + NSString * fontWeight = [RNSVGFontWeightToString(topFont_->fontWeight) lowercaseString]; + NSString * fontStyle = RNSVGFontStyleStrings[topFont_->fontStyle]; BOOL fontFamilyFound = NO; NSArray *supportedFontFamilyNames = [UIFont familyNames]; @@ -141,7 +141,7 @@ scaleMultiplier:1.0]; } -void pushIndices(GlyphContext *self) { +void pushIndices(RNSVGGlyphContext *self) { [self->mXsIndices_ addObject:[NSNumber numberWithLong:self->mXsIndex_]]; [self->mYsIndices_ addObject:[NSNumber numberWithLong:self->mYsIndex_]]; [self->mDXsIndices_ addObject:[NSNumber numberWithLong:self->mDXsIndex_]]; @@ -171,8 +171,8 @@ void pushIndices(GlyphContext *self) { self->mDYsIndices_ = [[NSMutableArray alloc]init]; self->mRsIndices_ = [[NSMutableArray alloc]init]; - self->mFontSize_ = FontData_DEFAULT_FONT_SIZE; - self->topFont_ = [FontData Defaults]; + self->mFontSize_ = RNSVGFontData_DEFAULT_FONT_SIZE; + self->topFont_ = [RNSVGFontData Defaults]; self->mXs_ = [[NSArray alloc]init]; self->mYs_ = [[NSArray alloc]init]; @@ -207,18 +207,18 @@ void pushIndices(GlyphContext *self) { return self; } -- (FontData *)getFont { +- (RNSVGFontData *)getFont { return topFont_; } -FontData *getTopOrParentFont(GlyphContext *self, RNSVGGroup* child) { +RNSVGFontData *getTopOrParentFont(RNSVGGlyphContext *self, RNSVGGroup* child) { if (self->mTop_ > 0) { return self->topFont_; } else { RNSVGGroup* parentRoot = [child getParentTextRoot]; - FontData* Defaults = [FontData Defaults]; + RNSVGFontData* Defaults = [RNSVGFontData Defaults]; while (parentRoot != nil) { - FontData *map = [[parentRoot getGlyphContext] getFont]; + RNSVGFontData *map = [[parentRoot getGlyphContext] getFont]; if (map != Defaults) { return map; } @@ -228,16 +228,16 @@ FontData *getTopOrParentFont(GlyphContext *self, RNSVGGroup* child) { } } -void pushNodeAndFont(GlyphContext *self, RNSVGGroup* node, NSDictionary* font) { - FontData *parent = getTopOrParentFont(self, node); +void pushNodeAndFont(RNSVGGlyphContext *self, RNSVGGroup* node, NSDictionary* font) { + RNSVGFontData *parent = getTopOrParentFont(self, node); self->mTop_++; if (font == nil) { [self->mFontContext_ addObject:parent]; return; } - FontData *data = [FontData initWithNSDictionary:font - parent:parent - scale:self->mScale_]; + RNSVGFontData *data = [RNSVGFontData initWithNSDictionary:font + parent:parent + scale:self->mScale_]; self->mFontSize_ = data->fontSize; [self->mFontContext_ addObject:data]; self->topFont_ = data; @@ -395,11 +395,11 @@ void incrementIndices(NSMutableArray *indices, long topIndex) { mDX_ = 0; mXIndex_ = nextIndex; NSString *string = [mXs_ objectAtIndex:nextIndex]; - mX_ = [PropHelper fromRelativeWithNSString:string - relative:mWidth_ - offset:0 - scale:mScale_ - fontSize:mFontSize_]; + mX_ = [RNSVGPropHelper fromRelativeWithNSString:string + relative:mWidth_ + offset:0 + scale:mScale_ + fontSize:mFontSize_]; } mX_ += advance; return mX_; @@ -412,11 +412,11 @@ void incrementIndices(NSMutableArray *indices, long topIndex) { mDY_ = 0; mYIndex_ = nextIndex; NSString *string = [mYs_ objectAtIndex:nextIndex]; - mY_ = [PropHelper fromRelativeWithNSString:string - relative:mHeight_ - offset:0 - scale:mScale_ - fontSize:mFontSize_]; + mY_ = [RNSVGPropHelper fromRelativeWithNSString:string + relative:mHeight_ + offset:0 + scale:mScale_ + fontSize:mFontSize_]; } return mY_; } @@ -427,11 +427,11 @@ void incrementIndices(NSMutableArray *indices, long topIndex) { if (nextIndex < [mDXs_ count]) { mDXIndex_ = nextIndex; NSString *string = [mDXs_ objectAtIndex:nextIndex]; - double val = [PropHelper fromRelativeWithNSString:string - relative:mWidth_ - offset:0 - scale:mScale_ - fontSize:mFontSize_]; + double val = [RNSVGPropHelper fromRelativeWithNSString:string + relative:mWidth_ + offset:0 + scale:mScale_ + fontSize:mFontSize_]; mDX_ += val; } return mDX_; @@ -443,11 +443,11 @@ void incrementIndices(NSMutableArray *indices, long topIndex) { if (nextIndex < [mDYs_ count]) { mDYIndex_ = nextIndex; NSString *string = [mDYs_ objectAtIndex:nextIndex]; - double val = [PropHelper fromRelativeWithNSString:string - relative:mHeight_ - offset:0 - scale:mScale_ - fontSize:mFontSize_]; + double val = [RNSVGPropHelper fromRelativeWithNSString:string + relative:mHeight_ + offset:0 + scale:mScale_ + fontSize:mFontSize_]; mDY_ += val; } return mDY_; diff --git a/ios/Text/PropHelper.h b/ios/Text/RNSVGPropHelper.h similarity index 79% rename from ios/Text/PropHelper.h rename to ios/Text/RNSVGPropHelper.h index 1dfd0708..6d29a165 100644 --- a/ios/Text/PropHelper.h +++ b/ios/Text/RNSVGPropHelper.h @@ -1,10 +1,10 @@ #import #import -#ifndef PropHelper_h -#define PropHelper_h +#ifndef RNSVGPropHelper_h +#define RNSVGPropHelper_h -@interface PropHelper : NSObject +@interface RNSVGPropHelper : NSObject + (double) fromRelativeWithNSString:(NSString *)length relative:(double)relative diff --git a/ios/Text/PropHelper.m b/ios/Text/RNSVGPropHelper.m similarity index 96% rename from ios/Text/PropHelper.m rename to ios/Text/RNSVGPropHelper.m index 94103955..f2ac1253 100644 --- a/ios/Text/PropHelper.m +++ b/ios/Text/RNSVGPropHelper.m @@ -1,5 +1,5 @@ -#include "PropHelper.h" -@implementation PropHelper +#include "RNSVGPropHelper.h" +@implementation RNSVGPropHelper + (double)fromRelativeWithNSString:(NSString *)length relative:(double)relative diff --git a/ios/Text/RNSVGTSpan.h b/ios/Text/RNSVGTSpan.h index 9f909070..9b7509fc 100644 --- a/ios/Text/RNSVGTSpan.h +++ b/ios/Text/RNSVGTSpan.h @@ -9,12 +9,6 @@ #import #import #import "RNSVGText.h" -#import "TextPathSide.h" -#import "TextPathMethod.h" -#import "TextPathMidLine.h" -#import "TextPathSpacing.h" -#import "TextLengthAdjust.h" -#import "AlignmentBaseline.h" @interface RNSVGTSpan : RNSVGText diff --git a/ios/Text/RNSVGTSpan.m b/ios/Text/RNSVGTSpan.m index 3499c4e0..7f23c043 100644 --- a/ios/Text/RNSVGTSpan.m +++ b/ios/Text/RNSVGTSpan.m @@ -8,7 +8,8 @@ #import "RNSVGTSpan.h" #import "RNSVGText.h" #import "RNSVGTextPath.h" -#import "FontData.h" +#import "RNSVGTextProperties.h" +#import "RNSVGFontData.h" NSCharacterSet *separators = nil; static double radToDeg = 180 / M_PI; @@ -95,8 +96,8 @@ static double radToDeg = 180 / M_PI; // Create a dictionary for this font CTFontRef fontRef = [self getFontFromContext]; CGMutablePathRef path = CGPathCreateMutable(); - GlyphContext* gc = [[self getTextRoot] getGlyphContext]; - FontData* font = [gc getFont]; + RNSVGGlyphContext* gc = [[self getTextRoot] getGlyphContext]; + RNSVGFontData* font = [gc getFont]; NSUInteger n = str.length; /* * @@ -169,7 +170,7 @@ static double radToDeg = 180 / M_PI; user agents should not apply optional ligatures. https://www.w3.org/TR/css-text-3/#letter-spacing-property */ - bool allowOptionalLigatures = letterSpacing == 0 && font->fontVariantLigatures == FontVariantLigaturesNormal; + bool allowOptionalLigatures = letterSpacing == 0 && font->fontVariantLigatures == RNSVGFontVariantLigaturesNormal; /* For OpenType fonts, discretionary ligatures include those enabled by @@ -268,7 +269,7 @@ static double radToDeg = 180 / M_PI; is adjusted to take into account various horizontal alignment text properties and attributes, such as a ‘dx’ attribute value on a ‘tspan’ element. */ - enum TextAnchor textAnchor = font->textAnchor; + enum RNSVGTextAnchor textAnchor = font->textAnchor; CGRect textBounds = CTLineGetBoundsWithOptions(line, 0); double textMeasure = CGRectGetWidth(textBounds); double offset = getTextAnchorOffset(textAnchor, textMeasure); @@ -281,7 +282,7 @@ static double radToDeg = 180 / M_PI; double fontSize = [gc getFontSize]; bool sharpMidLine = false; if (hasTextPath) { - sharpMidLine = TextPathMidLineFromString([textPath midLine]) == TextPathMidLineSharp; + sharpMidLine = RNSVGTextPathMidLineFromString([textPath midLine]) == RNSVGTextPathMidLineSharp; /* Name side @@ -302,7 +303,7 @@ static double radToDeg = 180 / M_PI; Adding 'side' was resolved at the Sydney (2015) meeting. */ - side = TextPathSideFromString([textPath side]) == TextPathSideRight ? -1 : 1; + side = RNSVGTextPathSideFromString([textPath side]) == RNSVGTextPathSideRight ? -1 : 1; /* Name startOffset @@ -341,20 +342,20 @@ static double radToDeg = 180 / M_PI; a point on the path equal distance in both directions from the initial position on the path is reached. */ - double absoluteStartOffset = [PropHelper fromRelativeWithNSString:textPath.startOffset - relative:_pathLength - offset:0 - scale:1 - fontSize:fontSize]; + double absoluteStartOffset = [RNSVGPropHelper fromRelativeWithNSString:textPath.startOffset + relative:_pathLength + offset:0 + scale:1 + fontSize:fontSize]; offset += absoluteStartOffset; if (isClosed) { double halfPathDistance = _pathLength / 2; - startOfRendering = absoluteStartOffset + (textAnchor == TextAnchorMiddle ? -halfPathDistance : 0); + startOfRendering = absoluteStartOffset + (textAnchor == RNSVGTextAnchorMiddle ? -halfPathDistance : 0); endOfRendering = startOfRendering + _pathLength; } /* - TextPathSpacing spacing = textPath.getSpacing(); - if (spacing == TextPathSpacing.auto) { + RNSVGTextPathSpacing spacing = textPath.getSpacing(); + if (spacing == RNSVGTextPathSpacing.auto) { // Hmm, what to do here? // https://svgwg.org/svg2-draft/text.html#TextPathElementSpacingAttribute } @@ -438,13 +439,13 @@ static double radToDeg = 180 / M_PI; */ double scaleSpacingAndGlyphs = 1; NSString *mTextLength = [self textLength]; - enum TextLengthAdjust mLengthAdjust = TextLengthAdjustFromString([self lengthAdjust]); + enum RNSVGTextLengthAdjust mLengthAdjust = RNSVGTextLengthAdjustFromString([self lengthAdjust]); if (mTextLength != nil) { - double author = [PropHelper fromRelativeWithNSString:mTextLength - relative:[gc getWidth] - offset:0 - scale:1 - fontSize:fontSize]; + double author = [RNSVGPropHelper fromRelativeWithNSString:mTextLength + relative:[gc getWidth] + offset:0 + scale:1 + fontSize:fontSize]; if (author < 0) { NSException *e = [NSException exceptionWithName:@"NegativeTextLength" @@ -454,11 +455,11 @@ static double radToDeg = 180 / M_PI; } switch (mLengthAdjust) { default: - case TextLengthAdjustSpacing: + case RNSVGTextLengthAdjustSpacing: // TODO account for ligatures letterSpacing += (author - textMeasure) / (n - 1); break; - case TextLengthAdjustSpacingAndGlyphs: + case RNSVGTextLengthAdjustSpacingAndGlyphs: scaleSpacingAndGlyphs = author / textMeasure; break; } @@ -509,54 +510,54 @@ static double radToDeg = 180 / M_PI; double totalHeight = top + bottom; double baselineShift = 0; NSString *baselineShiftString = [self getBaselineShift]; - enum AlignmentBaseline baseline = AlignmentBaselineFromString([self getAlignmentBaseline]); - if (baseline != AlignmentBaselineBaseline) { + enum RNSVGAlignmentBaseline baseline = RNSVGAlignmentBaselineFromString([self getAlignmentBaseline]); + if (baseline != RNSVGAlignmentBaselineBaseline) { // TODO alignment-baseline, test / verify behavior // TODO get per glyph baselines from font baseline table, for high-precision alignment CGFloat xHeight = CTFontGetXHeight(fontRef); switch (baseline) { // https://wiki.apache.org/xmlgraphics-fop/LineLayout/AlignmentHandling default: - case AlignmentBaselineBaseline: + case RNSVGAlignmentBaselineBaseline: // Use the dominant baseline choice of the parent. // Match the box’s corresponding baseline to that of its parent. baselineShift = 0; break; - case AlignmentBaselineTextBottom: - case AlignmentBaselineAfterEdge: - case AlignmentBaselineTextAfterEdge: + case RNSVGAlignmentBaselineTextBottom: + case RNSVGAlignmentBaselineAfterEdge: + case RNSVGAlignmentBaselineTextAfterEdge: // Match the bottom of the box to the bottom of the parent’s content area. // text-after-edge = text-bottom // text-after-edge = descender depth baselineShift = -descenderDepth; break; - case AlignmentBaselineAlphabetic: + case RNSVGAlignmentBaselineAlphabetic: // Match the box’s alphabetic baseline to that of its parent. // alphabetic = 0 baselineShift = 0; break; - case AlignmentBaselineIdeographic: + case RNSVGAlignmentBaselineIdeographic: // Match the box’s ideographic character face under-side baseline to that of its parent. // ideographic = descender depth baselineShift = -descenderDepth; break; - case AlignmentBaselineMiddle: + case RNSVGAlignmentBaselineMiddle: // Align the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent. TODO // middle = x height / 2 baselineShift = xHeight / 2; break; - case AlignmentBaselineCentral: + case RNSVGAlignmentBaselineCentral: // Match the box’s central baseline to the central baseline of its parent. // central = (ascender height - descender depth) / 2 baselineShift = (ascenderHeight - descenderDepth) / 2; break; - case AlignmentBaselineMathematical: + case RNSVGAlignmentBaselineMathematical: // Match the box’s mathematical baseline to that of its parent. // Hanging and mathematical baselines // There are no obvious formulas to calculate the position of these baselines. @@ -565,30 +566,30 @@ static double radToDeg = 180 / M_PI; baselineShift = 0.5 * ascenderHeight; break; - case AlignmentBaselineHanging: + case RNSVGAlignmentBaselineHanging: baselineShift = 0.8 * ascenderHeight; break; - case AlignmentBaselineTextTop: - case AlignmentBaselineBeforeEdge: - case AlignmentBaselineTextBeforeEdge: + case RNSVGAlignmentBaselineTextTop: + case RNSVGAlignmentBaselineBeforeEdge: + case RNSVGAlignmentBaselineTextBeforeEdge: // Match the top of the box to the top of the parent’s content area. // text-before-edge = text-top // text-before-edge = ascender height baselineShift = ascenderHeight; break; - case AlignmentBaselineBottom: + case RNSVGAlignmentBaselineBottom: // Align the top of the aligned subtree with the top of the line box. baselineShift = bottom; break; - case AlignmentBaselineCenter: + case RNSVGAlignmentBaselineCenter: // Align the center of the aligned subtree with the center of the line box. baselineShift = totalHeight / 2; break; - case AlignmentBaselineTop: + case RNSVGAlignmentBaselineTop: // Align the bottom of the aligned subtree with the bottom of the line box. baselineShift = top; break; @@ -624,8 +625,8 @@ static double radToDeg = 180 / M_PI; */ if (baselineShiftString != nil && ![baselineShiftString isEqualToString:@""]) { switch (baseline) { - case AlignmentBaselineTop: - case AlignmentBaselineBottom: + case RNSVGAlignmentBaselineTop: + case RNSVGAlignmentBaselineBottom: break; default: @@ -651,12 +652,11 @@ static double radToDeg = 180 / M_PI; } } else if ([baselineShiftString isEqualToString:@"baseline"]) { } else { - baselineShift -= [PropHelper fromRelativeWithNSString:baselineShiftString - relative:fontSize - offset:0 - scale:1 - fontSize:fontSize]; - + baselineShift -= [RNSVGPropHelper fromRelativeWithNSString:baselineShiftString + relative:fontSize + offset:0 + scale:1 + fontSize:fontSize]; } break; } @@ -811,14 +811,14 @@ static double radToDeg = 180 / M_PI; return path; } -CGFloat getTextAnchorOffset(enum TextAnchor textAnchor, CGFloat width) +CGFloat getTextAnchorOffset(enum RNSVGTextAnchor textAnchor, CGFloat width) { switch (textAnchor) { - case TextAnchorStart: + case RNSVGTextAnchorStart: return 0; - case TextAnchorMiddle: + case RNSVGTextAnchorMiddle: return -width / 2; - case TextAnchorEnd: + case RNSVGTextAnchorEnd: return -width; } diff --git a/ios/Text/RNSVGText.h b/ios/Text/RNSVGText.h index 47dddf2e..457fe950 100644 --- a/ios/Text/RNSVGText.h +++ b/ios/Text/RNSVGText.h @@ -8,7 +8,6 @@ #import #import "RNSVGGroup.h" -#import "AlignmentBaseline.h" @interface RNSVGText : RNSVGGroup diff --git a/ios/Text/RNSVGText.m b/ios/Text/RNSVGText.m index c0a4ab64..28f665a9 100644 --- a/ios/Text/RNSVGText.m +++ b/ios/Text/RNSVGText.m @@ -10,12 +10,13 @@ #import "RNSVGTextPath.h" #import #import -#import "GlyphContext.h" +#import "RNSVGGlyphContext.h" +#import "RNSVGTextProperties.h" @implementation RNSVGText { RNSVGText *_textRoot; - GlyphContext *_glyphContext; + RNSVGGlyphContext *_glyphContext; } - (void)renderLayerTo:(CGContextRef)context @@ -36,8 +37,8 @@ - (void)setupGlyphContext:(CGContextRef)context { - _glyphContext = [[GlyphContext alloc] initWithScale:1 width:[self getContextWidth] - height:[self getContextHeight]]; + _glyphContext = [[RNSVGGlyphContext alloc] initWithScale:1 width:[self getContextWidth] + height:[self getContextHeight]]; } // release the cached CGPathRef for RNSVGTSpan @@ -109,7 +110,7 @@ parent = [parent superview]; } if (self.alignmentBaseline == nil) { - self.alignmentBaseline = AlignmentBaselineStrings[0]; + self.alignmentBaseline = RNSVGAlignmentBaselineStrings[0]; } return self.alignmentBaseline; } @@ -139,7 +140,7 @@ return self.baselineShift; } -- (GlyphContext *)getGlyphContext +- (RNSVGGlyphContext *)getGlyphContext { return _glyphContext; } diff --git a/ios/Text/RNSVGTextPath.m b/ios/Text/RNSVGTextPath.m index 81fd5df5..e33c76a9 100644 --- a/ios/Text/RNSVGTextPath.m +++ b/ios/Text/RNSVGTextPath.m @@ -8,7 +8,7 @@ #import "RNSVGTextPath.h" -#import "BezierElement.h" +#import "RNSVGBezierElement.h" /* Some Bezier logic from PerformanceBezier */ /* @@ -128,8 +128,8 @@ void addLine(CGPoint *last, const CGPoint *next, NSMutableArray *lines, CGFloat lineCount = 0; length = 0; - NSArray *elements = [BezierElement elementsFromCGPath:path]; - for (BezierElement *element in elements) { + NSArray *elements = [RNSVGBezierElement elementsFromCGPath:path]; + for (RNSVGBezierElement *element in elements) { switch (element.elementType) { case kCGPathElementMoveToPoint: diff --git a/ios/Text/RNSVGTextProperties.h b/ios/Text/RNSVGTextProperties.h new file mode 100644 index 00000000..d86db41d --- /dev/null +++ b/ios/Text/RNSVGTextProperties.h @@ -0,0 +1,200 @@ +#import + +#ifndef RNTextProperties_h +#define RNTextProperties_h + +typedef NS_ENUM(NSInteger, RNSVGAlignmentBaseline) { + RNSVGAlignmentBaselineBaseline, + RNSVGAlignmentBaselineTextBottom, + RNSVGAlignmentBaselineAlphabetic, + RNSVGAlignmentBaselineIdeographic, + RNSVGAlignmentBaselineMiddle, + RNSVGAlignmentBaselineCentral, + RNSVGAlignmentBaselineMathematical, + RNSVGAlignmentBaselineTextTop, + RNSVGAlignmentBaselineBottom, + RNSVGAlignmentBaselineCenter, + RNSVGAlignmentBaselineTop, + /* + SVG implementations may support the following aliases in order to support legacy content: + + text-before-edge = text-top + text-after-edge = text-bottom + */ + RNSVGAlignmentBaselineTextBeforeEdge, + RNSVGAlignmentBaselineTextAfterEdge, + // SVG 1.1 + RNSVGAlignmentBaselineBeforeEdge, + RNSVGAlignmentBaselineAfterEdge, + RNSVGAlignmentBaselineHanging, + RNSVGAlignmentBaselineDEFAULT = RNSVGAlignmentBaselineBaseline +}; + +static NSString* const RNSVGAlignmentBaselineStrings[] = { + @"baseline", + @"text-bottom", + @"alphabetic", + @"ideographic", + @"middle", + @"central", + @"mathematical", + @"text-top", + @"bottom", + @"center", + @"top", + @"text-before-edge", + @"text-after-edge", + @"before-edge", + @"after-edge", + @"hanging", + @"central", + @"mathematical", + @"text-top", + @"bottom", + @"center", + @"top", + nil +}; + +NSString* RNSVGAlignmentBaselineToString( enum RNSVGAlignmentBaseline fw ); + +enum RNSVGAlignmentBaseline RNSVGAlignmentBaselineFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGFontStyle) { + RNSVGFontStyleNormal, + RNSVGFontStyleItalic, + RNSVGFontStyleOblique, + RNSVGFontStyleDEFAULT = RNSVGFontStyleNormal, +}; + +static NSString* const RNSVGFontStyleStrings[] = {@"normal", @"italic", @"oblique", nil}; + +NSString* RNSVGFontStyleToString( enum RNSVGFontStyle fw ); + +enum RNSVGFontStyle RNSVGFontStyleFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGFontVariantLigatures) { + RNSVGFontVariantLigaturesNormal, + RNSVGFontVariantLigaturesNone, + RNSVGFontVariantLigaturesDEFAULT = RNSVGFontVariantLigaturesNormal, +}; + +static NSString* const RNSVGFontVariantLigaturesStrings[] = {@"normal", @"none", nil}; + +NSString* RNSVGFontVariantLigaturesToString( enum RNSVGFontVariantLigatures fw ); + +enum RNSVGFontVariantLigatures RNSVGFontVariantLigaturesFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGFontWeight) { + RNSVGFontWeightNormal, + RNSVGFontWeightBold, + RNSVGFontWeightBolder, + RNSVGFontWeightLighter, + RNSVGFontWeight100, + RNSVGFontWeight200, + RNSVGFontWeight300, + RNSVGFontWeight400, + RNSVGFontWeight500, + RNSVGFontWeight600, + RNSVGFontWeight700, + RNSVGFontWeight800, + RNSVGFontWeight900, + RNSVGFontWeightDEFAULT = RNSVGFontWeightNormal, +}; + +static NSString* const RNSVGFontWeightStrings[] = {@"Normal", @"Bold", @"Bolder", @"Lighter", @"100", @"200", @"300", @"400", @"500", @"600", @"700", @"800", @"900", nil}; + + +NSString* RNSVGFontWeightToString( enum RNSVGFontWeight fw ); + +enum RNSVGFontWeight RNSVGFontWeightFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGTextAnchor) { + RNSVGTextAnchorStart, + RNSVGTextAnchorMiddle, + RNSVGTextAnchorEnd, + RNSVGTextAnchorDEFAULT = RNSVGTextAnchorStart, +}; + +static NSString* const RNSVGTextAnchorStrings[] = {@"start", @"middle", @"end", nil}; + +NSString* RNSVGTextAnchorToString( enum RNSVGTextAnchor fw ); + +enum RNSVGTextAnchor RNSVGTextAnchorFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGTextDecoration) { + RNSVGTextDecorationNone, + RNSVGTextDecorationUnderline, + RNSVGTextDecorationOverline, + RNSVGTextDecorationLineThrough, + RNSVGTextDecorationBlink, + RNSVGTextDecorationDEFAULT = RNSVGTextDecorationNone, +}; + +static NSString* const RNSVGTextDecorationStrings[] = {@"None", @"Underline", @"Overline", @"LineThrough", @"Blink", nil}; + +NSString* RNSVGTextDecorationToString( enum RNSVGTextDecoration fw ); + +enum RNSVGTextDecoration RNSVGTextDecorationFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGTextLengthAdjust) { + RNSVGTextLengthAdjustSpacing, + RNSVGTextLengthAdjustSpacingAndGlyphs, + RNSVGTextLengthAdjustDEFAULT = RNSVGTextLengthAdjustSpacing, +}; + +static NSString* const RNSVGTextLengthAdjustStrings[] = {@"spacing", @"spacingAndGlyphs", nil}; + +NSString* RNSVGTextLengthAdjustToString( enum RNSVGTextLengthAdjust fw ); + +enum RNSVGTextLengthAdjust RNSVGTextLengthAdjustFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGTextPathMethod) { + RNSVGTextPathMethodAlign, + RNSVGTextPathMethodStretch, + RNSVGTextPathMethodDEFAULT = RNSVGTextPathMethodAlign, +}; + +static NSString* const RNSVGTextPathMethodStrings[] = {@"align", @"stretch", nil}; + +NSString* RNSVGTextPathMethodToString( enum RNSVGTextPathMethod fw ); + +enum RNSVGTextPathMethod RNSVGTextPathMethodFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGTextPathMidLine) { + RNSVGTextPathMidLineSharp, + RNSVGTextPathMidLineSmooth, + RNSVGTextPathMidLineDEFAULT = RNSVGTextPathMidLineSharp, +}; + +static NSString* const RNSVGTextPathMidLineStrings[] = {@"sharp", @"smooth", nil}; + +NSString* RNSVGTextPathMidLineToString( enum RNSVGTextPathMidLine fw ); + +enum RNSVGTextPathMidLine RNSVGTextPathMidLineFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGTextPathSide) { + RNSVGTextPathSideLeft, + RNSVGTextPathSideRight, + RNSVGTextPathSideDEFAULT = RNSVGTextPathSideLeft, +}; + +static NSString* const RNSVGTextPathSideStrings[] = {@"left", @"right", nil}; + +NSString* RNSVGTextPathSideToString( enum RNSVGTextPathSide fw ); + +enum RNSVGTextPathSide RNSVGTextPathSideFromString( NSString* s ); + +typedef NS_ENUM(NSInteger, RNSVGTextPathSpacing) { + RNSVGTextPathSpacingAutoSpacing, + RNSVGTextPathSpacingExact, + RNSVGTextPathSpacingDEFAULT = RNSVGTextPathSpacingAutoSpacing, +}; + +static NSString* const RNSVGTextPathSpacingStrings[] = {@"auto", @"exact", nil}; + +NSString* RNSVGTextPathSpacingToString( enum RNSVGTextPathSpacing fw ); + +enum RNSVGTextPathSpacing RNSVGTextPathSpacingFromString( NSString* s ); + +#endif diff --git a/ios/Text/RNSVGTextProperties.m b/ios/Text/RNSVGTextProperties.m new file mode 100644 index 00000000..ff5f980e --- /dev/null +++ b/ios/Text/RNSVGTextProperties.m @@ -0,0 +1,199 @@ +#import "RNSVGTextProperties.h" + +#pragma mark - RNSVGAlignmentBaseline + +NSString* RNSVGAlignmentBaselineToString( enum RNSVGAlignmentBaseline fw ) +{ + return RNSVGAlignmentBaselineStrings[fw]; +} + +enum RNSVGAlignmentBaseline RNSVGAlignmentBaselineFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGAlignmentBaselineStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGAlignmentBaselineStrings[i]]) { + return i; + } + } + return RNSVGAlignmentBaselineDEFAULT; +} + +#pragma mark - RNSVGFontStyle + +NSString* RNSVGFontStyleToString( enum RNSVGFontStyle fw ) +{ + return RNSVGFontStyleStrings[fw]; +} + +enum RNSVGFontStyle RNSVGFontStyleFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGFontStyleStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGFontStyleStrings[i]]) { + return i; + } + } + return RNSVGFontStyleDEFAULT; +} + +#pragma mark - RNSVGFontVariantLigatures + +NSString* RNSVGFontVariantLigaturesToString( enum RNSVGFontVariantLigatures fw ) +{ + return RNSVGFontVariantLigaturesStrings[fw]; +} + +enum RNSVGFontVariantLigatures RNSVGFontVariantLigaturesFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGFontVariantLigaturesStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGFontVariantLigaturesStrings[i]]) { + return i; + } + } + return RNSVGFontVariantLigaturesDEFAULT; +} + +#pragma mark - RNSVGFontWeight + +NSString* RNSVGFontWeightToString( enum RNSVGFontWeight fw ) +{ + return RNSVGFontWeightStrings[fw]; +} + +enum RNSVGFontWeight RNSVGFontWeightFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGFontWeightStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([[s capitalizedString] isEqualToString:RNSVGFontWeightStrings[i]]) { + return i; + } + } + return RNSVGFontWeightDEFAULT; +} + +#pragma mark - RNSVGTextAnchor + +NSString* RNSVGTextAnchorToString( enum RNSVGTextAnchor fw ) +{ + return RNSVGTextAnchorStrings[fw]; +} + +enum RNSVGTextAnchor RNSVGTextAnchorFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGTextAnchorStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGTextAnchorStrings[i]]) { + return i; + } + } + return RNSVGTextAnchorDEFAULT; +} + +#pragma mark - RNSVGTextDecoration + +NSString* RNSVGTextDecorationToString( enum RNSVGTextDecoration fw ) +{ + return RNSVGTextDecorationStrings[fw]; +} + +enum RNSVGTextDecoration RNSVGTextDecorationFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGTextDecorationStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGTextDecorationStrings[i]]) { + return i; + } + } + return RNSVGTextDecorationDEFAULT; +} + +#pragma mark - RNSVGTextLengthAdjust + +NSString* RNSVGTextLengthAdjustToString( enum RNSVGTextLengthAdjust fw ) +{ + return RNSVGTextLengthAdjustStrings[fw]; +} + +enum RNSVGTextLengthAdjust RNSVGTextLengthAdjustFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGTextLengthAdjustStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGTextLengthAdjustStrings[i]]) { + return i; + } + } + return RNSVGTextLengthAdjustDEFAULT; +} + +#pragma mark - RNSVGTextPathMethod + +NSString* RNSVGTextPathMethodToString( enum RNSVGTextPathMethod fw ) +{ + return RNSVGTextPathMethodStrings[fw]; +} + +enum RNSVGTextPathMethod RNSVGTextPathMethodFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGTextPathMethodStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGTextPathMethodStrings[i]]) { + return i; + } + } + return RNSVGTextPathMethodDEFAULT; +} + +#pragma mark - RNSVGTextPathMidLine + +NSString* RNSVGTextPathMidLineToString( enum RNSVGTextPathMidLine fw ) +{ + return RNSVGTextPathMidLineStrings[fw]; +} + +enum RNSVGTextPathMidLine RNSVGTextPathMidLineFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGTextPathMidLineStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGTextPathMidLineStrings[i]]) { + return i; + } + } + return RNSVGTextPathMidLineDEFAULT; +} + +#pragma mark - RNSVGTextPathSide + +NSString* RNSVGTextPathSideToString( enum RNSVGTextPathSide fw ) +{ + return RNSVGTextPathSideStrings[fw]; +} + +enum RNSVGTextPathSide RNSVGTextPathSideFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGTextPathSideStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGTextPathSideStrings[i]]) { + return i; + } + } + return RNSVGTextPathSideDEFAULT; +} + +#pragma mark - RNSVGTextPathSpacing + +NSString* RNSVGTextPathSpacingToString( enum RNSVGTextPathSpacing fw ) +{ + return RNSVGTextPathSpacingStrings[fw]; +} + +enum RNSVGTextPathSpacing RNSVGTextPathSpacingFromString( NSString* s ) +{ + const NSUInteger l = sizeof(RNSVGTextPathSpacingStrings) / sizeof(NSString*); + for (NSUInteger i = 0; i < l; i++) { + if ([s isEqualToString:RNSVGTextPathSpacingStrings[i]]) { + return i; + } + } + return RNSVGTextPathSpacingDEFAULT; +} diff --git a/ios/Text/TextAnchor.h b/ios/Text/TextAnchor.h deleted file mode 100644 index a4c18ef4..00000000 --- a/ios/Text/TextAnchor.h +++ /dev/null @@ -1,19 +0,0 @@ -#import - -#ifndef TextAnchor_h -#define TextAnchor_h - -typedef NS_ENUM(NSInteger, TextAnchor) { - TextAnchorStart, - TextAnchorMiddle, - TextAnchorEnd, - TextAnchorDEFAULT = TextAnchorStart, -}; - -static NSString* const TextAnchorStrings[] = {@"start", @"middle", @"end", nil}; - -NSString* TextAnchorToString( enum TextAnchor fw ); - -enum TextAnchor TextAnchorFromString( NSString* s ); - -#endif diff --git a/ios/Text/TextAnchor.m b/ios/Text/TextAnchor.m deleted file mode 100644 index f295551c..00000000 --- a/ios/Text/TextAnchor.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "TextAnchor.h" - -NSString* TextAnchorToString( enum TextAnchor fw ) -{ - return TextAnchorStrings[fw]; -} - -enum TextAnchor TextAnchorFromString( NSString* s ) -{ - const NSUInteger l = sizeof(TextAnchorStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:TextAnchorStrings[i]]) { - return i; - } - } - return TextAnchorDEFAULT; -} diff --git a/ios/Text/TextDecoration.h b/ios/Text/TextDecoration.h deleted file mode 100644 index 4a30d883..00000000 --- a/ios/Text/TextDecoration.h +++ /dev/null @@ -1,21 +0,0 @@ -#import - -#ifndef TextDecoration_h -#define TextDecoration_h - -typedef NS_ENUM(NSInteger, TextDecoration) { - TextDecorationNone, - TextDecorationUnderline, - TextDecorationOverline, - TextDecorationLineThrough, - TextDecorationBlink, - TextDecorationDEFAULT = TextDecorationNone, -}; - -static NSString* const TextDecorationStrings[] = {@"None", @"Underline", @"Overline", @"LineThrough", @"Blink", nil}; - -NSString* TextDecorationToString( enum TextDecoration fw ); - -enum TextDecoration TextDecorationFromString( NSString* s ); - -#endif diff --git a/ios/Text/TextDecoration.m b/ios/Text/TextDecoration.m deleted file mode 100644 index 5bf31361..00000000 --- a/ios/Text/TextDecoration.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "TextDecoration.h" - -NSString* TextDecorationToString( enum TextDecoration fw ) -{ - return TextDecorationStrings[fw]; -} - -enum TextDecoration TextDecorationFromString( NSString* s ) -{ - const NSUInteger l = sizeof(TextDecorationStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:TextDecorationStrings[i]]) { - return i; - } - } - return TextDecorationDEFAULT; -} diff --git a/ios/Text/TextLengthAdjust.h b/ios/Text/TextLengthAdjust.h deleted file mode 100644 index e93af930..00000000 --- a/ios/Text/TextLengthAdjust.h +++ /dev/null @@ -1,18 +0,0 @@ -#import - -#ifndef TextLengthAdjust_h -#define TextLengthAdjust_h - -typedef NS_ENUM(NSInteger, TextLengthAdjust) { - TextLengthAdjustSpacing, - TextLengthAdjustSpacingAndGlyphs, - TextLengthAdjustDEFAULT = TextLengthAdjustSpacing, -}; - -static NSString* const TextLengthAdjustStrings[] = {@"spacing", @"spacingAndGlyphs", nil}; - -NSString* TextLengthAdjustToString( enum TextLengthAdjust fw ); - -enum TextLengthAdjust TextLengthAdjustFromString( NSString* s ); - -#endif diff --git a/ios/Text/TextLengthAdjust.m b/ios/Text/TextLengthAdjust.m deleted file mode 100644 index 0ad44241..00000000 --- a/ios/Text/TextLengthAdjust.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "TextLengthAdjust.h" - -NSString* TextLengthAdjustToString( enum TextLengthAdjust fw ) -{ - return TextLengthAdjustStrings[fw]; -} - -enum TextLengthAdjust TextLengthAdjustFromString( NSString* s ) -{ - const NSUInteger l = sizeof(TextLengthAdjustStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:TextLengthAdjustStrings[i]]) { - return i; - } - } - return TextLengthAdjustDEFAULT; -} diff --git a/ios/Text/TextPathMethod.h b/ios/Text/TextPathMethod.h deleted file mode 100644 index a5f6defa..00000000 --- a/ios/Text/TextPathMethod.h +++ /dev/null @@ -1,18 +0,0 @@ -#import - -#ifndef TextPathMethod_h -#define TextPathMethod_h - -typedef NS_ENUM(NSInteger, TextPathMethod) { - TextPathMethodAlign, - TextPathMethodStretch, - TextPathMethodDEFAULT = TextPathMethodAlign, -}; - -static NSString* const TextPathMethodStrings[] = {@"align", @"stretch", nil}; - -NSString* TextPathMethodToString( enum TextPathMethod fw ); - -enum TextPathMethod TextPathMethodFromString( NSString* s ); - -#endif diff --git a/ios/Text/TextPathMethod.m b/ios/Text/TextPathMethod.m deleted file mode 100644 index 23aef013..00000000 --- a/ios/Text/TextPathMethod.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "TextPathMethod.h" - -NSString* TextPathMethodToString( enum TextPathMethod fw ) -{ - return TextPathMethodStrings[fw]; -} - -enum TextPathMethod TextPathMethodFromString( NSString* s ) -{ - const NSUInteger l = sizeof(TextPathMethodStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:TextPathMethodStrings[i]]) { - return i; - } - } - return TextPathMethodDEFAULT; -} diff --git a/ios/Text/TextPathMidLine.h b/ios/Text/TextPathMidLine.h deleted file mode 100644 index 3911be2b..00000000 --- a/ios/Text/TextPathMidLine.h +++ /dev/null @@ -1,18 +0,0 @@ -#import - -#ifndef TextPathMidLine_h -#define TextPathMidLine_h - -typedef NS_ENUM(NSInteger, TextPathMidLine) { - TextPathMidLineSharp, - TextPathMidLineSmooth, - TextPathMidLineDEFAULT = TextPathMidLineSharp, -}; - -static NSString* const TextPathMidLineStrings[] = {@"sharp", @"smooth", nil}; - -NSString* TextPathMidLineToString( enum TextPathMidLine fw ); - -enum TextPathMidLine TextPathMidLineFromString( NSString* s ); - -#endif diff --git a/ios/Text/TextPathMidLine.m b/ios/Text/TextPathMidLine.m deleted file mode 100644 index 6e4d3e43..00000000 --- a/ios/Text/TextPathMidLine.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "TextPathMidLine.h" - -NSString* TextPathMidLineToString( enum TextPathMidLine fw ) -{ - return TextPathMidLineStrings[fw]; -} - -enum TextPathMidLine TextPathMidLineFromString( NSString* s ) -{ - const NSUInteger l = sizeof(TextPathMidLineStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:TextPathMidLineStrings[i]]) { - return i; - } - } - return TextPathMidLineDEFAULT; -} diff --git a/ios/Text/TextPathSide.h b/ios/Text/TextPathSide.h deleted file mode 100644 index 90a55ce2..00000000 --- a/ios/Text/TextPathSide.h +++ /dev/null @@ -1,18 +0,0 @@ -#import - -#ifndef TextPathSide_h -#define TextPathSide_h - -typedef NS_ENUM(NSInteger, TextPathSide) { - TextPathSideLeft, - TextPathSideRight, - TextPathSideDEFAULT = TextPathSideLeft, -}; - -static NSString* const TextPathSideStrings[] = {@"left", @"right", nil}; - -NSString* TextPathSideToString( enum TextPathSide fw ); - -enum TextPathSide TextPathSideFromString( NSString* s ); - -#endif diff --git a/ios/Text/TextPathSide.m b/ios/Text/TextPathSide.m deleted file mode 100644 index d0bcb820..00000000 --- a/ios/Text/TextPathSide.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "TextPathSide.h" - -NSString* TextPathSideToString( enum TextPathSide fw ) -{ - return TextPathSideStrings[fw]; -} - -enum TextPathSide TextPathSideFromString( NSString* s ) -{ - const NSUInteger l = sizeof(TextPathSideStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:TextPathSideStrings[i]]) { - return i; - } - } - return TextPathSideDEFAULT; -} diff --git a/ios/Text/TextPathSpacing.h b/ios/Text/TextPathSpacing.h deleted file mode 100644 index f40b5c45..00000000 --- a/ios/Text/TextPathSpacing.h +++ /dev/null @@ -1,18 +0,0 @@ -#import - -#ifndef TextPathSpacing_h -#define TextPathSpacing_h - -typedef NS_ENUM(NSInteger, TextPathSpacing) { - TextPathSpacingAutoSpacing, - TextPathSpacingExact, - TextPathSpacingDEFAULT = TextPathSpacingAutoSpacing, -}; - -static NSString* const TextPathSpacingStrings[] = {@"auto", @"exact", nil}; - -NSString* TextPathSpacingToString( enum TextPathSpacing fw ); - -enum TextPathSpacing TextPathSpacingFromString( NSString* s ); - -#endif diff --git a/ios/Text/TextPathSpacing.m b/ios/Text/TextPathSpacing.m deleted file mode 100644 index 08735d76..00000000 --- a/ios/Text/TextPathSpacing.m +++ /dev/null @@ -1,17 +0,0 @@ -#import "TextPathSpacing.h" - -NSString* TextPathSpacingToString( enum TextPathSpacing fw ) -{ - return TextPathSpacingStrings[fw]; -} - -enum TextPathSpacing TextPathSpacingFromString( NSString* s ) -{ - const NSUInteger l = sizeof(TextPathSpacingStrings) / sizeof(NSString*); - for (NSUInteger i = 0; i < l; i++) { - if ([s isEqualToString:TextPathSpacingStrings[i]]) { - return i; - } - } - return TextPathSpacingDEFAULT; -} diff --git a/ios/Utils/BezierElement.h b/ios/Utils/RNSVGBezierElement.h similarity index 87% rename from ios/Utils/BezierElement.h rename to ios/Utils/RNSVGBezierElement.h index 5d59efc0..87784d14 100644 --- a/ios/Utils/BezierElement.h +++ b/ios/Utils/RNSVGBezierElement.h @@ -7,9 +7,9 @@ #import #import -#define NULLPOINT CGRectNull.origin +#define RNSVGNULLPOINT CGRectNull.origin -@interface BezierElement : NSObject +@interface RNSVGBezierElement : NSObject // Element storage @property (nonatomic, assign) CGPathElementType elementType; diff --git a/ios/Utils/BezierElement.m b/ios/Utils/RNSVGBezierElement.m similarity index 80% rename from ios/Utils/BezierElement.m rename to ios/Utils/RNSVGBezierElement.m index 98bc65d1..736fa854 100644 --- a/ios/Utils/BezierElement.m +++ b/ios/Utils/RNSVGBezierElement.m @@ -4,27 +4,27 @@ https://github.com/erica/iOS-Drawing/tree/master/C08/Quartz%20Book%20Pack/Bezier */ -#import "BezierElement.h" +#import "RNSVGBezierElement.h" #pragma mark - Bezier Element - -@implementation BezierElement +@implementation RNSVGBezierElement - (instancetype) init { self = [super init]; if (self) { _elementType = kCGPathElementMoveToPoint; - _point = NULLPOINT; - _controlPoint1 = NULLPOINT; - _controlPoint2 = NULLPOINT; + _point = RNSVGNULLPOINT; + _controlPoint1 = RNSVGNULLPOINT; + _controlPoint2 = RNSVGNULLPOINT; } return self; } + (instancetype) elementWithPathElement: (CGPathElement) element { - BezierElement *newElement = [[self alloc] init]; + RNSVGBezierElement *newElement = [[self alloc] init]; newElement.elementType = element.type; switch (newElement.elementType) @@ -57,12 +57,12 @@ return newElement; } -// Convert one element to BezierElement and save to array +// Convert one element to RNSVGBezierElement and save to array void GetBezierElements(void *info, const CGPathElement *element) { NSMutableArray *bezierElements = (__bridge NSMutableArray *)info; if (element) - [bezierElements addObject:[BezierElement elementWithPathElement:*element]]; + [bezierElements addObject:[RNSVGBezierElement elementWithPathElement:*element]]; } // Retrieve array of component elements diff --git a/ios/Utils/RNSVGPathParser.m b/ios/Utils/RNSVGPathParser.m index 1c434cde..cc4532d6 100644 --- a/ios/Utils/RNSVGPathParser.m +++ b/ios/Utils/RNSVGPathParser.m @@ -8,8 +8,8 @@ #import "RNSVGPathParser.h" #import -#import "math.h" -#import "BezierElement.h" +#import +#import "RNSVGBezierElement.h" @implementation RNSVGPathParser {