Beispiel #1
0
class GLWriter(GLFontCache):
    #
    # NOTES:
    # (1) Use gl.ortho2 to use X pixel coordinates!
    #
    def text(self, (h, v), text):
        import gl, fm
        gl.cmov2i(h, v + self.fontinfo[6] - self.fontinfo[3])
        fm.prstr(text)
Beispiel #2
0
class GLFormatter(AbstractFormatter):
    #
    # NOTES:
    # (1) Use gl.ortho2 to use X pixel coordinates!
    # (2) Call setfont with some font handle immediately after initializing
    #
    def init(self, left, top, right):
        self.fontkey = None
        self.fonthandle = None
        self.fontinfo = None
        self.fontcache = {}
        return AbstractFormatter.init(self, left, top, right)

    #
    def d_text(self, (h, v), text):
        import gl, fm
        gl.cmov2i(h, v + self.fontinfo[6] - self.fontinfo[3])
        fm.prstr(text)
Beispiel #3
0
	#
	def text(self, (h, v), string):
		#print 'text', ((h, v), string)
		if h < 0:
			# If the point is outside the window
			# the whole string isn't drawn.
			# Skip the beginning of the string.
			# XXX What if the font is bigger than 20 pixels?
			i, n = 0, len(string)
			while h < -MASK and i < n:
				h = h + self.font.getstrwidth(string[i])
				i = i + 1
			string = string[i:]
		gl.cmov2(h, v + self.baseline())
		self.font.setfont()
		fm.prstr(string)
	#
	def shade(self, (h, v), percent):
		pass # XXX
	#
	def baseline(self):
		(printermatched, fixed_width, xorig, yorig, xsize, ysize, \
			height, nglyphs) = self.font.getfontinfo()
		return height - yorig
	#
	def lineheight(self):
		(printermatched, fixed_width, xorig, yorig, xsize, ysize, \
			height, nglyphs) = self.font.getfontinfo()
		return height
	#
	def textbreak(self, string, width):
Beispiel #4
0
# Text formatting abstractions