[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 yr help. I'm very interested in pygame_sdl2 and it
seems to me that porting my game project to it would be fairly simple
and worth the effort as well for future projects. But I shudder at the
delay to my project which I suspect wd be required to create and
master a new packaging environment. And all of it to get some simple
text on the screen. Is it simply the case that pgs4a does not support
font rendering?

Regards,

T



On 7/24/15, Tom Rothamel <tomrothamel.us> wrote:
> Have you tried your entire app under RAPT/pygamesdl2?
>
> The general idea is that pygamesdl should run all pygame games unchanged
> except for the import code. Insofar as it doesn't, that's something we
> should investigate and try fix.
>
> (The one exception is the dropping of support for non-32 bit surfaces,
> which have probably been obsolete for a while now, and complicate
> everything by requiring 4 code paths.)
>
>
> On Fri, Jul 24, 2015 at 8:46 PM tom arnall <kloro2006@xxxxxxxxx> wrote:
>
>> Tom,
>>
>> Thanks again for the help you have been giving me. And thanks of
>> course for your work on pygamesdl2.
>>
>> Is it possible to take just the font rendering capability from
>> pygamesdl 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 pygamesdl is not compatible with python
>> 2.7
>> ?
>>
>> If I use the pygamesdl font rendering, do I need to use RAPT instead
>> of pgsa 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 <tomrothamel.us> 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
>> > pygamesdl 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 stopinterval=3):
>> >> print âstopping >> â + strinterval)
>> >> time.sleepinterval)
>> >>
>> >> pygame.init()
>> >>
>> >> BLACK = (0, 0, 0)
>> >> WHITE = (255, 255, 255)
>> >>
>> >> width = 400
>> >> height = 400
>> >>
>> >> screen = pygame.display.setmode((width, height))
>> >>
>> >> background = pygame.Surfacescreen.getsize())
>> >> 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.blititemSurface, (0,0))
>> >> background.blitsurface, (0,0))
>> >> screen.blitbackground,(0,0))
>> >>
>> >> pygame.display.flip()
>> >>
>> >> stop(20)
>> >>
>> >
>>
>>
>> --
>>
>


-