| [ Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]
STR #12
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 2 - Low, e.g. a documentation error or undocumented side-effect |
Scope: | 2 - Specific to an operating system |
Subsystem: | X11 |
Summary: | gl_draw & fl_font_xft problem & fix |
Version: | 1.1.3 |
Created By: | jmw.micronix.com |
Assigned To: | mike |
Fix Version: | 1.1.4 |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | jmw.micronix.com 06:52 Apr 12, 2003 |
| Compiling FLTK 1.1.3 with xft enabled under X11 results in gl_draw not working as the glXUseXFont() call within gl_font barfs with an Xrequest:BadFont error. (I'm using Linux 2.4.20, Xfree 4.2.0, gcc 2.95.3).
Whilst I realise that xft support is not yet complete and may be addressed properly in due course, this particular problem can be easily solved with a little hack to gl_draw.cxx and fl_font_xft.cxx. This may help others who want to use bitmapped fonts with OpenGL scenes AND have anti-aliasing operational with FLTK 1.1.x. Not sure how valid this is but hey, it works for me.
src/fl_font_xft.cxx:
Need to make sure that listbase is set to 0 as gl_font uses this to determine whether to create bitmap display lists for the font in question so we alter Fl_FontSize to:
Fl_FontSize::Fl_FontSize(const char* name) { encoding = fl_encoding_; size = fl_size_; #if HAVE_GL listbase = 0; #endif font = fontopen(name, false); }
Also need to add the following (ripped from v2.0 code).
// This call is used by opengl to get a bitmapped font. XFontStruct* fl_xxfont() { if (current_font->core) return current_font->u.core.font; static XftFont* xftfont; if (xftfont) XftFontClose (fl_display, xftfont); xftfont = fontopen(fl_fonts[fl_font_].name, true); return xftfont->u.core.font; }
src/gl_draw.cxx:
Just need to add declaration for fl_xxfont() (this should go in a header but I didn't want to contaminate mine).
#if USE_XFT extern XFontStruct* fl_xxfont(); #endif
Then we just need to add the call to fl_xxfont in the appropriate place within gl_font which becomes:
void gl_font(int fontid, int size) { fl_font(fontid, size); if (!fl_fontsize->listbase) { #ifdef WIN32 int base = fl_fontsize->metr.tmFirstChar; int count = fl_fontsize->metr.tmLastChar-base+1; HFONT oldFid = (HFONT)SelectObject(fl_gc, fl_fontsize->fid); fl_fontsize->listbase = glGenLists(256); wglUseFontBitmaps(fl_gc, base, count, fl_fontsize->listbase+base); SelectObject(fl_gc, oldFid); #elif defined(__APPLE__) fl_fontsize->listbase = glGenLists(256); aglUseFont(aglGetCurrentContext(),fl_fontsize->font,fl_fontsize->face, fl_fontsize->size, 0, 256, fl_fontsize->listbase); #else #if USE_XFT fl_xfont = fl_xxfont(); #endif int base = fl_xfont->min_char_or_byte2; int count = fl_xfont->max_char_or_byte2-base+1; fl_fontsize->listbase = glGenLists(256); glXUseXFont(fl_xfont->fid, base, count, fl_fontsize->listbase+base); #endif } glListBase(fl_fontsize->listbase); }
Then just recompile fltk and verify using the cube test program (fix is properly exercised if cube.cxx is hacked to draw text in different fonts/sizes). Hope this helps somebody somewhere.
Cheers!
| |
|
#2 | mike 14:59 May 04, 2003 |
| Thanks, these changes have been applied to CVS for the 1.1.4 release. | |
[ Return to Bugs & Features ]
|
| |