Skip to content

Commit

Permalink
Finish removing platform-dependent code from Fl_PostScript.cxx
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11477 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Mar 30, 2016
1 parent 730f2d1 commit 5adda33
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 2 additions & 0 deletions FL/Fl_Graphics_Driver.H
Expand Up @@ -238,6 +238,8 @@ public:
virtual void mask_bitmap(uchar **) {}
// default implementation may be enough
virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s) { return float(s); }
// default implementation may be enough
virtual float scale_bitmap_for_PostScript() { return 2; }
// each platform implements that its own way
static void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h);
protected:
Expand Down
26 changes: 7 additions & 19 deletions src/drivers/PostScript/Fl_PostScript.cxx
Expand Up @@ -16,22 +16,14 @@
// http://www.fltk.org/str.php
//

#include <config.h>
#include <FL/Fl.H>
#include <FL/x.H>
#include <FL/fl_ask.H>
#include <FL/fl_draw.H>
#include <stdio.h>
#include <FL/Fl_PostScript.H>
#include <FL/Fl_Native_File_Chooser.H>
#include <FL/Fl_System_Driver.H>
#include <stdarg.h>
#if defined(USE_X11)
#include <src/Fl_Font.H>
#if USE_XFT
#include <X11/Xft/Xft.h>
#endif
#endif

/** \brief Label of the PostScript file chooser window */
const char *Fl_PostScript_File_Device::file_chooser_title = "Select a .ps file";
Expand Down Expand Up @@ -1041,12 +1033,8 @@ static uchar *calc_mask(uchar *img, int w, int h, Fl_Color bg)
// write to PostScript a bitmap image of a UTF8 string
void Fl_PostScript_Graphics_Driver::transformed_draw_extra(const char* str, int n, double x, double y, int w, bool rtl)
{
// scale for bitmask computation
#if defined(USE_X11) && !USE_XFT
float scale = 1; // don't scale because we can't expect to have scalable fonts
#else
float scale = 2;
#endif
// scale for bitmask computation is set to 1 when we can't expect to have scalable fonts
float scale = Fl_Display_Device::display_device()->driver()->scale_bitmap_for_PostScript();
Fl_Fontsize old_size = size();
Fl_Font fontnum = Fl_Graphics_Driver::font();
int w_scaled = (int)(w * (scale + 0.5));
Expand All @@ -1060,11 +1048,11 @@ void Fl_PostScript_Graphics_Driver::transformed_draw_extra(const char* str, int
// color offscreen background with a shade contrasting with the text color
fl_rectf(0, 0, w_scaled, (int)(h+3*scale) );
fl_color(text_color);
#if defined(USE_X11) && !USE_XFT
// force seeing this font as new so it's applied to the offscreen graphics context
fl_graphics_driver->font_descriptor(NULL);
fl_font(fontnum, 0);
#endif
if (scale < 1.5) {
// force seeing this font as new so it's applied to the offscreen graphics context
fl_graphics_driver->font_descriptor(NULL);
fl_font(fontnum, 0);
}
fl_font(fontnum, (Fl_Fontsize)(scale * old_size) );
int w2 = (int)fl_width(str, n);
// draw string in offscreen
Expand Down
1 change: 1 addition & 0 deletions src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
Expand Up @@ -128,6 +128,7 @@ protected:
Fl_Color color() { return color_; }
void color(uchar r, uchar g, uchar b);
virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s);
virtual float scale_bitmap_for_PostScript();
};


Expand Down
4 changes: 4 additions & 0 deletions src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
Expand Up @@ -693,6 +693,10 @@ float Fl_Xlib_Graphics_Driver::scale_font_for_PostScript(Fl_Font_Descriptor *des
return ps_size;
}

float Fl_Xlib_Graphics_Driver::scale_bitmap_for_PostScript() {
return 1;
}

#endif // FL_DOXYGEN
//
// End of "$Id$".
Expand Down
4 changes: 4 additions & 0 deletions src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
Expand Up @@ -1097,6 +1097,10 @@ float Fl_Xlib_Graphics_Driver::scale_font_for_PostScript(Fl_Font_Descriptor *des
return ps_size;
}

float Fl_Xlib_Graphics_Driver::scale_bitmap_for_PostScript() {
return 2;
}

#endif // FL_DOXYGEN

//
Expand Down

0 comments on commit 5adda33

Please sign in to comment.