diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H index c51e99c1d..42b386e9c 100644 --- a/FL/Fl_Device.H +++ b/FL/Fl_Device.H @@ -59,6 +59,8 @@ typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf); #define MATRIX_STACK_SIZE 32 #define MATRIX_STACK_MAX (MATRIX_STACK_SIZE - 1) +/** A 2D coordinate transformation matrix + */ struct matrix {double a, b, c, d, x, y;}; // typedef what the x,y fields in a point are: @@ -110,6 +112,8 @@ public: in the \ref fl_drawings and \ref fl_attributes modules. */ class FL_EXPORT Fl_Graphics_Driver : public Fl_Device { + Fl_Font font_; // current font + Fl_Fontsize size_; // current font size enum {LINE, LOOP, POLYGON, POINT_}; int sptr; matrix stack[MATRIX_STACK_SIZE]; @@ -199,7 +203,7 @@ protected: friend FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D); friend void gl_start(); - matrix *fl_matrix; + matrix *fl_matrix; /**< Points to the current coordinate transformation matrix */ /** \brief The constructor. */ Fl_Graphics_Driver(); @@ -345,7 +349,11 @@ protected: public: static const char *class_id; /** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */ - virtual void font(Fl_Font face, Fl_Fontsize size) = 0; + virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ = size;} + /** \brief see fl_font(). */ + Fl_Font font() {return font_; } + /** \brief see fl_size(). */ + Fl_Fontsize size() {return size_; } /** \brief The destructor */ virtual ~Fl_Graphics_Driver() {}; }; diff --git a/FL/Fl_PostScript.H b/FL/Fl_PostScript.H index 80c5bd5c1..56b05234e 100644 --- a/FL/Fl_PostScript.H +++ b/FL/Fl_PostScript.H @@ -76,8 +76,6 @@ class Clip { Clip * clip_; int lang_level_; - int font_; - int size_; int gap_; int pages_; @@ -182,8 +180,6 @@ class Clip { void transformed_vertex(double x, double y); void font(int face, int size); - int font(){return font_;}; - int size(){return size_;}; void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0){draw_scaled_image(d,x,y,w,h,w,h,delta,ldelta);}; void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0){draw_scaled_image_mono(d,x,y,w,h,w,h,delta,ld);}; diff --git a/FL/fl_draw.H b/FL/fl_draw.H index a17737d3f..5d197e403 100644 --- a/FL/fl_draw.H +++ b/FL/fl_draw.H @@ -480,20 +480,17 @@ inline void fl_transformed_vertex(double xf, double yf) {fl_graphics_driver->tra Lines should be spaced \p size pixels apart or more. */ inline void fl_font(Fl_Font face, Fl_Fontsize size) { fl_graphics_driver->font(face,size); } -extern FL_EXPORT Fl_Font fl_font_; ///< current font index /** Returns the \p face set by the most recent call to fl_font(). This can be used to save/restore the font. */ -inline Fl_Font fl_font() {return fl_font_;} -/** \brief current font size */ -extern FL_EXPORT Fl_Fontsize fl_size_; +inline Fl_Font fl_font() {return fl_graphics_driver->font();} /** Returns the \p size set by the most recent call to fl_font(). This can be used to save/restore the font. */ -inline Fl_Fontsize fl_size() {return fl_size_;} +inline Fl_Fontsize fl_size() {return fl_graphics_driver->size();} // information you can get about the current font: /** diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx index 790545703..87c2d28ee 100644 --- a/src/Fl_Device.cxx +++ b/src/Fl_Device.cxx @@ -54,11 +54,13 @@ void Fl_Surface_Device::set_current(void) static matrix m0 = {1, 0, 0, 1, 0, 0}; Fl_Graphics_Driver::Fl_Graphics_Driver() { - sptr=0; rstackptr=0; - fl_clip_state_number=0; - m = m0; - fl_matrix = &m; - p = (XPOINT *)0; + font_ = 0; + size_ = 0; + sptr=0; rstackptr=0; + fl_clip_state_number=0; + m = m0; + fl_matrix = &m; + p = (XPOINT *)0; }; // diff --git a/src/Fl_PostScript.cxx b/src/Fl_PostScript.cxx index aecfe9af8..178d2b479 100644 --- a/src/Fl_PostScript.cxx +++ b/src/Fl_PostScript.cxx @@ -589,15 +589,14 @@ int Fl_PostScript_Graphics_Driver::start_postscript (int pagecount, void Fl_PostScript_Graphics_Driver::recover(){ color(cr_,cg_,cb_); line_style(linestyle_,linewidth_,linedash_); - font(font_,size_); + font(Fl_Graphics_Driver::font(), Fl_Graphics_Driver::size()); } void Fl_PostScript_Graphics_Driver::reset(){ gap_=1; clip_=0; cr_=cg_=cb_=0; - font_=FL_HELVETICA; - size_=12; + Fl_Graphics_Driver::font(FL_HELVETICA, 12); linewidth_=0; linestyle_=FL_SOLID; strcpy(linedash_,""); @@ -932,7 +931,7 @@ void Fl_PostScript_Graphics_Driver::font(int f, int s) { fprintf(output, "/%s SF\n" , _fontNames[f]); fprintf(output,"%i FS\n", s); Fl_Display_Device::display_device()->driver()->font(f,s); // Use display fonts for font measurement - font_ = f; size_ = s; + Fl_Graphics_Driver::font(f, s); } void Fl_PostScript_Graphics_Driver::color(Fl_Color c) { diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx index 5312c6fe4..5e6d2f5ff 100644 --- a/src/fl_font_mac.cxx +++ b/src/fl_font_mac.cxx @@ -250,18 +250,12 @@ static Fl_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size) { //////////////////////////////////////////////////////////////// // Public interface: -Fl_Font fl_font_ = 0; -Fl_Fontsize fl_size_ = 0; - - void Fl_Quartz_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) { if (fnum==-1) { - fl_font_ = 0; - fl_size_ = 0; + Fl_Graphics_Driver::font(0, 0); return; } - fl_font_ = fnum; - fl_size_ = size; + Fl_Graphics_Driver::font(fnum, size); fl_font(find(fnum, size)); } diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx index 5c5238605..c35625d13 100644 --- a/src/fl_font_win32.cxx +++ b/src/fl_font_win32.cxx @@ -132,11 +132,11 @@ static Fl_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size, int angle) { //////////////////////////////////////////////////////////////// // Public interface: -Fl_Font fl_font_ = 0; -Fl_Fontsize fl_size_ = 0; +static Fl_Font fl_font_ = 0; +static Fl_Fontsize fl_size_ = 0; //static HDC font_gc; -void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) { +static void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) { if (fnum==-1) { // just make sure that we will load a new font next time fl_font_ = 0; fl_size_ = 0; fl_angle_ = 0; return; @@ -148,6 +148,7 @@ void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) { void Fl_GDI_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) { fl_font(fnum, size, 0); + Fl_Graphics_Driver::font(fl_font_, fl_size_); } int fl_height() { diff --git a/src/fl_font_x.cxx b/src/fl_font_x.cxx index 247770ede..6983aff1e 100644 --- a/src/fl_font_x.cxx +++ b/src/fl_font_x.cxx @@ -260,8 +260,6 @@ static Fl_Font_Descriptor* find(int fnum, int size) { //////////////////////////////////////////////////////////////// // Public interface: -Fl_Font fl_font_ = 0; -Fl_Fontsize fl_size_ = 0; void *fl_xftfont = 0; static GC font_gc; @@ -271,11 +269,11 @@ XFontStruct* Fl_XFont_On_Demand::value() { void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) { if (fnum==-1) { - fl_font_ = 0; fl_size_ = 0; + Fl_Graphics_Driver::font(0, 0); return; } - if (fnum == fl_font_ && size == fl_size_) return; - fl_font_ = fnum; fl_size_ = size; + if (fnum == Fl_Graphics_Driver::font() && size == Fl_Graphics_Driver::size()) return; + Fl_Graphics_Driver::font(fnum, size); Fl_Font_Descriptor* f = find(fnum, size); if (f != fl_fontsize) { fl_fontsize = f; diff --git a/src/fl_font_xft.cxx b/src/fl_font_xft.cxx index 08953e95b..e6036f9a5 100644 --- a/src/fl_font_xft.cxx +++ b/src/fl_font_xft.cxx @@ -110,8 +110,8 @@ Fl_Fontdesc* fl_fonts = built_in_table; #define current_font (fl_fontsize->font) -Fl_Font fl_font_ = 0; -Fl_Fontsize fl_size_ = 0; +static Fl_Font fl_font_ = 0; +static Fl_Fontsize fl_size_ = 0; int fl_angle_ = 0; // internal for rotating text support Fl_XFont_On_Demand fl_xfont; void *fl_xftfont = 0; @@ -154,6 +154,7 @@ void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) { void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) { fl_font(fnum,size,0); + Fl_Graphics_Driver::font(fl_font_, fl_size_); } static XftFont* fontopen(const char* name, bool core, int angle) { diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx index 8086afa09..95f9a37ce 100644 --- a/src/gl_draw.cxx +++ b/src/gl_draw.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include "Fl_Gl_Choice.H" #include "Fl_Font.H" #include @@ -161,8 +162,7 @@ void gl_remove_displaylist_fonts() # if HAVE_GL // clear variables used mostly in fl_font - fl_font_ = 0; - fl_size_ = 0; + fl_graphics_driver->font(0, 0); for (int j = 0 ; j < FL_FREE_FONT ; ++j) {