diff --git a/GlyphsSource/SpeedPunk.xcodeproj/project.pbxproj b/GlyphsSource/SpeedPunk.xcodeproj/project.pbxproj index 47fd26d..65568aa 100644 --- a/GlyphsSource/SpeedPunk.xcodeproj/project.pbxproj +++ b/GlyphsSource/SpeedPunk.xcodeproj/project.pbxproj @@ -32,7 +32,7 @@ 5649E5E72AC60A6700A0FF33 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = ""; }; 5649E5E82AC60A6800A0FF33 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/Localizable.strings; sourceTree = ""; }; 5649E5E92AC60A6A00A0FF33 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; - 5649E5EA2AC61EBC00A0FF33 /* GlyphsCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GlyphsCore.framework; path = "../../../../../../Applications/Glyphs 3.app/Contents/Frameworks/GlyphsCore.framework"; sourceTree = ""; }; + 5649E5EA2AC61EBC00A0FF33 /* GlyphsCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GlyphsCore.framework; path = "/Applications/Glyphs 3.app/Contents/Frameworks/GlyphsCore.framework"; sourceTree = ""; }; 5664B2B02AC4597800A28703 /* SpeedPunk.glyphsReporter */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SpeedPunk.glyphsReporter; sourceTree = BUILT_PRODUCTS_DIR; }; 5664B2B32AC4597800A28703 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 5664B2B62AC4597800A28703 /* SpeedPunk.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeedPunk.h; sourceTree = ""; }; @@ -230,8 +230,8 @@ CODE_SIGN_IDENTITY = "Developer ID Application: Georg Seifert (X2L8375ZQ7)"; DEPLOYMENT_LOCATION = YES; DEVELOPMENT_TEAM = X2L8375ZQ7; - DSTROOT = "$(USER_LIBRARY_DIR)/Application Support/Glyphs 3/Plugins"; - FRAMEWORK_SEARCH_PATHS = "\"/Applications/Glyphs 3.app/Contents/Frameworks\""; + DSTROOT = "$(USER_LIBRARY_DIR)/Application Support/Glyphs 4/Plugins"; + FRAMEWORK_SEARCH_PATHS = "\"/Applications/Glyphs 4.app/Contents/Frameworks\""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSPrincipalClass = SPSpeedPunk; INSTALL_PATH = /; @@ -247,7 +247,7 @@ CODE_SIGN_IDENTITY = "Developer ID Application: Georg Seifert (X2L8375ZQ7)"; DEPLOYMENT_POSTPROCESSING = NO; DEVELOPMENT_TEAM = X2L8375ZQ7; - FRAMEWORK_SEARCH_PATHS = "\"/Applications/Glyphs 3.app/Contents/Frameworks\""; + FRAMEWORK_SEARCH_PATHS = "\"/Applications/Glyphs 4.app/Contents/Frameworks\""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSPrincipalClass = SPSpeedPunk; INSTALL_PATH = /; diff --git a/GlyphsSource/SpeedPunk/SpeedPunk.h b/GlyphsSource/SpeedPunk/SpeedPunk.h index e7bf8c1..955df98 100644 --- a/GlyphsSource/SpeedPunk/SpeedPunk.h +++ b/GlyphsSource/SpeedPunk/SpeedPunk.h @@ -7,7 +7,7 @@ // #import -#import +#import @interface SPSpeedPunk : NSViewController diff --git a/GlyphsSource/SpeedPunk/SpeedPunk.m b/GlyphsSource/SpeedPunk/SpeedPunk.m index 9ff45d1..4bb1ea6 100644 --- a/GlyphsSource/SpeedPunk/SpeedPunk.m +++ b/GlyphsSource/SpeedPunk/SpeedPunk.m @@ -7,20 +7,87 @@ // #import "SpeedPunk.h" -#import -#import #import #import #import #import #import -#import +#import #import -#import -#import +#import +#import +#import + +// extern void calcQuadraticParameters(NSPoint p1, NSPoint p2, NSPoint p3, NSPoint *a, NSPoint *b, NSPoint *c); +// extern void calcCubicParameters(NSPoint p1, NSPoint p2, NSPoint p3, NSPoint p4, NSPoint *a, NSPoint *b, NSPoint *c, NSPoint *d); + +typedef void (*CalcCubicParametersFunction)( + NSPoint p1, + NSPoint p2, + NSPoint p3, + NSPoint p4, + NSPoint *a, + NSPoint *b, + NSPoint *c, + NSPoint *d +); + +static CalcCubicParametersFunction sCalcCubicParameters = NULL; + +typedef void (*CalcQuadraticParametersFunction)( + NSPoint p1, + NSPoint p2, + NSPoint p3, + NSPoint *a, + NSPoint *b, + NSPoint *c +); + +static CalcQuadraticParametersFunction sCalcQuadraticParameters = NULL; + +static void *sFrameworkHandle = NULL; + +static BOOL LoadCalcCubicParameters(void) { + NSBundle *coreBundle = [NSBundle bundleForClass:[GSFont class]]; + sFrameworkHandle = dlopen( + coreBundle.executablePath.fileSystemRepresentation, + RTLD_LAZY | RTLD_LOCAL + ); + + if (sFrameworkHandle == NULL) { + NSLog(@"Could not load framework: %s", dlerror()); + return NO; + } -extern void calcQuadraticParameters(NSPoint p1, NSPoint p2, NSPoint p3, NSPoint *a, NSPoint *b, NSPoint *c); -extern void calcCubicParameters(NSPoint p1, NSPoint p2, NSPoint p3, NSPoint p4, NSPoint *a, NSPoint *b, NSPoint *c, NSPoint *d); + static const char *symbolCubicNames[] = { + "calcCubicParameters", // Glyphs 3 + "GSCalcCubicParameters" // Glyphs 4 + }; + void *symbolCubic = NULL; + for (NSUInteger i = 0; i < sizeof(symbolCubicNames) / sizeof(symbolCubicNames[0]); i++) { + symbolCubic = dlsym(sFrameworkHandle, symbolCubicNames[i]); + + if (symbolCubic != NULL) { + sCalcCubicParameters = (CalcCubicParametersFunction)symbolCubic; + break; + } + } + + static const char *symbolQuadraticNames[] = { + "calcQuadraticParameters", // Glyphs 3 + "GSCalcQuadraticParameters" // Glyphs 4 + }; + void *symbolQuadratic = NULL; + for (NSUInteger i = 0; i < sizeof(symbolQuadraticNames) / sizeof(symbolQuadraticNames[0]); i++) { + symbolQuadratic = dlsym(sFrameworkHandle, symbolQuadraticNames[i]); + + if (symbolQuadratic != NULL) { + sCalcQuadraticParameters = (CalcQuadraticParametersFunction)symbolQuadratic; + break; + } + } + return symbolCubic && symbolQuadratic; +} // #define DRAW_GRADIENTS 1 @@ -303,7 +370,11 @@ - (void)updateCurvaturePath { NSPoint outerspace2 = NSMakePoint(S20.x + (S21.y / S21abs * k2), S20.y - (S21.x / S21abs * k2)); NSPoint outerspace1 = NSMakePoint(S10.x + (S11.y / S11abs * k1), S10.y - (S11.x / S11abs * k1)); - NSBezierPath *path = [GSSaveBezierPath new]; + if (!isfinite(S10.x) || !isfinite(S10.y) || !isfinite(S20.x) || !isfinite(outerspace1.x) || !isfinite(outerspace1.y) || !isfinite(outerspace2.x) || !isfinite(outerspace2.y)) { + return; + } + + NSBezierPath *path = [NSBezierPath new]; // OnCurve [path moveToPoint:S10]; [path lineToPoint:S20]; @@ -339,6 +410,9 @@ @implementation SPSpeedPunk @synthesize controller = _editViewController; + (void)initialize { + + LoadCalcCubicParameters(); + NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; CGFloat defaultCurveGain = Interpolate(curveGainMin, curveGainMax, .2); [defaults registerDefaults:@{ @@ -373,7 +447,7 @@ - (void)awakeFromNib { } - (NSUInteger)interfaceVersion { - // Distinguishes the API verison the plugin was built for. Return 1. + // Distinguishes the API version the plugin was built for. Return 1. return 1; } @@ -415,11 +489,11 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N Alpha = [defaults floatForKey:AlphaKey]; for (GSPathSegment *segment in self.segments) { - for (SPCurvature *curvatrue in segment.objects) { + for (SPCurvature *curvature in segment.objects) { #if DRAW_GRADIENTS - curvatrue.gradient = nil; + curvature.gradient = nil; #else - curvatrue.color = nil; + curvature.color = nil; #endif } } @@ -440,7 +514,7 @@ - (NSArray *)_calcCurvaturesCubic:(NSPoint)p1 p2:(NSPoint)p2 p3:(NSPoint)p3 p4:( NSMutableArray *curvatureSets = [NSMutableArray new]; NSPoint a, b, c, d; - calcCubicParameters(p1, p2, p3, p4, &a, &b, &c, &d); + sCalcCubicParameters(p1, p2, p3, p4, &a, &b, &c, &d); CGFloat curvature1 = NSNotFound; CGFloat curvature2 = NSNotFound; @@ -466,7 +540,7 @@ - (NSArray *)_calcCurvaturesQuadratic:(NSPoint)p1 p2:(NSPoint)p2 p3:(NSPoint)p3 NSMutableArray *curvatureSets = [NSMutableArray new]; NSPoint a, b, c; - calcQuadraticParameters(p1, p2, p3, &a, &b, &c); + sCalcQuadraticParameters(p1, p2, p3, &a, &b, &c); CGFloat curvature1 = NSNotFound; CGFloat curvature2 = NSNotFound; @@ -490,7 +564,7 @@ - (NSArray *)_calcCurvaturesQuadratic:(NSPoint)p1 p2:(NSPoint)p2 p3:(NSPoint)p3 - (void)calcCurvatures:(GSPathSegment *)segment steps:(int)steps { NSArray *curvatureSets; - if( segment.type == CURVE) { + if (segment.type == CURVE) { // curvatureSets = self._calcCurvaturesCubic(segment[0], segment[1], segment[2], segment[3], steps) curvatureSets = [self _calcCurvaturesCubic:segment->elements[0] p2:segment->elements[1] p3:segment->elements[2] p4:segment->elements[3] steps:steps]; } @@ -498,7 +572,7 @@ - (void)calcCurvatures:(GSPathSegment *)segment steps:(int)steps { if (segment->count == 3) { curvatureSets = [self _calcCurvaturesQuadratic:segment->elements[0] p2:segment->elements[1] p3:segment->elements[2] steps:steps]; } - else { + else if (segment->count > 3) { curvatureSets = [NSMutableArray new]; NSPoint prevOn = segment->elements[0]; steps /= segment->count - 2; @@ -572,7 +646,7 @@ - (BOOL)conditionsAreMetForDrawing { /* Don't activate if text or pan (hand) tool are active. */ - NSWindowController *currentController = self.controller.view.window.windowController; + GSWindowController *currentController = self.controller.windowController; if (!currentController) { return NO; } diff --git a/GlyphsSource/SpeedPunk/common.xcconfig b/GlyphsSource/SpeedPunk/common.xcconfig index c96d9a5..fc450aa 100644 --- a/GlyphsSource/SpeedPunk/common.xcconfig +++ b/GlyphsSource/SpeedPunk/common.xcconfig @@ -1,9 +1,9 @@ // common -MARKETING_VERSION = 1.3 -CURRENT_PROJECT_VERSION = 20 +MARKETING_VERSION = 1.3.2 +CURRENT_PROJECT_VERSION = 22 -HUMAN_READABLE_COPYRIGHT = © 2023 Yanone +HUMAN_READABLE_COPYRIGHT = © 2026 Yanone PRODUCT_BUNDLE_IDENTIFIER = de.Yanone.${PRODUCT_NAME:rfc1034identifier} diff --git a/SpeedPunk.glyphsReporter/Contents/Info.plist b/SpeedPunk.glyphsReporter/Contents/Info.plist index 4249338..087de89 100644 --- a/SpeedPunk.glyphsReporter/Contents/Info.plist +++ b/SpeedPunk.glyphsReporter/Contents/Info.plist @@ -3,7 +3,7 @@ BuildMachineOSBuild - 21G726 + 22H420 CFBundleDevelopmentRegion en CFBundleExecutable @@ -17,13 +17,13 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.3 + 1.3.1 CFBundleSupportedPlatforms MacOSX CFBundleVersion - 20 + 21 DTCompiler com.apple.compilers.llvm.clang.1_0 DTPlatformBuild diff --git a/SpeedPunk.glyphsReporter/Contents/MacOS/SpeedPunk b/SpeedPunk.glyphsReporter/Contents/MacOS/SpeedPunk index 295157c..f7463f7 100755 Binary files a/SpeedPunk.glyphsReporter/Contents/MacOS/SpeedPunk and b/SpeedPunk.glyphsReporter/Contents/MacOS/SpeedPunk differ