From e2baef33cdfd3e5f90cdce2685b6239b1979b721 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sun, 4 May 2003 21:58:59 +0000 Subject: gl_font() didn't work properly for X11 when Xft was used (STR #12) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2976 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/fl_font_xft.cxx | 18 ++++++++++++++++-- src/gl_draw.cxx | 11 +++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/fl_font_xft.cxx b/src/fl_font_xft.cxx index efcdd8bdf..07b65a84e 100644 --- a/src/fl_font_xft.cxx +++ b/src/fl_font_xft.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_font_xft.cxx,v 1.4.2.10 2003/01/30 21:43:54 easysw Exp $" +// "$Id: fl_font_xft.cxx,v 1.4.2.11 2003/05/04 21:58:59 easysw Exp $" // // Xft font code for the Fast Light Tool Kit (FLTK). // @@ -142,6 +142,9 @@ static XftFont* fontopen(const char* name, bool core) { Fl_FontSize::Fl_FontSize(const char* name) { encoding = fl_encoding_; size = fl_size_; +#if HAVE_GL + listbase = 0; +#endif // HAVE_GL font = fontopen(name, false); } @@ -163,6 +166,17 @@ double fl_width(uchar c) { return fl_width((const char *)(&c), 1); } +#if HAVE_GL +// 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; +} +#endif // HAVE_GL + #if USE_OVERLAY // Currently Xft does not work with colormapped visuals, so this probably // does not work unless you have a true-color overlay. @@ -226,5 +240,5 @@ void fl_draw(const char *str, int n, int x, int y) { } // -// End of "$Id: fl_font_xft.cxx,v 1.4.2.10 2003/01/30 21:43:54 easysw Exp $" +// End of "$Id: fl_font_xft.cxx,v 1.4.2.11 2003/05/04 21:58:59 easysw Exp $" // diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index 25ef3468f..c19d0139d 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -1,5 +1,5 @@ // -// "$Id: gl_draw.cxx,v 1.7.2.5.2.10 2003/01/30 21:44:33 easysw Exp $" +// "$Id: gl_draw.cxx,v 1.7.2.5.2.11 2003/05/04 21:58:59 easysw Exp $" // // OpenGL drawing support routines for the Fast Light Tool Kit (FLTK). // @@ -36,6 +36,10 @@ #include "Fl_Gl_Choice.H" #include "Fl_Font.H" +#if USE_XFT +extern XFontStruct* fl_xxfont(); +#endif // USE_XFT + int gl_height() {return fl_height();} int gl_descent() {return fl_descent();} double gl_width(const char* s) {return fl_width(s);} @@ -58,6 +62,9 @@ void gl_font(int fontid, int size) { 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 // USE_XFT int base = fl_xfont->min_char_or_byte2; int count = fl_xfont->max_char_or_byte2-base+1; fl_fontsize->listbase = glGenLists(256); @@ -159,5 +166,5 @@ void gl_draw_image(const uchar* b, int x, int y, int w, int h, int d, int ld) { #endif // -// End of "$Id: gl_draw.cxx,v 1.7.2.5.2.10 2003/01/30 21:44:33 easysw Exp $". +// End of "$Id: gl_draw.cxx,v 1.7.2.5.2.11 2003/05/04 21:58:59 easysw Exp $". // -- cgit v1.2.3