From 0f88a78639fd5d9f7c0f1b8a55e3b842b84faf8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Wed, 11 Sep 2019 15:33:15 +0200 Subject: [PATCH] libgui/GuiCanvasWxBackend.py:resize(): load font named by fontName instead of wx.FONTFAMILY_TELETYPE. libgui/GuiCanvasWxBackend.py:__init__(): receive & set font{Name,PathName}. libgui/GuiCanvasWxBackend.py:__init__(): call AddFontResourceW() in lieu of WxPython support FOR ANYTHING THAT GOES BEYOND BEING A BLOODY NON-STOP HINDRANCE. --- libgui/GuiCanvasWxBackend.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libgui/GuiCanvasWxBackend.py b/libgui/GuiCanvasWxBackend.py index a26ca88..7839ce8 100644 --- a/libgui/GuiCanvasWxBackend.py +++ b/libgui/GuiCanvasWxBackend.py @@ -4,8 +4,9 @@ # Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz # +from ctypes import * from GuiCanvasColours import Colours -import math, wx +import math, os, wx class GuiBufferedDC(wx.MemoryDC): # {{{ __del__(self) @@ -145,7 +146,7 @@ class GuiCanvasWxBackend(): oldDc.SelectObject(wx.NullBitmap) self.canvasBitmap.Destroy(); self.canvasBitmap = newBitmap; self.canvasSize, self.cellSize = canvasSize, cellSize - self._font = wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) + self._font = wx.TheFontList.FindOrCreateFont(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, self.fontName) # }}} # {{{ xlateEventPoint(self, event, eventDc, viewRect) def xlateEventPoint(self, event, eventDc, viewRect): @@ -163,10 +164,11 @@ class GuiCanvasWxBackend(): # }}} # - # __init__(self, canvasSize, cellSize): initialisation method - def __init__(self, canvasSize, cellSize): + # __init__(self, canvasSize, cellSize, fontName="Dejavu Sans Mono", fontPathName=os.path.join("assets", "fonts", "DejaVuSansMono.ttf")): initialisation method + def __init__(self, canvasSize, cellSize, fontName="Dejavu Sans Mono", fontPathName=os.path.join("assets", "fonts", "DejaVuSansMono.ttf")): self._brushes, self._font, self._lastBrush, self._lastPen, self._pens = None, None, None, None, None - self.canvasBitmap, self.cellSize = None, None + self.canvasBitmap, self.cellSize, self.fontName, self.fontPathName = None, None, fontName, fontPathName + WinDLL("gdi32.dll").AddFontResourceW(self.fontPathName.encode("utf16")) self._initBrushesAndPens(); self.resize(canvasSize, cellSize); # vim:expandtab foldmethod=marker sw=4 ts=4 tw=120