Re: [Alephmodular-devel] Font Musings (different)
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-09-18 05:23:23
|
On Wednesday, September 17, 2003, at 10:08 PM, Timothy Collett wrote: >> A Font (CFontSpec) encapsulates choice of font family, style, and >> size. For instance, Monaco, Bold, 10pt. A CFontSpec is a relatively >> lightweight class. >> > > How is color handled? And are we bothering with background color and > justification? > > Just curious...I've been looking at Carbon font-handling stuff, so all > the fields of a ControlFontStyleRec are swimming around in my head > right now... x_x Color is an argument to the function. Background color is ignored (We assume we're drawing ontop of something else and want it to show through.) Justification is ignored/left to higher level routines. We just want to draw a string of text at X,Y. These are the current font related methods on CDContext (The Drawing Context Class) /* Font methods */ short get_font_height(const CBuffer::Font& font) short get_font_line_spacing(const CBuffer::Font& font) short text_width(const CBuffer::Font& font, char *string) short char_width(const CBuffer::Font& font, char c) void draw_text(const CBuffer::Font& font, const CPoint& where, char *string, const CColor& color) I still feel that it's right to pump font metric info through the drawing class as I fully expect to implement a Scaled Buffer at some future point in time. And on the fly it would be tweaking things. We are doing a 2x scale for our buffer. (We tell the system we are a 640x480 buffer, but we're actually drawing to a window much larger then that.) So we'll modify all inputs, including font sizes, by our modifier. Theoretically achieving a mostly unblurred but scaled up result. Yes, the concept of a scaled buffer is mostly getting tossed around in my head in order to do full screen terminal windows at higher resolutions (Crossed fingers.) screen_drawing.cpp and computer_interface.cpp both handle concepts of line wrapping and justification and clipping text to fit. But at a higher level than CDContext handling the basic 'draw string' functionality. I admit I'm keeping things extremely simple. For instance, CDContext currently has no concept of 'current color' or 'current font'. So all of the drawing commands so far include a color argument. This kind of puts it at a 'semi-right' state. Much better than calling platform drawing commands altogether, but not yet full featured to use outside of AM's use of the classes. Or potentially using the classes most efficiently. So far, I'm happy with the display abstraction. Fonts are the last major hurdle, and while there is another minor hurdle or so (DrawPicture(resource_picture) comes to mind) I believe it will be a straightforward procedure to attach that to a CBitmap class and use some of the SDL inclined picture extracting glue from A1 to do it. -Jeremy Parsons |