Text rendering in Pygame + OpenGL
2006-05-12 09:21:41
Have spent the last couple of nights putting together a text rendering library
for Pygame/PyOpenGL. The initial code base was pulled out of Nelly, but bears
little resemblance any more.
One of the goals is to make the library require only libraries most Pygame users
ordinarily use -- for most gamers, text rendering is not a critical enough
feature to bloat a package with another dependency. The current version of
Pygame does not expose enough font metrics, so these arrays are pulled directly
out of the Truetype file. Freetype could have been used, but I can't imagine
gamers having the patience to download and install it for a game.
So far, rendering does correct character advance and pairwise kerning. Before
the first release I'd like to add
* style character runs (marked-up text),
* first-fit line breaking,
* left, right and center alignment taking into account left/right-side bearing,
and for possibly for later:
* common temporal effects (transitions),
* text-editing cursor management,
* Knuth/Plass optimal line-breaking (and hyphenation?),
* ligature substitution.
I would just like to add that the Truetype format-4 character encoding table is
the most obfuscated, badly-documented file format in the world, and that the
people responsible for its existence should beg eternal forgiveness.
Children
2006-04-29 00:10:46
The last couple of weeks I've been stressed from what seems like unrelenting
work -- reading papers for class, writing assignment marking guides, organising
meetings, responding to emails. So I was sitting here contemplating watching
another Buffy episode, dreading the weeks ahead that will doubtless be filled
with more of the same, and thinking back on the week of no accomplishments.
Well, I did find a happy time: one of my tute classes (I won't say which one).
These guys started out the year fulfilling the computer science student
stereotype; late to class, uninterested, unwilling to participate in any
discussion, and more or less unable to think critically about the work. Now
we're in week eight and they've become my model students. They were all on-time,
asked intelligent questions, did their best to complete the tasks I set them,
helped each other out. A tutor could not ask for an easier time!
I'd love to think this is the result of my superior teaching skills (Ha!), but
in all likeliness they've just grown up. Or maybe they got all scared about
failing the assignment.
Free time
2006-04-21 19:02:22
I mistranscribed the due date for the first draft of my thesis proposal into my
diary, meaning I wrote the whole thing between the hours of 11pm and 7am this
morning. Not quite the way I wanted to do it, but on the plus side, I now have a
whole weekend free that I would otherwise have spent writing!
My
PyWeek entry took first place in the peer-judging review, which was
surprising. Many, many thanks to Richard for putting in the huge amount of work
that was needed to organise and run the event, and to everyone who voted for
*Nelly's Rooftop*. I plan to polish off the entry this weekend and post it on
the
PyGame website. On the todo list:
* Fixing some UI issues; e.g. making it easier to rotate blocks, and
drag-and-drop straight from the tool shelf.
* Replace the Lemmings-inspired password-protected level system with a more
traditional level selection screen.
* Add some more difficult levels.
Some people suggested adding a time-limit, or score based on the amount of time
taken. Sorry, that idea just doesn't appeal to me -- the game consists of gentle
steam and dripping water -- it's *supposed* to be calming.
Dream consipiracy
2006-04-16 10:08:28
If you've seen the film Waking Life you'll remember the scene where the
protagonist is told he can tell if he's dreaming by trying to adjust light
levels, i.e. by flipping a light switch.
Last night I tried doing exactly that in my dream but was foiled by a busted
globe. I had one handy, but was too afraid to change it for fear of being
electrocuted again!
My dream of lucidness will have to wait for another day, I guess.
Dusk sessions
2006-04-14 16:15:43
I finally got hold of Chanel Cole's (of Australian Idol fame) album. Turns out
it's not being stocked by any of the JB stores I frequent because their stock
system erroneously believes there are five copies sitting on the shelves.
According to the man with the computer, it sold very well in the first week after
release and then sales suddenly dropped off, presumably because no-one checked to
see if the supposed unmoving stock actually existed.
HMV had a copy, albeit in the R&B section -- cue ironic note about Chanel's
distaste for hip-hop which got her voted off the show. It's labelled as a
"dance" album, which really means it's a rip-off of the
Portishead/Avalanches style. Strictly speaking it's not Chanel's album: the band
is called Spook and also consists of Daniel, Chanel's off-pitch fellow Idol
boyfriend, and Statler and Waldorf, a partnership of electronic minds who are
clearly the sound behind the album.
And the sound is basically of Statler and Waldorf. Chanel's vocals are
ignorable, Daniel is (thankfully) not to be heard, which just leaves a very
generic, bland, contemporary electronic sound that would suit any cafe's sound
system. It's hard to get excited about, and Chanel does sing beatifully, but she
is wasting away on this album. Let's hope she finds some musical buddies soon
and puts out a real vocal album next time.
Richard writes:
Cool, I can't wait.