def setfont(self, fontkey): if fontkey == '': fontkey = 'Times-Roman 12' elif ' ' not in fontkey: fontkey = fontkey + ' 12' if fontkey == self.fontkey: return if self.fontcache.has_key(fontkey): handle = self.fontcache[fontkey] else: import string i = string.index(fontkey, ' ') name, sizestr = fontkey[:i], fontkey[i:] size = eval(sizestr) key1 = name + ' 1' key = name + ' ' + `size` # NB key may differ from fontkey! if self.fontcache.has_key(key): handle = self.fontcache[key] else: if self.fontcache.has_key(key1): handle = self.fontcache[key1] else: import fm handle = fm.findfont(name) self.fontcache[key1] = handle handle = handle.scalefont(size) self.fontcache[fontkey] = \ self.fontcache[key] = handle self.fontkey = fontkey if self.fonthandle <> handle: self.fonthandle = handle self.fontinfo = handle.getfontinfo() handle.setfont()
def setfont(self, fontkey): if fontkey == '': fontkey = 'Times-Roman 12' elif ' ' not in fontkey: fontkey = fontkey + ' 12' if fontkey == self.fontkey: return if self.fontcache.has_key(fontkey): handle = self.fontcache[fontkey] else: import string i = string.index(fontkey, ' ') name, sizestr = fontkey[:i], fontkey[i:] size = eval(sizestr) key1 = name + ' 1' key = name + ' ' + ` size ` # NB key may differ from fontkey! if self.fontcache.has_key(key): handle = self.fontcache[key] else: if self.fontcache.has_key(key1): handle = self.fontcache[key1] else: import fm handle = fm.findfont(name) self.fontcache[key1] = handle handle = handle.scalefont(size) self.fontcache[fontkey] = \ self.fontcache[key] = handle self.fontkey = fontkey if self.fonthandle <> handle: self.fonthandle = handle self.fontinfo = handle.getfontinfo() handle.setfont()
G = Struct() # G.queue = [] # Pending STDWIN events G.drawqueue = [] # Windows that need WE_REDRAW G.windowmap = {} # Map window id to window object G.windowmap['0'] = None # For convenience G.focus = None # Input focus G.fg = BLACK # Foreground color G.bg = WHITE # Background color G.def_size = 0, 0 # Default window size G.def_pos = 0, 0 # Default window position # G.size = DEF_SIZE G.font = fm.findfont(DEF_FONT).scalefont(G.size) # Initialize GL # gl.foreground() gl.noport() dummygid = gl.winopen('') # Ask for all sorts of events # # Both REDRAW (= resize and/or redraw!) and INPUTCHANGE are implicitly queued #qdevice(REDRAW) #qdevice(INPUTCHANGE) # # Keyboard gl.qdevice(KEYBD)
def setfont(fontname): G.font = fm.findfont(fontname).scalefont(G.size)
# Text formatting abstractions
def setfont(self, fontname): self.font = fm.findfont(fontname).scalefont(self.size)
G = Struct() # G.queue = [] # Pending STDWIN events G.drawqueue = [] # Windows that need WE_REDRAW G.windowmap = {} # Map window id to window object G.windowmap["0"] = None # For convenience G.focus = None # Input focus G.fg = BLACK # Foreground color G.bg = WHITE # Background color G.def_size = 0, 0 # Default window size G.def_pos = 0, 0 # Default window position # G.size = DEF_SIZE G.font = fm.findfont(DEF_FONT).scalefont(G.size) # Initialize GL # gl.foreground() gl.noport() dummygid = gl.winopen("") # Ask for all sorts of events # # Both REDRAW (= resize and/or redraw!) and INPUTCHANGE are implicitly queued # qdevice(REDRAW) # qdevice(INPUTCHANGE) # # Keyboard