More files moved
This commit is contained in:
+33
-23
@@ -3,37 +3,47 @@
|
||||
|
||||
import sys
|
||||
from PyQt4 import Qt, QtGui
|
||||
from wx import Width
|
||||
|
||||
chars = u""" !"#$%&'()*+, ./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} """
|
||||
chars = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~ ≥→←↑↓ △Ⓘ"""
|
||||
|
||||
font = sys.argv[1]
|
||||
size = int(sys.argv[2])
|
||||
filename = sys.argv[3]
|
||||
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
font = QtGui.QFont(font)
|
||||
font.setBold(True)
|
||||
font.setPointSize(size)
|
||||
metrics = QtGui.QFontMetrics(font)
|
||||
|
||||
width = 0
|
||||
for c in chars:
|
||||
rect = metrics.boundingRect(c)
|
||||
if rect.width() > width:
|
||||
width = rect.width()
|
||||
def getCharWidth():
|
||||
width = 0
|
||||
for c in chars:
|
||||
rect = metrics.boundingRect(c)
|
||||
if rect.width() > width:
|
||||
width = rect.width()
|
||||
return width
|
||||
|
||||
image = QtGui.QImage(width*len(chars), size+4, QtGui.QImage.Format_RGB32)
|
||||
image.fill(0xffffff)
|
||||
painter = QtGui.QPainter()
|
||||
painter.begin(image)
|
||||
painter.setFont(font)
|
||||
for i, c in enumerate(chars):
|
||||
rect = metrics.boundingRect(c)
|
||||
if i == 0:
|
||||
rect.setWidth(4)
|
||||
painter.drawText(width*i-rect.left(), size+1, c)
|
||||
for j in range(rect.width(), width):
|
||||
painter.drawLine(width*i+j, 0, width*i+j, width)
|
||||
painter.end()
|
||||
image.save(filename)
|
||||
width = getCharWidth()
|
||||
|
||||
def createFontBitmap(filename, foreground, background):
|
||||
image = QtGui.QImage(width*len(chars), size+4, QtGui.QImage.Format_RGB32)
|
||||
image.fill(background)
|
||||
painter = QtGui.QPainter()
|
||||
painter.begin(image)
|
||||
painter.setFont(font)
|
||||
pen = QtGui.QPen(foreground)
|
||||
painter.setPen(pen)
|
||||
for i, c in enumerate(chars):
|
||||
rect = metrics.boundingRect(c)
|
||||
if i == 0:
|
||||
rect.setWidth(4)
|
||||
elif i == 14:
|
||||
rect.setLeft(rect.left()+1)
|
||||
rect.setWidth(1)
|
||||
painter.drawText(width*i-rect.left(), size+1, c)
|
||||
for j in range(rect.width(), width):
|
||||
painter.drawLine(width*i+j, 0, width*i+j, size+4)
|
||||
painter.end()
|
||||
image.save(filename)
|
||||
|
||||
if len(sys.argv) == 4:
|
||||
createFontBitmap(sys.argv[3], QtGui.QColor(0x00, 0x00, 0x00), QtGui.QColor(0xFF, 0xFF, 0xFF))
|
||||
|
||||
Reference in New Issue
Block a user