[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] having problem with font objects in pgs4a ports to android
- To: pygame-users@xxxxxxxx
- Subject: [pygame] having problem with font objects in pgs4a ports to android
- From: tom arnall <kloro2006@xxxxxxxxx>
- Date: Fri, 24 Jul 2015 16:37:05 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Fri, 24 Jul 2015 19:37:09 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=k21ubuNeRLx97g+G6pjQ/miK1G+TCxBDZPATChta9oE=; b=zx8B0GvibOUHfiKTiMDigf5dzAMxrmdnpW27QcNYmLoPJz4HzioprsHpSBp1O9nvQz UbI1cTvV7HQjQ0vfJPSWa7meFcJZjYqkpbbyaltl6fFQNGnJ72KMMuz3OcMGFVpGrRwI LFa4Sa7ydWfY0dXz9AhsV/zTqOmih2WN/CZ5SVb7dAXxofq3zBq68HwLrmqpOv965Pbb KJia0e8oZyy/VRY+gdcSYiKYRmmBU6KmaOMdJPu9tLvu1EgcGo/Swo8aHU3tCZ41zVjP NrW564jTKNvnRC36QW0fA+YGzaylnthV4WD5kjCUq6AJIpW0tA6XdIm7GBGpKTC9XNo8 VRrQ==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
I think I'm making progress on the issue, but I am still having
problems with font rendering. The code below runs on my PC under
Linux, i.e., it prints "hello world" on the window it produces. But
when I make it into an apk with the pgsa-0.9.4 kit and run it on my
phone, it puts garbage on the screen. I posted this item y'day except
I have changed creation of the font object. Instead of using
font.SysFont, I'm using font.Font with argument of a font file name,
as in:
font = pygame.font.Font(âdata/Vera.ttfâ, 25)
No change in results but I think closer to good ones because I read on
the net that SysFont will not work for android ports. It also stands
to reason that it is better to include the data for the font in the
apk.
Again, Iâve put pygame apps on the phone which donât use the Font objects and
they run fine. And this one runs fine under Linux.
====
import pygame, sys, os, random
from pygame.locals import *
import time
try:
import android
except ImportError:
android = None
def stop(interval=3):
print âstopping >> â + str(interval)
time.sleep(interval)
pygame.init()
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
width = 400
height = 400
screen = pygame.display.set_mode((width, height))
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill(WHITE)
surface = pygame.Surface((width,height))
font = pygame.font.Font(âdata/Vera.ttfâ, 25)
itemSurface = font.render(âhello world!â, True, BLACK, WHITE)
surface.blit(itemSurface, (0,0))
background.blit(surface, (0,0))
screen.blit(background,(0,0))
pygame.display.flip()
stop(20)