wxCoord xx = XLOG2DEV(points[0].x + xoffset);
wxCoord yy = YLOG2DEV(points[0].y + yoffset);
- wxCoord xx0 = xx;
- wxCoord yy0 = yy;
-
fprintf( m_pstream, "%d %d moveto\n", xx, yy );
CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset );
CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset);
}
- fprintf( m_pstream, "%d %d lineto\n", xx0, yy0 );
+ fprintf( m_pstream, "closepath\n" );
fprintf( m_pstream, "stroke\n" );
}
}
m_font = font;
- const char *name;
- const char *style = "";
int Style = m_font.GetStyle();
int Weight = m_font.GetWeight();
+ const char *name;
switch (m_font.GetFamily())
{
case wxTELETYPE:
case wxMODERN:
- name = "/Courier";
- break;
- case wxSWISS:
- name = "/Helvetica";
+ {
+ if (Style == wxITALIC)
+ {
+ if (Weight == wxBOLD)
+ name = "/Courier-BoldOblique";
+ else
+ name = "/Courier-Oblique";
+ }
+ else
+ {
+ if (Weight == wxBOLD)
+ name = "/Courier-Bold";
+ else
+ name = "/Courier";
+ }
break;
+ }
case wxROMAN:
-// name = "/Times-Roman";
- name = "/Times"; // Altered by EDZ
+ {
+ if (Style == wxITALIC)
+ {
+ if (Weight == wxBOLD)
+ name = "/Times-BoldItalic";
+ else
+ name = "/Times-Italic";
+ }
+ else
+ {
+ if (Weight == wxBOLD)
+ name = "/Times-Bold";
+ else
+ name = "/Times-Roman";
+ }
break;
+ }
case wxSCRIPT:
- name = "/Zapf-Chancery-MediumItalic";
+ {
+ name = "/ZapfChancery-MediumItalic";
Style = wxNORMAL;
Weight = wxNORMAL;
break;
+ }
+ case wxSWISS:
default:
- case wxDEFAULT: // Sans Serif Font
- name = "/LucidaSans";
- }
-
- if (Style == wxNORMAL && (Weight == wxNORMAL || Weight == wxLIGHT))
- {
- if (m_font.GetFamily () == wxROMAN)
- style = "-Roman";
- else
- style = "";
- }
- else if (Style == wxNORMAL && Weight == wxBOLD)
- {
- style = "-Bold";
- }
- else if (Style == wxITALIC && (Weight == wxNORMAL || Weight == wxLIGHT))
- {
- if (m_font.GetFamily () == wxROMAN)
- style = "-Italic";
- else
- style = "-Oblique";
- }
- else if (Style == wxITALIC && Weight == wxBOLD)
- {
- if (m_font.GetFamily () == wxROMAN)
- style = "-BoldItalic";
- else
- style = "-BoldOblique";
- }
- else if (Style == wxSLANT && (Weight == wxNORMAL || Weight == wxLIGHT))
- {
- if (m_font.GetFamily () == wxROMAN)
- style = "-Italic";
- else
- style = "-Oblique";
- }
- else if (Style == wxSLANT && Weight == wxBOLD)
- {
- if (m_font.GetFamily () == wxROMAN)
- style = "-BoldItalic";
- else
- style = "-BoldOblique";
- }
- else
- {
- style = "";
+ {
+ if (Style == wxITALIC)
+ {
+ if (Weight == wxBOLD)
+ name = "/Helvetica-BoldOblique";
+ else
+ name = "/Helvetica-Oblique";
+ }
+ else
+ {
+ if (Weight == wxBOLD)
+ name = "/Helvetica-Bold";
+ else
+ name = "/Helvetica";
+ }
+ break;
+ }
}
- char buffer[100];
- strcpy( buffer, name );
- strcat( buffer, style );
-
- fprintf( m_pstream, buffer );
+ fprintf( m_pstream, name );
fprintf( m_pstream, " reencodeISO def\n" );
- fprintf( m_pstream, buffer );
+ fprintf( m_pstream, name );
fprintf( m_pstream, " findfont\n" );
+ char buffer[100];
sprintf( buffer, "%f scalefont setfont\n", YLOG2DEVREL(m_font.GetPointSize() * 1000) / 1000.0F);
// this is a hack - we must scale font size (in pts) according to m_scaleY but
// YLOG2DEVREL works with wxCoord type (int or longint). Se we first convert font size
GetTextExtent(text, &text_w, &text_h, &text_descent);
- SetFont( m_font );
+ // VZ: this seems to be unnecessary, so taking it out for now, if it
+ // doesn't create any problems, remove this comment entirely
+ //SetFont( m_font );
if (m_textForegroundColour.Ok())
{
wxCoord by = y + size - text_descent; // baseline
fprintf( m_pstream, "%d %d moveto\n", XLOG2DEV(x), YLOG2DEV(by) );
- /* I don't know how to write char to a stream, so I use a mini string */
- char tmpbuf[2];
- tmpbuf[1] = 0;
-
fprintf( m_pstream, "(" );
const wxWX2MBbuf textbuf = text.mb_str();
int len = strlen(textbuf);
{
/* Cope with special characters */
fprintf( m_pstream, "\\" );
- tmpbuf[0] = (char) c;
- fprintf( m_pstream, tmpbuf );
+ fputc(c, m_pstream);
}
else if ( c >= 128 )
{
}
else
{
- tmpbuf[0] = (char) c;
- fprintf( m_pstream, tmpbuf );
+ fputc(c, m_pstream);
}
}
if (buffer[i] == ',') buffer[i] = '.';
fprintf(m_pstream, buffer);
- /* I don't know how to write char to a stream, so I use a mini string */
- char tmpbuf[2];
- tmpbuf[1] = 0;
-
fprintf( m_pstream, "(" );
const wxWX2MBbuf textbuf = text.mb_str();
int len = strlen(textbuf);
{
/* Cope with special characters */
fprintf( m_pstream, "\\" );
- tmpbuf[0] = (char) c;
- fprintf( m_pstream, tmpbuf );
+ fputc(c, m_pstream);
}
else if ( c >= 128 )
{
}
else
{
- tmpbuf[0] = (char) c;
- fprintf( m_pstream, tmpbuf );
+ fputc(c, m_pstream);
}
}
// Compute the bounding box. Note that it is in the default user
// coordinate system, thus we have to convert the values.
- wxCoord llx = (wxCoord) ((XLOG2DEV(m_minX)+wx_printer_translate_x)*wx_printer_scale_x);
- wxCoord lly = (wxCoord) ((YLOG2DEV(m_minY)+wx_printer_translate_y)*wx_printer_scale_y);
- wxCoord urx = (wxCoord) ((XLOG2DEV(m_maxX)+wx_printer_translate_x)*wx_printer_scale_x);
- wxCoord ury = (wxCoord) ((YLOG2DEV(m_maxY)+wx_printer_translate_y)*wx_printer_scale_y);
+ wxCoord minX = (wxCoord) XLOG2DEV(m_minX);
+ wxCoord minY = (wxCoord) YLOG2DEV(m_minY);
+ wxCoord maxX = (wxCoord) XLOG2DEV(m_maxX);
+ wxCoord maxY = (wxCoord) YLOG2DEV(m_maxY);
+
+ // LOG2DEV may have changed the minimum to maximum vice versa
+ if ( minX > maxX ) { wxCoord tmp = minX; minX = maxX; maxX = tmp; }
+ if ( minY > maxY ) { wxCoord tmp = minY; minY = maxY; maxY = tmp; }
+
+ // account for used scaling (boundingbox is before scaling in ps-file)
+ double scale_x = m_printData.GetPrinterScaleX() / ms_PSScaleFactor;
+ double scale_y = m_printData.GetPrinterScaleY() / ms_PSScaleFactor;
+
+ wxCoord llx, lly, urx, ury;
+ llx = (wxCoord) ((minX+wx_printer_translate_x)*scale_x);
+ lly = (wxCoord) ((minY+wx_printer_translate_y)*scale_y);
+ urx = (wxCoord) ((maxX+wx_printer_translate_x)*scale_x);
+ ury = (wxCoord) ((maxY+wx_printer_translate_y)*scale_y);
+ // (end of bounding box computation)
+
// If we're landscape, our sense of "x" and "y" is reversed.
if (m_printData.GetOrientation() == wxLANDSCAPE)
double UnderlineThickness = 0.0;
/* get actual parameters */
- const int Family = fontToUse->GetFamily();
- const int Size = fontToUse->GetPointSize();
- const int Style = fontToUse->GetStyle();
- const int Weight = fontToUse->GetWeight();
+ int Family = fontToUse->GetFamily();
+ int Size = fontToUse->GetPointSize();
+ int Style = fontToUse->GetStyle();
+ int Weight = fontToUse->GetWeight();
/* if we have another font, read the font-metrics */
if (Family!=lastFamily || Size!=lastSize || Style!=lastStyle || Weight!=lastWeight)
switch (Family)
{
case wxMODERN:
- {
- if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "CourBoO";
- else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "CourBo";
- else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "CourO";
- else name = "Cour";
- }
+ case wxTELETYPE:
+ {
+ if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "CourBoO.afm";
+ else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "CourBo.afm";
+ else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "CourO.afm";
+ else name = "Cour.afm";
break;
+ }
case wxROMAN:
- {
- if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "TimesBoO";
- else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "TimesBo";
- else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "TimesO";
- else name = "TimesRo";
- }
+ {
+ if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "TimesBoO.afm";
+ else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "TimesBo.afm";
+ else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "TimesO.afm";
+ else name = "TimesRo.afm";
break;
+ }
+ case wxSCRIPT:
+ {
+ name = "Zapf.afm";
+ Style = wxNORMAL;
+ Weight = wxNORMAL;
+ }
+ case wxSWISS:
default:
- {
- if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "HelvBoO";
- else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "HelvBo";
- else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "HelvO";
- else name = "Helv";
- }
+ {
+ if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "HelvBoO.afm";
+ else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "HelvBo.afm";
+ else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "HelvO.afm";
+ else name = "Helv.afm";
break;
+ }
}
/* get the directory of the AFM files */
/* new elements JC Sun Aug 25 23:21:44 MET DST 1996 */
- afmName << name << wxT(".afm");
+ afmName << name;
FILE *afmFile = wxFopen(afmName,wxT("r"));
+
if (afmFile==NULL)
{
afmName = wxThePrintSetupData->GetAFMPath();
- afmName << wxFILE_SEP_PATH << name << wxT(".afm");
+ afmName << wxFILE_SEP_PATH << name;
afmFile = wxFopen(afmName,wxT("r"));
}
-#ifdef __UNIX__
-#ifndef __VMS__
+#if defined(__UNIX__) && !defined(__VMS__)
if (afmFile==NULL)
/* please do NOT change the line above to "else if (afmFile==NULL)" -
- afmFile = fopen() may fail and in that case the next if branch
afmName << wxFILE_SEP_PATH
<< wxT("share") << wxFILE_SEP_PATH
<< wxT("wx") << wxFILE_SEP_PATH
+#if defined(__LINUX__) || defined(__FREEBSD__)
+ << wxT("gs_afm") << wxFILE_SEP_PATH
+#else
<< wxT("afm") << wxFILE_SEP_PATH
- << name << wxT(".afm");
+#endif
+ << name;
afmFile = wxFopen(afmName,wxT("r"));
}
-#endif
#endif
if (afmFile==NULL)
/ is done by adding the widths of the characters in the
/ string. they are given in 1/1000 of the size! */
- double widthSum=0;
+ long sum=0;
wxCoord height=Size; /* by default */
unsigned char *p;
for(p=(unsigned char *)wxMBSTRINGCAST strbuf; *p; p++)
if(lastWidths[*p]== INT_MIN)
{
wxLogDebug(wxT("GetTextExtent: undefined width for character '%hc' (%d)\n"), *p,*p);
- widthSum += (lastWidths[' ']/1000.0F * Size); /* assume space */
+ sum += lastWidths[' ']; /* assume space */
}
else
{
- widthSum += ((lastWidths[*p]/1000.0F)*Size);
+ sum += lastWidths[*p];
}
}
-
+
+ double widthSum = sum;
+ widthSum *= Size;
+ widthSum /= 1000.0F;
+
/* add descender to height (it is usually a negative value) */
//if (lastDescender != INT_MIN)
//{