Pyglet only seems to use points. Is there a way to convert easily? Surely there must be a simple way because it's something obviously important, to be able to use pixels for text height.
class Font():
def __init__(self,font,size):
self.size = size
self.font = font
def return_surface(self,label):
surface = Surface((label.content_width,label.content_height))
surface.set_background_alpha(0)
setup_framebuffer(surface,True)
label.draw()
end_framebuffer()
return surface
def render(self,text,colour):
colour = fix_colour(colour)
label = pyglet.text.Label(text,font_name=self.font,font_size=self.size,color = colour,dpi=72)
return self.return_surface(label)
def render_wordwrap(self,text,width,colour,alignment):
if alignment == 0:
alignment = 'left'
elif alignment == 1:
alignment = 'center'
else:
alignment = 'right'
colour = fix_colour(colour)
label = pyglet.text.Label(text,font_name=self.font,font_size=self.size,color = colour,width=width,halign=alignment, multiline=True,dpi=72)
return self.return_surface(label)