Treść książki

Przejdź do opcji czytnikaPrzejdź do nawigacjiPrzejdź do informacjiPrzejdź do stopki
ĆWICZENIA
translate-x=self.render-char(
ord(character),character-x,character-y,font-size)
translate-x+=int(0.1*font-size)
character-x+=translate-x
defrender-char(self,ch,sx,sy,font-size):
max-x=0
forpathsinself.--font[ch]:
last=None
forcoordsinpaths:
ifcoords[0]>max-x:max-x=coords[0]
iflast==None:
#Skipfirstpoint.
last=coords
continue
self.--gfx-engine.draw-line(
int(sx+last[0]*font-size),
int(sy+last[1]*font-size),
int(sx+coords[0]*font-size),
int(sy+coords[1]*font-size))
last=coords
returnint(max-x*font-size)
def--read-uint8(self,data):
returnord(data.next())
def--read-float(self,data):
b=""
for-inxrange(4):
b+=data.next()
returnstruct.unpack(">f",b)[0]
deftest-vec-font():
FONT=("eJxNUiFQw0AQTL6BTFUcMg4Zh0z+BQJR0RkEIq6yghlkZR04XOtwrcO1Dp"
"c6XOpwqcMVh2R381+amZ9NLrd3t3tvBhEe93T8ifxjj/27KRHkh91stsQ4"
"ic4e91gU9rbZCef4ruvaDCvkqshbngubZmfT5xfharVm3HbdoWrbPVE570"
"VBrBaLZeAn9nM0EoH4PZ2G40hAzAxZ9pzOaMVxA5Pnq67VCqgcxNSK0jz/"
"wjIBRYg0wr5mmYMiFhPebLYOSuPU3rd7lQFVrajsoywVoyoy/D83whjXq7"
"WbdIdYJstPHDkWTB6ebEfX4JhGpmN0iyzU5hZclmXCO/RlpUnvINFwCUws"
55