From 2c8fa89edaa8b85077bbdd9ba824ba7fb94f6e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Fri, 13 Sep 2019 10:03:39 +0200 Subject: [PATCH] libgui/GuiCanvasWxBackend.py:{resize,__init__}(): restrict external font loading to Windows (via sym.) assets/text/TODO: updated. --- assets/text/TODO | 2 +- libgui/GuiCanvasWxBackend.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/assets/text/TODO b/assets/text/TODO index 5301720..b279ef2 100644 --- a/assets/text/TODO +++ b/assets/text/TODO @@ -7,7 +7,7 @@ 7) Incremental auto{load,save} & {backup,restore} (needs Settings window) 8) Sprites & scripted (Python?) animation on the basis of asset traits and {composable,parametrised} patterns (metric flow, particle system, rigging, ...) 9) Composition, parametrisation & keying of tools from higher-order operators (brushes, filters, outlines, patterns & shaders) and unit tools -10) GUI: a) switch to GTK b) replace logo w/ canvas panel in About dialogue c) {copy,cut,insert from,paste}, {edit asset in new canvas,import from canvas} +10) GUI: a) switch to GTK b) replace logo w/ canvas panel in About dialogue c) {copy,cut,insert from,paste}, {edit asset in new canvas,import from canvas} d) replace resize buttons w/ {-,edit box,+} buttons & lock button re: ratio (ty lol3) High-priority list: 1) geometric primitives: arrow, circle, cloud/speech bubble, curve, heart, hexagon, line, pentagon, polygon, rhombus, triangle, square, star diff --git a/libgui/GuiCanvasWxBackend.py b/libgui/GuiCanvasWxBackend.py index 780fb20..f3d4748 100644 --- a/libgui/GuiCanvasWxBackend.py +++ b/libgui/GuiCanvasWxBackend.py @@ -6,7 +6,7 @@ from ctypes import * from GuiCanvasColours import Colours -import math, os, wx +import math, os, platform, wx class GuiBufferedDC(wx.MemoryDC): # {{{ __del__(self) @@ -155,7 +155,10 @@ class GuiCanvasWxBackend(): oldDc.SelectObject(wx.NullBitmap) self.canvasBitmap.Destroy(); self.canvasBitmap = newBitmap; self.canvasSize, self.cellSize = canvasSize, cellSize - self._font = wx.TheFontList.FindOrCreateFont(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, self.fontName) + if platform.system() == "Windows": + self._font = wx.TheFontList.FindOrCreateFont(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, self.fontName) + else: + self._font = wx.Font(8, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL) # }}} # {{{ xlateEventPoint(self, event, eventDc, viewRect) def xlateEventPoint(self, event, eventDc, viewRect): @@ -177,7 +180,8 @@ class GuiCanvasWxBackend(): 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, self.fontName, self.fontPathName = None, None, fontName, fontPathName - WinDLL("gdi32.dll").AddFontResourceW(self.fontPathName.encode("utf16")) + if platform.system() == "Windows": + WinDLL("gdi32.dll").AddFontResourceW(self.fontPathName.encode("utf16")) self._initBrushesAndPens(); self.resize(canvasSize, cellSize); # vim:expandtab foldmethod=marker sw=4 ts=4 tw=120