Re: [openglean-devel]Font support.
Status: Beta
Brought to you by:
rkrolib
From: Richard R. <sf...@ol...> - 2005-09-30 13:49:58
|
Varol: I've been looking at your code a little more this morning. It looks like you only read characters in the range 0..255. Have you given much thought yet to supporting large character sets? I'm inclined towards the idea of reading font glyphs more or less on-demand, rather than reading the entire font at once. The difficulties are in finding where as-yet-unread glyphs begin and in rapidly finding glyphs in memory after loading. (Allocating pointers to all possible glyphs in a big array and filling unloaded ones with NULL is probably not a very good solution; even for 16-bit Unicode, on a 32-bit system, that's a quarter of a MB of pointers for every font...) I'm thinking of some kind of hash approach. Take a sequence of primes, where the Nth prime is approximately 2^N. Take the glyph number mod by the prime table size That would be the primary location for already-loaded glyphs. As the table fills, reallocate and re-hash. For unloaded font glyphs, some kind of sparse array could be used to locate known places in a font. For example, after reading the font glyph for 'a', you would know the location of 'b'. (Well, maybe not. I am not sure if BDF files are necessarily presented in the order of the glyph encoding. But in most, if not all, cases you will probably be better off to start searching for 'b' right after 'a', I suspect. (^&) Additionally, perhaps loading up to 8 or 16 glyphs at a time might be good. If you need the Latin 'a', the chances are pretty good that you'll need 'b' before too long. (But for languages like Chinese, I don't think the odds are so favorable.) -- "I probably don't know what I'm talking about." http://www.olib.org/~rkr/ |