[Alephmodular-devel] Font Musings (different)
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-09-17 19:05:50
|
A Font (CFontSpec) encapsulates choice of font family, style, and size. For instance, Monaco, Bold, 10pt. A CFontSpec is a relatively lightweight class. You can ask CDisplay if a font is available. You can pass a font to CDContext->draw_text to select the font to draw with. If a font is unavailable, then drawing in that font is undefined (It may have a default font, or may just decline drawing anything at all) From a CFontSpec, you can ask for variants (Such as different sizes or different styles) Before drawing with a font, you should prepare a buffer for receiving it. This allows the buffer to prepare and cache any information it needs for the font. Such as preloading bitmap definitions or setting up OpenGL drawing lists for each glyph. Draw_text will prepare the font itself, but for efficiency reasons, you may wish to precache these things when beginning a level or switching graphic modes. Preparing a buffer with a font that it has already been prepared with should be a no-op. CFontSpec's should test for equality (Does CFontSpec A == CFontSpec B?) Implementation musings: Internally, I'm thinking of some kind of hash_map within a CBuffer for storing prepared font info. How wary should I be that hash_map is a SGI extension to the C++ STL? (gcc appears to support it, as does microsoft) and it seems to have been originally extended as far back as Hewlett Packard, so may be in the most generally available STL downloads. (at the very least, gcc+MS covers a good chunk of our expected targets anyhow) I think I'm finally getting somewhere conceptually. Yay! -Jeremy Parsons |