summaryrefslogtreecommitdiffstats
path: root/Demo/sgi/gl/glstdwin/fontchart.py
blob: 6b58f12a9c9254d2fe8f4e5911078576f9ea5903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import stdwingl

import stdwin
from stdwinevents import *

def main():
	size = 12
	w = stdwin.open('Font chart ' + `size`)
	while 1:
		type, window, detail = stdwin.getevent()
		if type == WE_CLOSE:
			break
		if type == WE_DRAW:
			width, height = w.getwinsize()
			d = w.begindrawing()
			d.setsize(size)
			h, v = 0, 0
			for c in range(32, 256):
				ch = chr(c)
				chw = d.textwidth(ch)
				if h + chw > width:
					v = v + d.lineheight()
					h = 0
					if v >= height:
						break
				d.text((h, v), ch)
				h = h + chw
			del d
		if type == WE_MOUSE_UP:
			size = size + 1
			w.settitle('Font chart ' + `size`)
			w.change((0, 0), (2000, 2000))

main()