PEP8 radio/util/font2png.py
Fix whitespace and indentations, remove semicolons
This commit is contained in:
@@ -12,6 +12,7 @@ for f in glob.glob("fonts/*.ttf"):
|
|||||||
|
|
||||||
chars = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~ ≥→←↑↓↗↘↙↖△"""
|
chars = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~ ≥→←↑↓↗↘↙↖△"""
|
||||||
|
|
||||||
|
|
||||||
def getCharWidth(fontsize, metrics, index):
|
def getCharWidth(fontsize, metrics, index):
|
||||||
if index == 0:
|
if index == 0:
|
||||||
return 4
|
return 4
|
||||||
@@ -24,6 +25,7 @@ def getCharWidth(fontsize, metrics, index):
|
|||||||
else:
|
else:
|
||||||
return rect.width() + 1
|
return rect.width() + 1
|
||||||
|
|
||||||
|
|
||||||
def getFontTopBottom(fontsize, metrics):
|
def getFontTopBottom(fontsize, metrics):
|
||||||
top, bottom = 0, 0
|
top, bottom = 0, 0
|
||||||
for i, c in enumerate(chars):
|
for i, c in enumerate(chars):
|
||||||
@@ -32,12 +34,14 @@ def getFontTopBottom(fontsize, metrics):
|
|||||||
bottom = max(bottom, rect.bottom())
|
bottom = max(bottom, rect.bottom())
|
||||||
return top, bottom
|
return top, bottom
|
||||||
|
|
||||||
|
|
||||||
def getFontWidth(fontsize, metrics):
|
def getFontWidth(fontsize, metrics):
|
||||||
width = 0
|
width = 0
|
||||||
for i, c in enumerate(chars):
|
for i, c in enumerate(chars):
|
||||||
width += getCharWidth(fontsize, metrics, i)
|
width += getCharWidth(fontsize, metrics, i)
|
||||||
return width
|
return width
|
||||||
|
|
||||||
|
|
||||||
def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, background, coordsfile=True):
|
def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, background, coordsfile=True):
|
||||||
coords = []
|
coords = []
|
||||||
font = QtGui.QFont(fontname)
|
font = QtGui.QFont(fontname)
|
||||||
@@ -52,7 +56,7 @@ def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, backgro
|
|||||||
extraFilename = "fonts/extra_%dpx.png" % fontsize
|
extraFilename = "fonts/extra_%dpx.png" % fontsize
|
||||||
extraImage = QtGui.QImage(extraFilename)
|
extraImage = QtGui.QImage(extraFilename)
|
||||||
if extraImage.isNull():
|
if extraImage.isNull():
|
||||||
print "No extra font file", extraFilename
|
print("No extra font file", extraFilename)
|
||||||
extraWidth = 0
|
extraWidth = 0
|
||||||
else:
|
else:
|
||||||
extraWidth = extraImage.size().width()
|
extraWidth = extraImage.size().width()
|
||||||
@@ -69,7 +73,7 @@ def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, backgro
|
|||||||
if i == 0:
|
if i == 0:
|
||||||
pass
|
pass
|
||||||
elif i == 14 and fontsize <= 8:
|
elif i == 14 and fontsize <= 8:
|
||||||
painter.drawPoint(width, fontsize);
|
painter.drawPoint(width, fontsize)
|
||||||
else:
|
else:
|
||||||
rect = metrics.boundingRect(c)
|
rect = metrics.boundingRect(c)
|
||||||
if fontsize >= 24:
|
if fontsize >= 24:
|
||||||
|
|||||||
Reference in New Issue
Block a user