#endif
#ifndef WX_PRECOMP
- #include "wx/setup.h"
- #include "wx/defs.h"
#endif // WX_PRECOMP
#if wxUSE_PRINTING_ARCHITECTURE
#include "wx/image.h"
#include "wx/log.h"
#include "wx/generic/dcpsg.h"
-#include "wx/generic/prntdlgg.h"
+#include "wx/printdlg.h"
#include "wx/button.h"
#include "wx/stattext.h"
#include "wx/radiobox.h"
{
return (int)(ms_PSScaleFactor * 72.0);
}
-
+
wxPostScriptDC::wxPostScriptDC ()
"%d %d lineto\n"
"%d %d lineto\n"
"closepath clip newpath\n",
- XLOG2DEV(x), YLOG2DEV(y),
- XLOG2DEV(x+w), YLOG2DEV(y),
- XLOG2DEV(x+w), YLOG2DEV(y+h),
- XLOG2DEV(x), YLOG2DEV(y+h) );
+ LogicalToDeviceX(x), LogicalToDeviceY(y),
+ LogicalToDeviceX(x+w), LogicalToDeviceY(y),
+ LogicalToDeviceX(x+w), LogicalToDeviceY(y+h),
+ LogicalToDeviceX(x), LogicalToDeviceY(y+h) );
}
"%d %d moveto\n"
"%d %d lineto\n"
"stroke\n",
- XLOG2DEV(x1), YLOG2DEV(y1),
- XLOG2DEV(x2), YLOG2DEV (y2) );
+ LogicalToDeviceX(x1), LogicalToDeviceY(y1),
+ LogicalToDeviceX(x2), LogicalToDeviceY (y2) );
CalcBoundingBox( x1, y1 );
CalcBoundingBox( x2, y2 );
"%d %d lineto\n"
"closepath\n"
"fill\n",
- XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL(radius), YLOG2DEVREL(radius), (wxCoord)alpha1, (wxCoord) alpha2,
- XLOG2DEV(xc), YLOG2DEV(yc) );
+ LogicalToDeviceX(xc), LogicalToDeviceY(yc), LogicalToDeviceXRel(radius), LogicalToDeviceYRel(radius), (wxCoord)alpha1, (wxCoord) alpha2,
+ LogicalToDeviceX(xc), LogicalToDeviceY(yc) );
CalcBoundingBox( xc-radius, yc-radius );
CalcBoundingBox( xc+radius, yc+radius );
"%d %d lineto\n"
"stroke\n"
"fill\n",
- XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL(radius), YLOG2DEVREL(radius), (wxCoord)alpha1, (wxCoord) alpha2,
- XLOG2DEV(xc), YLOG2DEV(yc) );
+ LogicalToDeviceX(xc), LogicalToDeviceY(yc), LogicalToDeviceXRel(radius), LogicalToDeviceYRel(radius), (wxCoord)alpha1, (wxCoord) alpha2,
+ LogicalToDeviceX(xc), LogicalToDeviceY(yc) );
CalcBoundingBox( xc-radius, yc-radius );
CalcBoundingBox( xc+radius, yc+radius );
fprintf( m_pstream,
"newpath\n"
"%d %d %d %d %d %d true ellipticarc\n",
- XLOG2DEV(x+w/2), YLOG2DEV(y+h/2), XLOG2DEVREL(w/2), YLOG2DEVREL(h/2), (wxCoord)sa, (wxCoord)ea );
+ LogicalToDeviceX(x+w/2), LogicalToDeviceY(y+h/2), LogicalToDeviceXRel(w/2), LogicalToDeviceYRel(h/2), (wxCoord)sa, (wxCoord)ea );
CalcBoundingBox( x ,y );
CalcBoundingBox( x+w, y+h );
fprintf(m_pstream,
"newpath\n"
"%d %d %d %d %d %d false ellipticarc\n",
- XLOG2DEV(x+w/2), YLOG2DEV(y+h/2), XLOG2DEVREL(w/2), YLOG2DEVREL(h/2), (wxCoord)sa, (wxCoord)ea );
+ LogicalToDeviceX(x+w/2), LogicalToDeviceY(y+h/2), LogicalToDeviceXRel(w/2), LogicalToDeviceYRel(h/2), (wxCoord)sa, (wxCoord)ea );
CalcBoundingBox( x ,y );
CalcBoundingBox( x+w, y+h );
"%d %d moveto\n"
"%d %d lineto\n"
"stroke\n",
- XLOG2DEV(x), YLOG2DEV(y),
- XLOG2DEV(x+1), YLOG2DEV(y) );
+ LogicalToDeviceX(x), LogicalToDeviceY(y),
+ LogicalToDeviceX(x+1), LogicalToDeviceY(y) );
CalcBoundingBox( x, y );
}
fprintf( m_pstream, "newpath\n" );
- wxCoord xx = XLOG2DEV(points[0].x + xoffset);
- wxCoord yy = YLOG2DEV(points[0].y + yoffset);
+ wxCoord xx = LogicalToDeviceX(points[0].x + xoffset);
+ wxCoord yy = LogicalToDeviceY(points[0].y + yoffset);
fprintf( m_pstream, "%d %d moveto\n", xx, yy );
for (int i = 1; i < n; i++)
{
- xx = XLOG2DEV(points[i].x + xoffset);
- yy = YLOG2DEV(points[i].y + yoffset);
+ xx = LogicalToDeviceX(points[i].x + xoffset);
+ yy = LogicalToDeviceY(points[i].y + yoffset);
fprintf( m_pstream, "%d %d lineto\n", xx, yy );
fprintf( m_pstream, "newpath\n" );
- wxCoord xx = XLOG2DEV(points[0].x + xoffset);
- wxCoord yy = YLOG2DEV(points[0].y + yoffset);
+ wxCoord xx = LogicalToDeviceX(points[0].x + xoffset);
+ wxCoord yy = LogicalToDeviceY(points[0].y + yoffset);
fprintf( m_pstream, "%d %d moveto\n", xx, yy );
for (int i = 1; i < n; i++)
{
- xx = XLOG2DEV(points[i].x + xoffset);
- yy = YLOG2DEV(points[i].y + yoffset);
+ xx = LogicalToDeviceX(points[i].x + xoffset);
+ yy = LogicalToDeviceY(points[i].y + yoffset);
fprintf( m_pstream, "%d %d lineto\n", xx, yy );
int i;
for ( i =0; i<n ; i++ )
{
- CalcBoundingBox( XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset));
+ CalcBoundingBox( LogicalToDeviceX(points[i].x+xoffset), LogicalToDeviceY(points[i].y+yoffset));
}
fprintf( m_pstream,
"newpath\n"
"%d %d moveto\n",
- XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) );
+ LogicalToDeviceX(points[0].x+xoffset), LogicalToDeviceY(points[0].y+yoffset) );
for (i = 1; i < n; i++)
{
fprintf( m_pstream,
"%d %d lineto\n",
- XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset) );
+ LogicalToDeviceX(points[i].x+xoffset), LogicalToDeviceY(points[i].y+yoffset) );
}
fprintf( m_pstream, "stroke\n" );
"%d %d lineto\n"
"closepath\n"
"fill\n",
- XLOG2DEV(x), YLOG2DEV(y),
- XLOG2DEV(x + width), YLOG2DEV(y),
- XLOG2DEV(x + width), YLOG2DEV(y + height),
- XLOG2DEV(x), YLOG2DEV(y + height) );
+ LogicalToDeviceX(x), LogicalToDeviceY(y),
+ LogicalToDeviceX(x + width), LogicalToDeviceY(y),
+ LogicalToDeviceX(x + width), LogicalToDeviceY(y + height),
+ LogicalToDeviceX(x), LogicalToDeviceY(y + height) );
CalcBoundingBox( x, y );
CalcBoundingBox( x + width, y + height );
"%d %d lineto\n"
"closepath\n"
"stroke\n",
- XLOG2DEV(x), YLOG2DEV(y),
- XLOG2DEV(x + width), YLOG2DEV(y),
- XLOG2DEV(x + width), YLOG2DEV(y + height),
- XLOG2DEV(x), YLOG2DEV(y + height) );
+ LogicalToDeviceX(x), LogicalToDeviceY(y),
+ LogicalToDeviceX(x + width), LogicalToDeviceY(y),
+ LogicalToDeviceX(x + width), LogicalToDeviceY(y + height),
+ LogicalToDeviceX(x), LogicalToDeviceY(y + height) );
CalcBoundingBox( x, y );
CalcBoundingBox( x + width, y + height );
"%d %d lineto\n"
"closepath\n"
"fill\n",
- XLOG2DEV(x + rad), YLOG2DEV(y + rad), XLOG2DEVREL(rad),
- XLOG2DEV(x), YLOG2DEV(y + rad),
- XLOG2DEV(x + rad), YLOG2DEV(y + height - rad), XLOG2DEVREL(rad),
- XLOG2DEV(x + width - rad), YLOG2DEV(y + height),
- XLOG2DEV(x + width - rad), YLOG2DEV(y + height - rad), XLOG2DEVREL(rad),
- XLOG2DEV(x + width), YLOG2DEV(y + rad),
- XLOG2DEV(x + width - rad), YLOG2DEV(y + rad), XLOG2DEVREL(rad),
- XLOG2DEV(x + rad), YLOG2DEV(y) );
+ LogicalToDeviceX(x + rad), LogicalToDeviceY(y + rad), LogicalToDeviceXRel(rad),
+ LogicalToDeviceX(x), LogicalToDeviceY(y + rad),
+ LogicalToDeviceX(x + rad), LogicalToDeviceY(y + height - rad), LogicalToDeviceXRel(rad),
+ LogicalToDeviceX(x + width - rad), LogicalToDeviceY(y + height),
+ LogicalToDeviceX(x + width - rad), LogicalToDeviceY(y + height - rad), LogicalToDeviceXRel(rad),
+ LogicalToDeviceX(x + width), LogicalToDeviceY(y + rad),
+ LogicalToDeviceX(x + width - rad), LogicalToDeviceY(y + rad), LogicalToDeviceXRel(rad),
+ LogicalToDeviceX(x + rad), LogicalToDeviceY(y) );
CalcBoundingBox( x, y );
CalcBoundingBox( x + width, y + height );
"%d %d lineto\n"
"closepath\n"
"stroke\n",
- XLOG2DEV(x + rad), YLOG2DEV(y + rad), XLOG2DEVREL(rad),
- XLOG2DEV(x), YLOG2DEV(y + rad),
- XLOG2DEV(x + rad), YLOG2DEV(y + height - rad), XLOG2DEVREL(rad),
- XLOG2DEV(x + width - rad), YLOG2DEV(y + height),
- XLOG2DEV(x + width - rad), YLOG2DEV(y + height - rad), XLOG2DEVREL(rad),
- XLOG2DEV(x + width), YLOG2DEV(y + rad),
- XLOG2DEV(x + width - rad), YLOG2DEV(y + rad), XLOG2DEVREL(rad),
- XLOG2DEV(x + rad), YLOG2DEV(y) );
+ LogicalToDeviceX(x + rad), LogicalToDeviceY(y + rad), LogicalToDeviceXRel(rad),
+ LogicalToDeviceX(x), LogicalToDeviceY(y + rad),
+ LogicalToDeviceX(x + rad), LogicalToDeviceY(y + height - rad), LogicalToDeviceXRel(rad),
+ LogicalToDeviceX(x + width - rad), LogicalToDeviceY(y + height),
+ LogicalToDeviceX(x + width - rad), LogicalToDeviceY(y + height - rad), LogicalToDeviceXRel(rad),
+ LogicalToDeviceX(x + width), LogicalToDeviceY(y + rad),
+ LogicalToDeviceX(x + width - rad), LogicalToDeviceY(y + rad), LogicalToDeviceXRel(rad),
+ LogicalToDeviceX(x + rad), LogicalToDeviceY(y) );
CalcBoundingBox( x, y );
CalcBoundingBox( x + width, y + height );
"newpath\n"
"%d %d %d %d 0 360 ellipse\n"
"fill\n",
- XLOG2DEV(x + width / 2), YLOG2DEV(y + height / 2),
- XLOG2DEVREL(width / 2), YLOG2DEVREL(height / 2) );
+ LogicalToDeviceX(x + width / 2), LogicalToDeviceY(y + height / 2),
+ LogicalToDeviceXRel(width / 2), LogicalToDeviceYRel(height / 2) );
CalcBoundingBox( x - width, y - height );
CalcBoundingBox( x + width, y + height );
"newpath\n"
"%d %d %d %d 0 360 ellipse\n"
"stroke\n",
- XLOG2DEV(x + width / 2), YLOG2DEV(y + height / 2),
- XLOG2DEVREL(width / 2), YLOG2DEVREL(height / 2) );
+ LogicalToDeviceX(x + width / 2), LogicalToDeviceY(y + height / 2),
+ LogicalToDeviceXRel(width / 2), LogicalToDeviceYRel(height / 2) );
CalcBoundingBox( x - width, y - height );
CalcBoundingBox( x + width, y + height );
if (!bitmap.Ok()) return;
- wxImage image( bitmap );
+ wxImage image = bitmap.ConvertToImage();
if (!image.Ok()) return;
wxCoord w = image.GetWidth();
wxCoord h = image.GetHeight();
- wxCoord ww = XLOG2DEVREL(image.GetWidth());
- wxCoord hh = YLOG2DEVREL(image.GetHeight());
+ wxCoord ww = LogicalToDeviceXRel(image.GetWidth());
+ wxCoord hh = LogicalToDeviceYRel(image.GetHeight());
- wxCoord xx = XLOG2DEV(x);
- wxCoord yy = YLOG2DEV(y + bitmap.GetHeight());
+ wxCoord xx = LogicalToDeviceX(x);
+ wxCoord yy = LogicalToDeviceY(y + bitmap.GetHeight());
fprintf( m_pstream,
"/origstate save def\n"
fprintf( m_pstream, " findfont\n" );
char buffer[100];
- sprintf( buffer, "%f scalefont setfont\n", YLOG2DEVREL(m_font.GetPointSize() * 1000) / 1000.0F);
+ sprintf( buffer, "%f scalefont setfont\n", LogicalToDeviceYRel(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
+ // LogicalToDeviceYRel works with wxCoord type (int or longint). Se we first convert font size
// to 1/1000th of pt and then back.
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
{
char buffer[100];
#ifdef __WXMSW__
- sprintf( buffer, "%f setlinewidth\n", XLOG2DEVREL(1000 * m_pen.GetWidth()) / 1000.0f );
+ sprintf( buffer, "%f setlinewidth\n", LogicalToDeviceXRel(1000 * m_pen.GetWidth()) / 1000.0f );
#else
- sprintf( buffer, "%f setlinewidth\n", XLOG2DEVREL(1000 * m_pen.GetWidth()) / 1000.0f );
+ sprintf( buffer, "%f setlinewidth\n", LogicalToDeviceXRel(1000 * m_pen.GetWidth()) / 1000.0f );
#endif
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
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())
{
// commented by V. Slavik and replaced by accurate version
// - note that there is still rounding error in text_descent!
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, "%d %d moveto\n", LogicalToDeviceX(x), LogicalToDeviceY(by) );
fprintf( m_pstream, "(" );
const wxWX2MBbuf textbuf = text.mb_str();
- int len = strlen(textbuf);
- int i;
+ size_t len = strlen(textbuf);
+ size_t i;
for (i = 0; i < len; i++)
{
int c = (unsigned char) textbuf[i];
{
/* 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);
}
}
"%d %d lineto\n"
"stroke\n"
"grestore\n",
- XLOG2DEV(x), YLOG2DEV(uy),
+ LogicalToDeviceX(x), LogicalToDeviceY(uy),
m_underlineThickness,
- XLOG2DEV(x + text_w), YLOG2DEV(uy) );
+ LogicalToDeviceX(x + text_w), LogicalToDeviceY(uy) );
for (i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
// FIXME only correct for 90 degrees
fprintf(m_pstream, "%d %d moveto\n",
- XLOG2DEV((wxCoord)(x + size)), YLOG2DEV((wxCoord)by) );
+ LogicalToDeviceX((wxCoord)(x + size)), LogicalToDeviceY((wxCoord)by) );
char buffer[100];
sprintf(buffer, "%.8f rotate\n", angle);
- int i;
+ size_t i;
for (i = 0; i < 100; i++)
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);
+ size_t len = strlen(textbuf);
for (i = 0; i < len; i++)
{
int c = (unsigned char) textbuf[i];
{
/* 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);
}
}
"%d %d lineto\n"
"stroke\n"
"grestore\n",
- XLOG2DEV(x), YLOG2DEV(uy),
+ LogicalToDeviceX(x), LogicalToDeviceY(uy),
m_underlineThickness,
- XLOG2DEV(x + w), YLOG2DEV(uy) );
+ LogicalToDeviceX(x + w), LogicalToDeviceY(uy) );
for (i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
"newpath\n"
"%d %d moveto\n"
"%d %d lineto\n",
- XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1),
- XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) );
+ LogicalToDeviceX((wxCoord)x1), LogicalToDeviceY((wxCoord)y1),
+ LogicalToDeviceX((wxCoord)x3), LogicalToDeviceY((wxCoord)y3) );
CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 );
CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 );
fprintf( m_pstream,
"%d %d %d %d %d %d DrawSplineSection\n",
- XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1),
- XLOG2DEV((wxCoord)x2), YLOG2DEV((wxCoord)y2),
- XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) );
+ LogicalToDeviceX((wxCoord)x1), LogicalToDeviceY((wxCoord)y1),
+ LogicalToDeviceX((wxCoord)x2), LogicalToDeviceY((wxCoord)y2),
+ LogicalToDeviceX((wxCoord)x3), LogicalToDeviceY((wxCoord)y3) );
CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 );
CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 );
fprintf( m_pstream,
"%d %d lineto\n"
"stroke\n",
- XLOG2DEV((wxCoord)c), YLOG2DEV((wxCoord)d) );
+ LogicalToDeviceX((wxCoord)c), LogicalToDeviceY((wxCoord)d) );
}
wxCoord wxPostScriptDC::GetCharWidth() const
// Resolution in pixels per logical inch
wxSize wxPostScriptDC::GetPPI(void) const
{
- return wxSize((int)(72 * ms_PSScaleFactor),
+ return wxSize((int)(72 * ms_PSScaleFactor),
(int)(72 * ms_PSScaleFactor));
}
m_printData.SetFilename(filename);
}
- m_pstream = fopen( m_printData.GetFilename().fn_str(), "w+" );
+ m_pstream = wxFopen( m_printData.GetFilename().fn_str(), wxT("w+") );
if (!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) LogicalToDeviceX(m_minX);
+ wxCoord minY = (wxCoord) LogicalToDeviceY(m_minY);
+ wxCoord maxX = (wxCoord) LogicalToDeviceX(m_maxX);
+ wxCoord maxY = (wxCoord) LogicalToDeviceY(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)
}
char buffer[100];
- sprintf( buffer, "%.8f %.8f scale\n", scale_x / ms_PSScaleFactor,
+ sprintf( buffer, "%.8f %.8f scale\n", scale_x / ms_PSScaleFactor,
scale_y / ms_PSScaleFactor);
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
wxCoord fwidth, wxCoord fheight,
wxDC *source,
wxCoord xsrc, wxCoord ysrc,
- int rop, bool WXUNUSED(useMask) )
+ int rop, bool WXUNUSED(useMask), wxCoord WXUNUSED(xsrcMask), wxCoord WXUNUSED(ysrcMask) )
{
wxCHECK_MSG( m_ok && m_pstream, FALSE, wxT("invalid postscript dc") );
lastStyle = Style;
lastWeight = Weight;
- char *name = (char*) NULL;
+ const char *name = NULL;
switch (Family)
{
afmName << name;
FILE *afmFile = wxFopen(afmName,wxT("r"));
-
+
if (afmFile==NULL)
{
afmName = wxThePrintSetupData->GetAFMPath();
- afmFile = fopen() may fail and in that case the next if branch
MUST be executed - and it would not if there was "else" */
{
- afmName = wxINSTALL_PREFIX;
+ afmName = wxGetDataDir();
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
if (afmFile==NULL)
{
- wxLogDebug( wxT("GetTextExtent: can't open AFM file '%hs'\n"), afmName.c_str() );
- wxLogDebug( wxT(" using approximate values\n"));
+ wxLogDebug( wxT("GetTextExtent: can't open AFM file '%hs'"), afmName.c_str() );
+ wxLogDebug( wxT(" using approximate values"));
for (int i=0; i<256; i++) lastWidths[i] = 500; /* an approximate value */
lastDescender = -150; /* dito. */
}
if ((sscanf(line,"%s%d",descString,&lastDescender)!=2) ||
(strcmp(descString,"Descender")!=0))
{
- wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad descender)\n"), afmName.c_str(),line );
+ wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad descender)"), afmName.c_str(),line );
}
}
/* JC 1.) check for UnderlinePosition */
if ((sscanf(line,"%s%lf",upString,&UnderlinePosition)!=2) ||
(strcmp(upString,"UnderlinePosition")!=0))
{
- wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad UnderlinePosition)\n"), afmName.c_str(), line );
+ wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad UnderlinePosition)"), afmName.c_str(), line );
}
}
/* JC 2.) check for UnderlineThickness */
if ((sscanf(line,"%s%lf",utString,&UnderlineThickness)!=2) ||
(strcmp(utString,"UnderlineThickness")!=0))
{
- wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad UnderlineThickness)\n"), afmName.c_str(), line );
+ wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad UnderlineThickness)"), afmName.c_str(), line );
}
}
/* JC 3.) check for EncodingScheme */
if ((sscanf(line,"%s%s",utString,encString)!=2) ||
(strcmp(utString,"EncodingScheme")!=0))
{
- wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad EncodingScheme)\n"), afmName.c_str(), line );
+ wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (bad EncodingScheme)"), afmName.c_str(), line );
}
else if (strncmp(encString, "AdobeStandardEncoding", 21))
{
- wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (unsupported EncodingScheme %hs)\n"),
+ wxLogDebug( wxT("AFM-file '%hs': line '%hs' has error (unsupported EncodingScheme %hs)"),
afmName.c_str(),line, encString);
}
}
{
if (sscanf(line,"%s%d%s%s%d",cString,&ascii,semiString,WXString,&cWidth)!=5)
{
- wxLogDebug(wxT("AFM-file '%hs': line '%hs' has an error (bad character width)\n"),afmName.c_str(),line);
+ wxLogDebug(wxT("AFM-file '%hs': line '%hs' has an error (bad character width)"),afmName.c_str(),line);
}
if(strcmp(cString,"C")!=0 || strcmp(semiString,";")!=0 || strcmp(WXString,"WX")!=0)
{
- wxLogDebug(wxT("AFM-file '%hs': line '%hs' has a format error\n"),afmName.c_str(),line);
+ wxLogDebug(wxT("AFM-file '%hs': line '%hs' has a format error"),afmName.c_str(),line);
}
/* printf(" char '%c'=%d has width '%d'\n",ascii,ascii,cWidth); */
if (ascii>=0 && ascii<256)
else
{
/* MATTHEW: this happens a lot; don't print an error */
- /* wxLogDebug("AFM-file '%s': ASCII value %d out of range\n",afmName.c_str(),ascii); */
+ /* wxLogDebug("AFM-file '%s': ASCII value %d out of range",afmName.c_str(),ascii); */
}
}
/* C.) ignore other entries. */
// VS: dirty, but is there any better solution?
double *pt;
pt = (double*) &m_underlinePosition;
- *pt = YLOG2DEVREL((wxCoord)(UnderlinePosition * fontToUse->GetPointSize())) / 1000.0f;
+ *pt = LogicalToDeviceYRel((wxCoord)(UnderlinePosition * fontToUse->GetPointSize())) / 1000.0f;
pt = (double*) &m_underlineThickness;
- *pt = YLOG2DEVREL((wxCoord)(UnderlineThickness * fontToUse->GetPointSize())) / 1000.0f;
+ *pt = LogicalToDeviceYRel((wxCoord)(UnderlineThickness * fontToUse->GetPointSize())) / 1000.0f;
}
{
if(lastWidths[*p]== INT_MIN)
{
- wxLogDebug(wxT("GetTextExtent: undefined width for character '%hc' (%d)\n"), *p,*p);
+ wxLogDebug(wxT("GetTextExtent: undefined width for character '%hc' (%d)"), *p,*p);
sum += lastWidths[' ']; /* assume space */
}
else
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)
//{