diff options
| author | Manolo Gouy <Manolo> | 2011-02-16 15:17:01 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2011-02-16 15:17:01 +0000 |
| commit | 162895ad571db9b20c15e13f8869583d49aa13b8 (patch) | |
| tree | f5b733c8fa17441afdf3fd633e8890da6bd548c3 /src | |
| parent | 3adac027c4201b37881f248b30428810f5336638 (diff) | |
Improved calculation of text width and height when using the PostScript graphics context
under Mac OS and MSWindows.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8438 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_PostScript.cxx | 3 | ||||
| -rw-r--r-- | src/fl_font_mac.cxx | 2 | ||||
| -rw-r--r-- | src/fl_font_win32.cxx | 24 |
3 files changed, 11 insertions, 18 deletions
diff --git a/src/Fl_PostScript.cxx b/src/Fl_PostScript.cxx index 5cb5fc3bf..e763b187b 100644 --- a/src/Fl_PostScript.cxx +++ b/src/Fl_PostScript.cxx @@ -1038,9 +1038,6 @@ static void transformed_draw_extra(const char* str, int n, double x, double y, i #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(); diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx index b69260808..602b8495d 100644 --- a/src/fl_font_mac.cxx +++ b/src/fl_font_mac.cxx @@ -248,7 +248,7 @@ void Fl_Quartz_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) { return; } Fl_Graphics_Driver::font(fnum, size); - fl_graphics_driver->font_descriptor( find(fnum, size) ); + this->font_descriptor( find(fnum, size) ); } int fl_height() { diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx index 485ea28a2..361de323d 100644 --- a/src/fl_font_win32.cxx +++ b/src/fl_font_win32.cxx @@ -130,23 +130,20 @@ static Fl_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size, int angle) { //////////////////////////////////////////////////////////////// // 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(const char* str, int n, int x, int y) { } 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 @@ void Fl_GDI_Graphics_Driver::draw(int angle, const char* str, int n, int x, int 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) { |
