-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmacOS.patch
378 lines (335 loc) · 16.8 KB
/
macOS.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
--- F-Engrave-1.75_src/f-engrave.py 2021-05-31 11:58:48
+++ f-engrave.py 2024-01-08 17:57:49
@@ -354,7 +354,42 @@
Zero = 0.00001
STOP_CALC = 0
+
+# macOS Patch - Stephen Houser ([email protected])
+# Inject system font directory and default document location
+sys.argv.extend(('--fontdir', '/System/Library/Fonts', '--defdir', '~/Documents'))
+# Get platform specific default font
+def get_default_font_name():
+ from sys import platform
+ if platform == "linux" or platform == "linux2":
+ default_font_name = 'TkDefaultFont'
+ elif platform == "darwin":
+ default_font_name = 'systemSystemFont'
+ elif platform == "win32":
+ default_font_name = 'TkDefaultFont'
+ else:
+ default_font_name = 'TkDefaultFont'
+
+ return default_font_name
+
+# Used to invole ttf2cxf_stream, when in bundle on macOS
+def ttf2cxf_stream():
+ ttf2cxf_cmd = 'ttf2cxf_stream'
+ if getattr(sys, 'frozen', False):
+ bundle_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
+ ttf2cxf_cmd = os.path.join(bundle_dir, ttf2cxf_cmd)
+
+ return ttf2cxf_cmd
+
+def potrace():
+ potrace_cmd = 'potrace'
+ if getattr(sys, 'frozen', False):
+ bundle_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
+ potrace_cmd = os.path.join(bundle_dir, potrace_cmd)
+
+ return potrace_cmd
+
#raw_input("PAUSED: Press ENTER to continue")
################################################################################
# Function for outputting messages to different locations #
@@ -463,7 +498,7 @@
font[key] = Character(key)
font[key].stroke_list = stroke_list
font[key].xmax = xmax
- new_cmd = re.match('^\[(.*)\]\s', text)
+ new_cmd = re.match(r'^\[(.*)\]\s', text)
if new_cmd: #new character
key_tmp = new_cmd.group(1)
if len(new_cmd.group(1)) == 1:
@@ -487,14 +522,14 @@
stroke_list = []
xmax, ymax = 0, 0
- line_cmd = re.match('^L (.*)', text)
+ line_cmd = re.match(r'^L (.*)', text)
if line_cmd:
coords = line_cmd.group(1)
coords = [float(n) for n in coords.split(',')]
stroke_list += [Line(coords)]
xmax = max(xmax, coords[0], coords[2])
- arc_cmd = re.match('^A (.*)', text)
+ arc_cmd = re.match(r'^A (.*)', text)
if arc_cmd:
coords = arc_cmd.group(1)
coords = [float(n) for n in coords.split(',')]
@@ -1836,7 +1871,7 @@
- cmd = ["ttf2cxf_stream","TEST","STDOUT"]
+ cmd = [ttf2cxf_stream(),"TEST","STDOUT"]
try:
startupinfo=None
if sys.platform == 'win32':
@@ -1856,7 +1891,7 @@
fmessage("ttf2cxf_stream executable is not present/working...Bummer")
self.TTF_AVAIL = FALSE
- cmd = ["potrace","-v"]
+ cmd = [potrace(),"-v"]
try:
startupinfo=None
if sys.platform == 'win32':
@@ -2466,8 +2501,14 @@
self.Listbox_1.bind("<Down>", self.Listbox_Key_Down)
try:
- font_files=os.listdir(self.fontdir.get())
- font_files.sort()
+ font_files = []
+ import fnmatch
+ for r, dirnames, filenames in os.walk(self.fontdir.get()):
+ for filename in fnmatch.filter(filenames, '*.[Cc][Xx][Ff]'):
+ font_files.append(os.path.join(r.replace(self.fontdir.get(), ""), filename))
+ for filename in fnmatch.filter(filenames, '*.[Tt][Tt][Ff]'):
+ font_files.append(os.path.join(r.replace(self.fontdir.get(), ""), filename))
+ font_files.sort()
except:
font_files=" "
for name in font_files:
@@ -5369,7 +5410,7 @@
self.Checkbutton_useIMGsize.place_forget()
# Left Column #
- w_label=90
+ w_label=120 #90
w_entry=60
w_units=35
@@ -5523,15 +5564,15 @@
self.Recalculate.place(x=12, y=Ybut, width=95, height=30)
Ybut=self.h-60
- self.V_Carve_Calc.place(x=x_label_R, y=Ybut, width=100, height=30)
+ self.V_Carve_Calc.place(x=x_label_R, y=Ybut, height=30)
Ybut=self.h-105
self.Radio_Cut_E.place(x=x_label_R, y=Ybut, width=185, height=23)
Ybut=self.h-85
self.Radio_Cut_V.place(x=x_label_R, y=Ybut, width=185, height=23)
- self.PreviewCanvas.configure( width = self.w-455, height = self.h-160 )
- self.PreviewCanvas_frame.place(x=220, y=10)
+ self.PreviewCanvas.configure( width = self.w-485, height = self.h-160 )
+ self.PreviewCanvas_frame.place(x=250, y=10)
self.Input_Label.place(x=222, y=self.h-130, width=112, height=21, anchor=W)
self.Input_frame.place(x=222, y=self.h-110, width=self.w-455, height=75)
@@ -5544,7 +5585,7 @@
self.Label_flip.configure(text="Flip Image")
self.Label_mirror.configure(text="Mirror Image")
# Left Column #
- w_label=90
+ w_label=120 #90
w_entry=60
w_units=35
@@ -5690,15 +5731,15 @@
self.Recalculate.place(x=12, y=Ybut, width=95, height=30)
Ybut=self.h-60
- self.V_Carve_Calc.place(x=x_label_R+offset_R, y=Ybut, width=100, height=30)
+ self.V_Carve_Calc.place(x=x_label_R+offset_R, y=Ybut, height=30)
Ybut=self.h-105
self.Radio_Cut_E.place(x=x_label_R+offset_R, y=Ybut, width=w_label, height=23)
Ybut=self.h-85
self.Radio_Cut_V.place(x=x_label_R+offset_R, y=Ybut, width=w_label, height=23)
- self.PreviewCanvas.configure( width = self.w-240, height = self.h-45 )
- self.PreviewCanvas_frame.place(x=230, y=10)
+ self.PreviewCanvas.configure( width = self.w-270, height = self.h-45 )
+ self.PreviewCanvas_frame.place(x=260, y=10)
self.Input_Label.place_forget()
self.Input_frame.place_forget()
@@ -5926,7 +5967,7 @@
option = option + "-e"
else:
option = ""
- cmd = ["ttf2cxf_stream",
+ cmd = [ttf2cxf_stream(),
option,
"-s",self.segarc.get(),
file_full,"STDOUT"]
@@ -6000,14 +6041,14 @@
try:
#cmd = ["potrace","-b","dxf",file_full,"-o","-"]
if self.bmp_longcurve.get() == 1:
- cmd = ["potrace",
+ cmd = [potrace(),
"-z", self.bmp_turnpol.get(),
"-t", self.bmp_turdsize.get(),
"-a",self.bmp_alphamax.get(),
"-O",self.bmp_opttolerance.get(),
"-b","dxf",file_full,"-o","-"]
else:
- cmd = ["potrace",
+ cmd = [potrace(),
"-z", self.bmp_turnpol.get(),
"-t", self.bmp_turdsize.get(),
"-a",self.bmp_alphamax.get(),
@@ -6049,14 +6090,14 @@
#cmd = ["potrace","-b","dxf",file_full,"-o","-"]
if self.bmp_longcurve.get() == 1:
- cmd = ["potrace",
+ cmd = [potrace(),
"-z", self.bmp_turnpol.get(),
"-t", self.bmp_turdsize.get(),
"-a",self.bmp_alphamax.get(),
"-O",self.bmp_opttolerance.get(),
"-b","dxf",file_full_tmp,"-o","-"]
else:
- cmd = ["potrace",
+ cmd = [potrace(),
"-z", self.bmp_turnpol.get(),
"-t", self.bmp_turdsize.get(),
"-a",self.bmp_alphamax.get(),
@@ -8370,18 +8411,18 @@
D_Yloc=D_Yloc+D_dY
self.Label_arcfit = Label(gen_settings,text="Arc Fitting")
- self.Label_arcfit.place(x=xd_label_L, y=D_Yloc, width=w_label, height=21)
+ self.Label_arcfit.place(x=xd_label_L, y=D_Yloc, width=w_label, height=23)
self.Radio_arcfit_none = Radiobutton(gen_settings,text="None", \
- value="none", width="110", anchor=W)
- self.Radio_arcfit_none.place(x=w_label+x_radio_offset, y=D_Yloc, width=90, height=23)
+ value="none", width="60", anchor=W)
+ self.Radio_arcfit_none.place(x=xd_entry_L, y=D_Yloc, width=60, height=23)
self.Radio_arcfit_none.configure(variable=self.arc_fit )
self.Radio_arcfit_radius = Radiobutton(gen_settings,text="Radius Format", \
- value="radius", width="110", anchor=W)
- self.Radio_arcfit_radius.place(x=w_label+x_radio_offset+65, y=D_Yloc, width=100, height=23)
+ value="radius", width="130", anchor=W)
+ self.Radio_arcfit_radius.place(x=xd_entry_L+65, y=D_Yloc, width=120, height=23)
self.Radio_arcfit_radius.configure(variable=self.arc_fit )
self.Radio_arcfit_center = Radiobutton(gen_settings,text="Center Format", \
- value="center", width="110", anchor=W)
- self.Radio_arcfit_center.place(x=w_label+x_radio_offset+65+115, y=D_Yloc, width=100, height=23)
+ value="center", width="130", anchor=W)
+ self.Radio_arcfit_center.place(x=xd_entry_L+65+125, y=D_Yloc, width=120, height=23)
self.Radio_arcfit_center.configure(variable=self.arc_fit )
D_Yloc=D_Yloc+D_dY
@@ -8413,29 +8454,26 @@
self.Checkbutton_var_dis.configure(variable=self.var_dis)
D_Yloc=D_Yloc+D_dY
- font_entry_width=215
self.Label_Fontdir = Label(gen_settings,text="Font Directory")
self.Label_Fontdir.place(x=xd_label_L, y=D_Yloc, width=w_label, height=21)
self.Entry_Fontdir = Entry(gen_settings,width="15")
- self.Entry_Fontdir.place(x=xd_entry_L, y=D_Yloc, width=font_entry_width, height=23)
+ self.Entry_Fontdir.place(x=xd_entry_L, y=D_Yloc, width=240, height=23)
self.Entry_Fontdir.configure(textvariable=self.fontdir)
self.Fontdir = Button(gen_settings,text="Select Dir")
- self.Fontdir.place(x=xd_entry_L+font_entry_width+10, y=D_Yloc, width=w_label-80, height=23)
+ self.Fontdir.place(x=xd_entry_L+250, y=D_Yloc, height=23)
D_Yloc=D_Yloc+D_dY
self.Label_Hcalc = Label(gen_settings,text="Height Calculation")
self.Label_Hcalc.place(x=xd_label_L, y=D_Yloc, width=w_label, height=21)
-
+ self.Radio_Hcalc_ALL = Radiobutton(gen_settings,text="Max All", \
+ value="max_all", width="110", anchor=W)
+ self.Radio_Hcalc_ALL.place(x=xd_entry_L+110, y=D_Yloc, width=90, height=23)
+ self.Radio_Hcalc_ALL.configure(variable=self.H_CALC )
self.Radio_Hcalc_USE = Radiobutton(gen_settings,text="Max Used", \
value="max_use", width="110", anchor=W)
- self.Radio_Hcalc_USE.place(x=w_label+x_radio_offset, y=D_Yloc, width=90, height=23)
+ self.Radio_Hcalc_USE.place(x=xd_entry_L, y=D_Yloc, width=90, height=23)
self.Radio_Hcalc_USE.configure(variable=self.H_CALC )
- self.Radio_Hcalc_ALL = Radiobutton(gen_settings,text="Max All", \
- value="max_all", width="110", anchor=W)
- self.Radio_Hcalc_ALL.place(x=w_label+x_radio_offset+90, y=D_Yloc, width=90, height=23)
- self.Radio_Hcalc_ALL.configure(variable=self.H_CALC )
-
if self.input_type.get() != "text":
self.Entry_Fontdir.configure(state="disabled")
self.Fontdir.configure(state="disabled")
@@ -8519,21 +8557,18 @@
self.Label_cutter_type = Label(vcarve_settings,text="Cutter Type")
self.Label_cutter_type.place(x=xd_label_L, y=D_Yloc, width=w_label, height=21)
- self.Radio_Type_VBIT = Radiobutton(vcarve_settings,text="V-Bit", value="VBIT",
- width="100", anchor=W)
- self.Radio_Type_VBIT.place(x=xd_entry_L, y=D_Yloc, width=w_label, height=21)
+ self.Radio_Type_VBIT = Radiobutton(vcarve_settings,text="V-Bit", value="VBIT", anchor=W)
+ self.Radio_Type_VBIT.place(x=xd_entry_L, y=D_Yloc, height=21)
self.Radio_Type_VBIT.configure(variable=self.bit_shape)
D_Yloc=D_Yloc+24
- self.Radio_Type_BALL = Radiobutton(vcarve_settings,text="Ball Nose", value="BALL",
- width="100", anchor=W)
- self.Radio_Type_BALL.place(x=xd_entry_L, y=D_Yloc, width=w_label, height=21)
+ self.Radio_Type_BALL = Radiobutton(vcarve_settings,text="Ball Nose", value="BALL", anchor=W)
+ self.Radio_Type_BALL.place(x=xd_entry_L, y=D_Yloc, height=21)
self.Radio_Type_BALL.configure(variable=self.bit_shape)
D_Yloc=D_Yloc+24
- self.Radio_Type_STRAIGHT = Radiobutton(vcarve_settings,text="Straight", value="FLAT",
- width="100", anchor=W)
- self.Radio_Type_STRAIGHT.place(x=xd_entry_L, y=D_Yloc, width=w_label, height=21)
+ self.Radio_Type_STRAIGHT = Radiobutton(vcarve_settings,text="Straight", value="FLAT", anchor=W)
+ self.Radio_Type_STRAIGHT.place(x=xd_entry_L, y=D_Yloc, height=21)
self.Radio_Type_STRAIGHT.configure(variable=self.bit_shape)
self.bit_shape.trace_variable("w", self.Entry_Bit_Shape_var_Callback)
@@ -8627,7 +8662,7 @@
self.Label_BoxGap_u.place(x=w_label+x_radio_offset+175, y=D_Yloc, width=100, height=21)
self.GEN_Reload = Button(vcarve_settings,text="Recalculate")
- self.GEN_Reload.place(x=580-10, y=D_Yloc, width=90, height=25, anchor="ne")
+ self.GEN_Reload.place(x=580-10, y=D_Yloc, height=25, anchor="ne")
self.GEN_Reload.bind("<ButtonRelease-1>", self.Recalculate_Click)
D_Yloc=D_Yloc+D_dY+12
@@ -8734,8 +8769,8 @@
self.Label_clean = Label(vcarve_settings,text="Cleanup Operations")
self.Label_clean.place(x=center_loc, y=D_Yloc, width=w_label, height=21,anchor=CENTER)
- self.CLEAN_Recalculate = Button(vcarve_settings,text="Calculate\nCleanup", command=self.CLEAN_Recalculate_Click)
- self.CLEAN_Recalculate.place(x=right_but_loc, y=D_Yloc, width=width_cb, height=height_cb*1.5, anchor="ne")
+ self.CLEAN_Recalculate = Button(vcarve_settings,text="Calculate Cleanup", command=self.CLEAN_Recalculate_Click)
+ self.CLEAN_Recalculate.place(x=right_but_loc, y=D_Yloc, height=height_cb*1.5, anchor="ne")
D_Yloc=D_Yloc+D_dY
self.Label_CLEAN_DIA = Label(vcarve_settings,text="Cleanup Cut Diameter")
@@ -8848,7 +8883,7 @@
Xbut=int(vcarve_settings.winfo_width()/2)
self.VCARVE_Recalculate = Button(vcarve_settings,text="Calculate V-Carve", command=self.VCARVE_Recalculate_Click)
- self.VCARVE_Recalculate.place(x=Xbut, y=Ybut, width=130, height=30, anchor="e")
+ self.VCARVE_Recalculate.place(x=Xbut, y=Ybut, height=30, anchor="e")
if self.cut_type.get() == "v-carve":
@@ -9310,13 +9345,14 @@
app.master.title("F-Engrave V"+version)
app.master.iconname("F-Engrave")
app.master.minsize(780,540)
+
try:
try:
import tkFont
- default_font = tkFont.nametofont("TkDefaultFont")
+ default_font = tkFont.nametofont(get_default_font_name())
except:
import tkinter.font
- default_font = tkinter.font.nametofont("TkDefaultFont")
+ default_font = tkinter.font.nametofont(get_default_font_name())
default_font.configure(size=9)
default_font.configure(family='arial')
--- F-Engrave-1.75_src/TTF2CXF_STREAM/Makefile 2013-07-21 23:03:00
+++ TTF2CXF_STREAM/Makefile 2024-01-08 17:57:26
@@ -2,9 +2,22 @@
# Makefile for TTF2CXF_STREAM
# Date: 6/28/2013
+ifeq ($(OS),Windows_NT)
+ TARGET=win
+else
+ UNAME_S := $(shell uname -s)
+ ifeq ($(UNAME_S),Linux)
+ TARGET=linux
+ endif
+ ifeq ($(UNAME_S),Darwin)
+ TARGET=osx
+ endif
+endif
+
WIN_BASEDIR = freetype-2.3.5-1-lib
+MAC_FREETYPE = $(shell brew --prefix freetype)
-all: linux
+all: $(TARGET)
linux:
g++ -o ttf2cxf_stream ttf2cxf_stream.cpp -lm -I/usr/include/freetype2 -lfreetype
@@ -27,4 +40,9 @@
-L$(WIN_BASEDIR)/lib \
$(WIN_BASEDIR)/lib/freetype.lib
+osx:
+ g++ -o ttf2cxf_stream ttf2cxf_stream.cpp -lm -I$(MAC_FREETYPE)/include/freetype2 -L$(MAC_FREETYPE)/lib -lfreetype
+clean:
+ -@rm ttf2cxf_stream
+