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
This commit is contained in:
parent
3adac027c4
commit
162895ad57
@ -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();
|
||||
|
@ -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() {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user