Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions GlyphsSource/SpeedPunk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
5649E5E72AC60A6700A0FF33 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
5649E5E82AC60A6800A0FF33 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/Localizable.strings; sourceTree = "<group>"; };
5649E5E92AC60A6A00A0FF33 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
5649E5EA2AC61EBC00A0FF33 /* GlyphsCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GlyphsCore.framework; path = "../../../../../../Applications/Glyphs 3.app/Contents/Frameworks/GlyphsCore.framework"; sourceTree = "<group>"; };
5649E5EA2AC61EBC00A0FF33 /* GlyphsCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GlyphsCore.framework; path = "/Applications/Glyphs 3.app/Contents/Frameworks/GlyphsCore.framework"; sourceTree = "<absolute>"; };
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 = "<group>"; };
Expand Down Expand Up @@ -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 = /;
Expand All @@ -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 = /;
Expand Down
2 changes: 1 addition & 1 deletion GlyphsSource/SpeedPunk/SpeedPunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <Cocoa/Cocoa.h>
#import <GlyphsCore/GlyphsReporterProtocol.h>
#import <GlyphsApp/GlyphsReporterProtocol.h>

@interface SPSpeedPunk : NSViewController <GlyphsReporter>

Expand Down
108 changes: 91 additions & 17 deletions GlyphsSource/SpeedPunk/SpeedPunk.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,87 @@
//

#import "SpeedPunk.h"
#import <GlyphsCore/GlyphsFilterProtocol.h>
#import <GlyphsCore/GSFilterPlugin.h>
#import <GlyphsCore/GSFont.h>
#import <GlyphsCore/GSGlyph.h>
#import <GlyphsCore/GSLayer.h>
#import <GlyphsCore/GSPath.h>
#import <GlyphsCore/GSPathSegment.h>
#import <GlyphsCore/GSGeometrieHelper.h>
#import <GlyphsCore/GSGeometryHelpers.h>
#import <GlyphsCore/GSProxyShapes.h>
#import <GlyphsCore/GSSaveBezierPath.h>
#import <GlyphsCore/GSWindowControllerProtocol.h>
#import <GlyphsApp/GSWindowController.h>
#import <GlyphsApp/GSEditViewController.h>
#import <dlfcn.h>

// 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

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -339,6 +410,9 @@ @implementation SPSpeedPunk
@synthesize controller = _editViewController;

+ (void)initialize {

LoadCalcCubicParameters();

NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults;
CGFloat defaultCurveGain = Interpolate(curveGainMin, curveGainMax, .2);
[defaults registerDefaults:@{
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
}
}
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -490,15 +564,15 @@ - (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];
}
else if (segment.type == QCURVE) {
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;
Expand Down Expand Up @@ -572,7 +646,7 @@ - (BOOL)conditionsAreMetForDrawing {
/*
Don't activate if text or pan (hand) tool are active.
*/
NSWindowController <GSWindowControllerProtocol> *currentController = self.controller.view.window.windowController;
GSWindowController *currentController = self.controller.windowController;
if (!currentController) {
return NO;
}
Expand Down
6 changes: 3 additions & 3 deletions GlyphsSource/SpeedPunk/common.xcconfig
Original file line number Diff line number Diff line change
@@ -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}

Expand Down
6 changes: 3 additions & 3 deletions SpeedPunk.glyphsReporter/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>21G726</string>
<string>22H420</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -17,13 +17,13 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.3</string>
<string>1.3.1</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>20</string>
<string>21</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
Expand Down
Binary file modified SpeedPunk.glyphsReporter/Contents/MacOS/SpeedPunk
Binary file not shown.