Author: manolo
Date: 2011-02-16 07:17:01 -0800 (Wed, 16 Feb 2011)
New Revision: 8438
Log:
Improved calculation of text width and height when using the PostScript 
graphics context
under Mac OS and MSWindows.

Modified:
   branches/branch-1.3/src/Fl_PostScript.cxx
   branches/branch-1.3/src/fl_font_mac.cxx
   branches/branch-1.3/src/fl_font_win32.cxx

Modified: branches/branch-1.3/src/Fl_PostScript.cxx
===================================================================
--- branches/branch-1.3/src/Fl_PostScript.cxx   2011-02-16 13:47:03 UTC (rev 
8437)
+++ branches/branch-1.3/src/Fl_PostScript.cxx   2011-02-16 15:17:01 UTC (rev 
8438)
@@ -1038,9 +1038,6 @@
 #endif
   fl_font(fontnum, (Fl_Fontsize)(scale * old_size) );
   fl_draw(str, n, 1, (int)(h * 0.8) ); // draw string in offscreen
-#ifdef WIN32
-  fl_font(0, FL_NORMAL_SIZE); // TODO: find something better
-#endif
   // read (most of) the offscreen image
   uchar *img = fl_read_image(NULL, 1, 1, w, h, 0);
   fl_end_offscreen();

Modified: branches/branch-1.3/src/fl_font_mac.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_mac.cxx     2011-02-16 13:47:03 UTC (rev 
8437)
+++ branches/branch-1.3/src/fl_font_mac.cxx     2011-02-16 15:17:01 UTC (rev 
8438)
@@ -248,7 +248,7 @@
     return;
   }
   Fl_Graphics_Driver::font(fnum, size);
-  fl_graphics_driver->font_descriptor( find(fnum, size) );
+  this->font_descriptor( find(fnum, size) );
 }
 
 int fl_height() {

Modified: branches/branch-1.3/src/fl_font_win32.cxx
===================================================================
--- branches/branch-1.3/src/fl_font_win32.cxx   2011-02-16 13:47:03 UTC (rev 
8437)
+++ branches/branch-1.3/src/fl_font_win32.cxx   2011-02-16 15:17:01 UTC (rev 
8438)
@@ -130,23 +130,20 @@
 ////////////////////////////////////////////////////////////////
 // Public interface:
 
-static Fl_Font fl_font_ = 0;
-static Fl_Fontsize fl_size_ = 0;
-//static HDC font_gc;
-
-static void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) {
+static void fl_font(Fl_Graphics_Driver *driver, 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;
+    fl_angle_ = 0;
+    driver->Fl_Graphics_Driver::font(0, 0);
     return;
   }
-  if (fnum == fl_font_ && size == fl_size_ && angle == fl_angle_) return;
-  fl_font_ = fnum; fl_size_ = size; fl_angle_ = angle;
-  fl_graphics_driver->font_descriptor( find(fnum, size, angle) );
+  if (fnum == driver->Fl_Graphics_Driver::font() && size == driver->size() && 
angle == fl_angle_) return;
+  fl_angle_ = angle;
+  driver->Fl_Graphics_Driver::font(fnum, size);
+  driver->font_descriptor( find(fnum, size, 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_);
+  fl_font(this, fnum, size, 0);
 }
 
 int fl_height() {
@@ -366,8 +363,7 @@
 }
 
 void Fl_GDI_Graphics_Driver::draw(int angle, const char* str, int n, int x, 
int y) {
-  fl_font(fl_font_, fl_size_, angle);
-//  fl_draw(str, n, (int)x, (int)y);
+  fl_font(this, Fl_Graphics_Driver::font(), size(), angle);
   int i = 0, i2=0;
   char *end = (char *)&str[n];
   COLORREF oldColor = SetTextColor(fl_gc, fl_RGB());
@@ -386,7 +382,7 @@
   TextOutW(fl_gc, x, y, (WCHAR*)ucs, i2);
   delete[] ucs;
   SetTextColor(fl_gc, oldColor);
-  fl_font(fl_font_, fl_size_);
+  fl_font(this, Fl_Graphics_Driver::font(), size(), 0);
 }
 
 void Fl_GDI_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to