partiallydisassembled.net

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.

Richard writes:

Cool, I can't wait.

Thorben writes:

can you show me how to travel in time, too? :-) (seems a bit like you coded abbreviations for months and forgot "May"?)

Alex writes:

Whoops. :-)

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.

Rachel writes:

They grew up in just eight weeks? Now that's dedication to an assignment. (Wish I could grow up in just eight weeks. Is there a pill or an exercise regime?)

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.

Thorben writes:

I managed to become lucid in a dream by performing so called "reality checks" (i suppose you know that term) regularly in waking life... They are supposed to become a habit in real life, so that you even start doing them in you dreams. And that's when you suddenly realize, that you are dreaming... The reality check that worked best for me is jumping into the air... While this may look foolish in real life (i always found proper explanations for my peculiar behavior, mostly it was nothing but the truth: "hey, sorry, i am just doing a reality check"), you will end up kind of floating gently back to the ground (or even staying in the air), if you are indeed in a dream. The reason for this is that one can't dream of hitting the ground. (Ever dreamed about falling down deep?) If you don't like the idea of jumping around from time to time in waking life, try to look at your watch and tell the time. If you are in a dream, you would at least have considerable difficulties doing that. If you can nevertheless tell the time, look away for a second and then look back to your watch. The time should have changed significantly. Drop me a line, if you became lucid successfully, will you? Thorben PS & OT: I REALLY enjoyed Nelly’s Rooftop, felt quite like the incredible machine, i played it through, although levels 9,10,11 where really hard. the rest was easy, and most of the time i didn't use all parts

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.
login