def test_size(self):
f = pygame_font.Font(None, 20)
text = as_unicode("Xg")
size = f.size(text)
w, h = size
self.assert_(isinstance(w, int) and isinstance(h, int))
s = f.render(text, False, (255, 255, 255))
self.assert_(size == s.get_size())
btext = text.encode("ascii")
self.assert_(f.size(btext) == size)
text = as_unicode(r"\u212A")
btext = text.encode("UTF-16")[2:] # Keep the byte order consistent.
bsize = f.size(btext)
try:
size = f.size(text)
except pygame.error:
pass
else:
self.assert_(size != bsize)
评论列表
文章目录