Skip to content

Commit 0322b2b

Browse files
committed
Python 3 compatibility: use print function
In the future, we may want to switch to Python 3 to be able to use things like type annotation (via mypy). The only thing that holds us back is that the Fontforge Python library is Python 2.x-only. But it costs us little to start preparing for the changeover now.
1 parent f430e18 commit 0322b2b

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

dataconvert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division
1+
from __future__ import division, print_function
22

33
"""Library for converting lines and polygons between various formats
44
@@ -95,7 +95,7 @@ def any_to_linestring(pointlist):
9595
try:
9696
return LineString(any_to_polyline(pointlist))
9797
except ValueError:
98-
print str(list(pointlist))
98+
print(str(list(pointlist)))
9999
raise
100100

101101
def any_to_polygon(outside, holes):

extractpoints.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
from __future__ import division
3+
from __future__ import division, print_function
44

55
import fontforge
66
import time
@@ -427,7 +427,7 @@ def find_centerpoint(edgepoint):
427427
# it earlier in the next_point(curpt) call.
428428
start_from = find_centerpoint(curpt)
429429
if start_from is None:
430-
print "find_centerpoint({}) failed...".format(curpt)
430+
print("find_centerpoint({}) failed...".format(curpt))
431431
start_from = curpt
432432
edit_line_after_recording = False
433433
else:
@@ -519,17 +519,17 @@ def create_dotted_font(fname):
519519
glyph = input_font[glyphname]
520520
new_glyph = new_font[glyphname]
521521
new_glyph.clear()
522-
print "Processing glyph at codepoint U+{:04X} named {}".format(glyph.encoding, glyphname)
522+
print("Processing glyph at codepoint U+{:04X} named {}".format(glyph.encoding, glyphname))
523523
glyph.unlinkRef()
524524
copy_glyph(glyph, new_glyph)
525525
font_type = args.output.lower().rsplit('.', 1)[-1]
526526
if font_type == 'sfd':
527527
new_font.save(args.output)
528528
else:
529529
new_font.generate(args.output)
530-
print "Dotted font created as", args.output
530+
print("Dotted font created as", args.output)
531531
if args.visualize:
532-
print "Press any key to exit"
532+
print("Press any key to exit")
533533
import visualization
534534
visualization.wait_for_keypress(args.em, args.zoom)
535535

@@ -546,7 +546,7 @@ def extraction_demo(fname, letter):
546546
glyph = font[codepoint]
547547
glyph.unlinkRef()
548548
dots = extract_dots(glyph, args.visualize)
549-
print "{} dots found".format(len(dots))
549+
print("{} dots found".format(len(dots)))
550550
if args.visualize:
551551
import visualization
552552
visualization.wait_for_keypress(args.em, args.zoom)
@@ -674,9 +674,9 @@ def debug(s, *args, **kwargs):
674674
if not DEBUG:
675675
return
676676
if not args and not kwargs:
677-
print s
677+
print(s)
678678
else:
679-
print s.format(*args, **kwargs)
679+
print(s.format(*args, **kwargs))
680680

681681
def parse_args():
682682
"Parse the arguments the user passed in"

generalfuncs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division
1+
from __future__ import division, print_function
22

33
"""Library for generally useful functions
44

visualization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division
1+
from __future__ import division, print_function
22

33
"""Library for visualizing our results"""
44

@@ -35,7 +35,7 @@ def wait_for_keypress(emsize = 1024, zoom = 1.0):
3535
# Reconstruct glyph coords from screen coords
3636
x = float(x) / zoom
3737
y = emsize-(float(y) / zoom)
38-
print (x, y)
38+
print((x, y))
3939
import sys
4040
sys.stdout.flush()
4141
continue
@@ -126,7 +126,7 @@ def draw_midlines(screen, polylines, midpoints, emsize = 1024, zoom = 1.0, polyl
126126
#for m in midpoints:
127127
#x = int(m[0] * zoom)
128128
#y = int((emsize-m[1]) * zoom)
129-
#print (x, y)
129+
#print((x, y))
130130
#pixel(screen, x, y, midpointcolor)
131131

132132
# Close the polylines loop again prior to drawing

0 commit comments

Comments
 (0)