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)

Reply via email to