Issue #1608 start - What do you think?
This commit is contained in:
+11
-15
@@ -6,15 +6,9 @@ from PyQt4 import Qt, QtGui
|
||||
|
||||
chars = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~ ≥→←↑↓ △Ⓘ"""
|
||||
|
||||
font = sys.argv[1]
|
||||
size = int(sys.argv[2])
|
||||
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
font = QtGui.QFont(font)
|
||||
font.setPointSize(size)
|
||||
metrics = QtGui.QFontMetrics(font)
|
||||
|
||||
def getCharWidth():
|
||||
def getCharWidth(metrics):
|
||||
width = 0
|
||||
for c in chars:
|
||||
rect = metrics.boundingRect(c)
|
||||
@@ -22,10 +16,12 @@ def getCharWidth():
|
||||
width = rect.width()
|
||||
return width
|
||||
|
||||
width = getCharWidth()
|
||||
|
||||
def createFontBitmap(filename, foreground, background):
|
||||
image = QtGui.QImage(width*len(chars), size+4, QtGui.QImage.Format_RGB32)
|
||||
def createFontBitmap(filename, fontname, fontsize, foreground, background):
|
||||
font = QtGui.QFont(fontname)
|
||||
font.setPointSize(fontsize)
|
||||
metrics = QtGui.QFontMetrics(font)
|
||||
width = getCharWidth(metrics)
|
||||
image = QtGui.QImage(width*len(chars), fontsize+4, QtGui.QImage.Format_RGB32)
|
||||
image.fill(background)
|
||||
painter = QtGui.QPainter()
|
||||
painter.begin(image)
|
||||
@@ -38,13 +34,13 @@ def createFontBitmap(filename, foreground, background):
|
||||
rect.setWidth(4)
|
||||
elif i == 14:
|
||||
rect.setWidth(1)
|
||||
painter.drawPoint(width*i, size);
|
||||
painter.drawPoint(width*i, fontsize);
|
||||
else:
|
||||
painter.drawText(width*i-rect.left(), size+1, c)
|
||||
painter.drawText(width*i-rect.left(), fontsize+1, c)
|
||||
for j in range(rect.width(), width):
|
||||
painter.drawLine(width*i+j, 0, width*i+j, size+4)
|
||||
painter.drawLine(width*i+j, 0, width*i+j, fontsize+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))
|
||||
createFontBitmap(sys.argv[3], sys.argv[1], int(sys.argv[2]), QtGui.QColor(0x00, 0x00, 0x00), QtGui.QColor(0xFF, 0xFF, 0xFF))
|
||||
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from PyQt4 import Qt, QtGui
|
||||
|
||||
menu = [ "radio_setup", "model_select", "model_settings", "model_checklist", "files", "version" ]
|
||||
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
image = QtGui.QImage(24*8, 24, QtGui.QImage.Format_RGB32)
|
||||
image.fill(QtGui.QColor(255, 255, 255))
|
||||
painter = QtGui.QPainter()
|
||||
painter.begin(image)
|
||||
for i, str in enumerate(menu):
|
||||
icon = QtGui.QImage("../src/bitmaps/Taranis/std/%s.png" % str)
|
||||
painter.drawImage(Qt.QPoint(24*i, 0), icon)
|
||||
painter.end()
|
||||
image.save("../src/bitmaps/Taranis/mainmenu.png")
|
||||
Reference in New Issue
Block a user