[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] having problem with font objects in pgs4a ports to android



Tom,

Thanks again for the help you have been giving me. And thanks of
course for your work on pygame_sdl2.

Is it possible to take just the font rendering capability from
pygame_sdl2 and use it without changing the rest of my application? I
would like to avoid rewriting the application in order to deal with
drawing a line of text

Are there any areas in which pygame_sdl2 is not compatible with python 2.7 ?

If I use the pygame_sdl2 font rendering, do I need to use RAPT instead
of pgs4a for the port to android? (Yes, this is an obviously lazy
question, but please cut me a break on it.)

Thanks in advance for any help you can give me,

Tom Arnall
Baja Norte





On 7/24/15, Tom Rothamel <tom@xxxxxxxxxxx> wrote:
> Have you tried the newer RAPT-based tool? PGS4A is getting very old, hasn't
> been updated for newer android versions. (Part of the reason for
> pygame_sdl2 is that it was easier and more productive to use SDL2 to port
> to Android/iOS than to continue maintaining an Android SDL1 port.)
>
> On Fri, Jul 24, 2015 at 7:37 PM tom arnall <kloro2006@xxxxxxxxx> wrote:
>
>> 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)
>>
>


--