summaryrefslogtreecommitdiff
path: root/src/Fl_PostScript.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2011-02-16 13:47:03 +0000
committerManolo Gouy <Manolo>2011-02-16 13:47:03 +0000
commit3adac027c4201b37881f248b30428810f5336638 (patch)
treeb0228679a027f406167f6abe9bbde30a8a4aca0d /src/Fl_PostScript.cxx
parenteb0b154ffd5d61b934224f6602cf61fbe853e1c7 (diff)
Improved calculation of text width and height when using the PostScript graphics context
under X11 or Xft. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8437 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_PostScript.cxx')
-rw-r--r--src/Fl_PostScript.cxx11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Fl_PostScript.cxx b/src/Fl_PostScript.cxx
index 7ffcf1a0f..5cb5fc3bf 100644
--- a/src/Fl_PostScript.cxx
+++ b/src/Fl_PostScript.cxx
@@ -272,8 +272,8 @@ static const char * prolog =
// show at position with desired width
// usage:
// width (string) x y show_pos_width
-"/show_pos_width {GS moveto dup dup stringwidth pop exch length 2 div 1 sub dup 0 eq {pop 1} if "
-"exch 3 index exch sub exch "
+"/show_pos_width {GS moveto dup dup stringwidth pop exch length 2 div dup 2 le {pop 9999} if "
+"1 sub exch 3 index exch sub exch "
"div 0 2 index 1 -1 scale ashow pop pop GR} bind def\n" // spacing altered to match desired width
//"/show_pos_width {GS moveto dup stringwidth pop 3 2 roll exch div -1 matrix scale concat "
//"show GR } bind def\n" // horizontally scaled text to match desired width
@@ -931,16 +931,17 @@ static const char *_fontNames[] = {
};
void Fl_PostScript_Graphics_Driver::font(int f, int s) {
- Fl_Display_Device::display_device()->driver()->font(f,s); // Use display fonts for font measurement
+ Fl_Graphics_Driver *driver = Fl_Display_Device::display_device()->driver();
+ driver->font(f,s); // Use display fonts for font measurement
Fl_Graphics_Driver::font(f, s);
+ Fl_Font_Descriptor *desc = driver->font_descriptor();
+ this->font_descriptor(desc);
if (f < FL_FREE_FONT) {
int ps_size = s;
fprintf(output, "/%s SF\n" , _fontNames[f]);
#if defined(USE_X11) && !USE_XFT
// Non-Xft fonts can have a different size from that required.
// Give to the PostScript font the same size as that used on the display
- Fl_Font_Descriptor *desc = Fl_Display_Device::display_device()->driver()->font_descriptor();
- this->font_descriptor(desc);
char *name = desc->font->font_name_list[0];
char *p = strstr(name, "--");
if (p) {