Re: [PyOpenGL-Users] Re: any font fns on the horizon? (in Linux)
Brought to you by:
mcfletch
From: <mi...@na...> - 2003-09-21 07:09:54
|
On Sun, Sep 21, 2003 at 12:06:54AM -0400, Maciej Kalisiak wrote: > On Sat, Sep 20, 2003 at 09:08:18PM -0400, mi...@na... wrote: > > I wrote a relatively simple but effective "GLText" module for pybzengine. > > It's texture based, generally produces nicely hinted output, and has some > > Unicode support. > > > > No documentation, but there is LGPL'ed source at > > http://navi.picogui.org/svn/misc/trunk/pybzengine/BZEngine/UI/GLText.py > > Wow, very nice! I just took it for a spin. A bit of tweaking to disentangle > it from rest of BZEngine, but works like a charm now. I like that this > approach uses multiple textures per font; texfont was limited to a > single texture per font. Spiffy. > > I would encourage you strongly to refactor this a bit, to make it a > separate, stand-alone package, since it seems terribly useful and quite > robust. It seems like little work. Not only separate it from BZEngine, > but hopefully from pygame as well, to give it the largest application Patches welcome :) I'll probably get to this eventually, but currently I'm still at the stage of separating pybzengine from pybzflag so I can use it in another project easily. > area. I think pygame could be used to generate the fonts as a > standalone utility, just like in genfont in "texfonts", which could then > be pickled for use in apps which don't want to import pygame (e.g., in > my stuff I'm trying to limit the number of packages it relies on...). That would be a nice feature. With pybzengine this might already be possible, since it's Texture class is pickle-friendly. Would take some more work to make this work if GLText was standalone. For my own purposes I'd rather just keep this as-is, since the relevant parts of pybzengine are small and fairly general-purpose. > > I'm not super familiar with fonts. Could you elaborate a tiny bit on > some of the terms you use in the head comment in GLText.py? I'm > wondering about the full meaning of "proper hinting" and "escapement". Hinting is the process of tweaking a font's rendering a bit so stems of letters, for example, line up better on a pixel grid. Without hinting, fonts generally look a bit blurry and are hard to read at normal-looking sizes. GLText can keep fonts rendered at multiple sizes so commonly used sizes can be rendered with a one to one correspondance between pixels and texels. These common sizes can therefore be rendered with correct hinting rather than looking a little blurry due to relying on OpenGL's trilinear filtering. In the applications I've used this technique for, it has worked nicely. Small fonts are used at the same size they were rendered at, giving high quality output. Large fonts are scaled using trilinear filtering, but lack of hinting isn't noticeable. > > I'm not too familiar with fonts in pygame, but my understanding is that > it only handles truetype fonts at the moment. Do you know if adding > support for general X11 fonts is in the plans, or even how hard a task > that is? (Murphy's Law says that soon enough I'll find that I must have > a given font, and it won't be .ttf... :) Well, GLText uses pygame's font capabilities, which is just a python binding for SDL_ttf. SDL_ttf is a simple wrapper for freetype, so it will handle any font format freetype can. This includes truetype, Postscript Type1, .pcf, windows fonts, and probably more. The downside of using SDL_ttf is that it hides most of the glyph metrics stored in the original font. The glyphs GLText stores will be padded to the font's line height rather than stored in tightly fitting bounding boxes. This wastes a little VRAM, but prevents requiring real freetype bindings. --Micah > > -- > "If you sit down at a poker game and don't see a sucker, get up. You're > the sucker." > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users |