revealer plugin: move font initialisation to earlier
Co-authored-by: SomberNight <somber.night@protonmail.com>
This commit is contained in:
committed by
SomberNight
parent
c187f64508
commit
32c97145ef
@@ -19,6 +19,7 @@ import traceback
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import sys
|
import sys
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import qrcode
|
import qrcode
|
||||||
from PyQt5.QtPrintSupport import QPrinter
|
from PyQt5.QtPrintSupport import QPrinter
|
||||||
@@ -39,6 +40,10 @@ from electrum.gui.qt.main_window import StatusBarButton
|
|||||||
from .revealer import RevealerPlugin
|
from .revealer import RevealerPlugin
|
||||||
|
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from electrum.gui.qt import ElectrumGui
|
||||||
|
|
||||||
|
|
||||||
class Plugin(RevealerPlugin):
|
class Plugin(RevealerPlugin):
|
||||||
|
|
||||||
MAX_PLAINTEXT_LEN = 189 # chars
|
MAX_PLAINTEXT_LEN = 189 # chars
|
||||||
@@ -63,6 +68,16 @@ class Plugin(RevealerPlugin):
|
|||||||
make_dir(self.base_dir)
|
make_dir(self.base_dir)
|
||||||
|
|
||||||
self.extension = False
|
self.extension = False
|
||||||
|
self._init_qt_received = False
|
||||||
|
|
||||||
|
@hook
|
||||||
|
def init_qt(self, gui: 'ElectrumGui'):
|
||||||
|
if self._init_qt_received: # only need/want the first signal
|
||||||
|
return
|
||||||
|
self._init_qt_received = True
|
||||||
|
# load custom fonts (note: here, and not in __init__, as it needs the QApplication to be created)
|
||||||
|
QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'SourceSans3-Bold.otf'))
|
||||||
|
QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'DejaVuSansMono-Bold.ttf'))
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def create_status_bar(self, sb):
|
def create_status_bar(self, sb):
|
||||||
@@ -402,7 +417,6 @@ class Plugin(RevealerPlugin):
|
|||||||
bitmap.fill(Qt.white)
|
bitmap.fill(Qt.white)
|
||||||
painter = QPainter()
|
painter = QPainter()
|
||||||
painter.begin(bitmap)
|
painter.begin(bitmap)
|
||||||
QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'SourceSans3-Bold.otf'))
|
|
||||||
if len(txt) < 102 :
|
if len(txt) < 102 :
|
||||||
fontsize = 15
|
fontsize = 15
|
||||||
linespace = 15
|
linespace = 15
|
||||||
@@ -548,13 +562,13 @@ class Plugin(RevealerPlugin):
|
|||||||
painter = QPainter()
|
painter = QPainter()
|
||||||
painter.begin(printer)
|
painter.begin(printer)
|
||||||
painter.drawImage(553,533, image)
|
painter.drawImage(553,533, image)
|
||||||
font = QFont('Source Sans Pro', 10, QFont.Bold)
|
font = QFont('Source Sans 3', 10, QFont.Bold)
|
||||||
painter.setFont(font)
|
painter.setFont(font)
|
||||||
painter.drawText(254,277, _("Calibration sheet"))
|
painter.drawText(254,277, _("Calibration sheet"))
|
||||||
font = QFont('Source Sans Pro', 7, QFont.Bold)
|
font = QFont('Source Sans 3', 7, QFont.Bold)
|
||||||
painter.setFont(font)
|
painter.setFont(font)
|
||||||
painter.drawText(600,2077, _("Instructions:"))
|
painter.drawText(600,2077, _("Instructions:"))
|
||||||
font = QFont('Source Sans Pro', 7, QFont.Normal)
|
font = QFont("", 7, QFont.Normal)
|
||||||
painter.setFont(font)
|
painter.setFont(font)
|
||||||
painter.drawText(700, 2177, _("1. Place this paper on a flat and well iluminated surface."))
|
painter.drawText(700, 2177, _("1. Place this paper on a flat and well iluminated surface."))
|
||||||
painter.drawText(700, 2277, _("2. Align your Revealer borderlines to the dashed lines on the top and left."))
|
painter.drawText(700, 2277, _("2. Align your Revealer borderlines to the dashed lines on the top and left."))
|
||||||
@@ -644,7 +658,6 @@ class Plugin(RevealerPlugin):
|
|||||||
|
|
||||||
#print code
|
#print code
|
||||||
f_size = 37
|
f_size = 37
|
||||||
QFontDatabase.addApplicationFont(os.path.join(os.path.dirname(__file__), 'DejaVuSansMono-Bold.ttf'))
|
|
||||||
font = QFont("DejaVu Sans Mono", f_size-11, QFont.Bold)
|
font = QFont("DejaVu Sans Mono", f_size-11, QFont.Bold)
|
||||||
font.setPixelSize(35)
|
font.setPixelSize(35)
|
||||||
painter.setFont(font)
|
painter.setFont(font)
|
||||||
|
|||||||
Reference in New Issue
Block a user