Use different print font scaling factor for Mac.

Define factor in header file so it can be adjusted with one edit.


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4041 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
telwertowski 2005-10-07 04:55:03 +00:00
parent 71a0e7f62b
commit adc6c5c69c
5 changed files with 20 additions and 7 deletions

View File

@ -158,7 +158,7 @@ void QgsComposerLabel::draw ( QPainter & painter )
// In any case, each font scales in in different way even if painter.scale() // In any case, each font scales in in different way even if painter.scale()
// is used instead of font size!!! -> Postscript is never exactly the same as // is used instead of font size!!! -> Postscript is never exactly the same as
// in preview. // in preview.
double factor = 2.45; double factor = QgsComposition::psFontScaleFactor();
double pssize = factor * 72.0 * mFont.pointSizeFloat() / mComposition->resolution(); double pssize = factor * 72.0 * mFont.pointSizeFloat() / mComposition->resolution();
double psscale = pssize/size; double psscale = pssize/size;

View File

@ -178,8 +178,7 @@ void QgsComposerMap::draw ( QPainter *painter, QgsRect *extent, QgsMapToPixel *t
if ( vector->labelOn() ) { if ( vector->labelOn() ) {
double fontScale = 25.4 * mFontScale * mComposition->scale() / 72; double fontScale = 25.4 * mFontScale * mComposition->scale() / 72;
if ( plotStyle() == QgsComposition::Postscript ) { if ( plotStyle() == QgsComposition::Postscript ) {
// I have no idea why 2.54 - it is an empirical value fontScale = QgsComposition::psFontScaleFactor() * 72.0 / mComposition->resolution();
fontScale = 2.54 * 72.0 / mComposition->resolution();
} }
vector->drawLabels ( painter, extent, transform, device, fontScale ); vector->drawLabels ( painter, extent, transform, device, fontScale );
} }

View File

@ -220,7 +220,7 @@ QRect QgsComposerScalebar::render ( QPainter *p )
// In any case, each font scales in in different way even if painter.scale() // In any case, each font scales in in different way even if painter.scale()
// is used instead of font size!!! -> Postscript is never exactly the same as // is used instead of font size!!! -> Postscript is never exactly the same as
// in preview. // in preview.
double factor = 2.45; double factor = QgsComposition::psFontScaleFactor();
double pssize = factor * 72.0 * mFont.pointSizeFloat() / mComposition->resolution(); double pssize = factor * 72.0 * mFont.pointSizeFloat() / mComposition->resolution();
double psscale = pssize/size; double psscale = pssize/size;

View File

@ -210,13 +210,12 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
// Fonts for rendering // Fonts for rendering
// I have no idea why 2.54 - it is an empirical value
// TODO: For output to Postscript the font must be scaled. But how? // TODO: For output to Postscript the font must be scaled. But how?
// The factor is an empirical value. // The factor is an empirical value.
// In any case, each font scales in in different way even if painter.scale() // In any case, each font scales in in different way even if painter.scale()
// is used instead of font size!!! -> Postscript is never exactly the same as // is used instead of font size!!! -> Postscript is never exactly the same as
// in preview. // in preview.
double psFontFactor = 2.45; double psFontFactor = QgsComposition::psFontScaleFactor();
double psTitleSize = psFontFactor * 72.0 * mTitleFont.pointSizeFloat() / mComposition->resolution(); double psTitleSize = psFontFactor * 72.0 * mTitleFont.pointSizeFloat() / mComposition->resolution();
double psSectionSize = psFontFactor * 72.0 * mSectionFont.pointSizeFloat() / mComposition->resolution(); double psSectionSize = psFontFactor * 72.0 * mSectionFont.pointSizeFloat() / mComposition->resolution();

View File

@ -99,6 +99,21 @@ public:
Postscript // Fonts need different scaling! Postscript // Fonts need different scaling!
}; };
/** \brief Font scaling factor for PostScript output
*
* For output to Postscript the font must be scaled. But how?
* The factor is an empirical value. In any case, each font scales
* in in different way even if painter.scale() is used instead of
* font size!!! -> Postscript is never exactly the same as in preview.
*/
static const double psFontScaleFactor() {
#ifdef Q_OS_MACX
return 1.85;
#else
return 2.45; // I have no idea why 2.45 - it is an empirical value
#endif
}
/** \brief Composition ID */ /** \brief Composition ID */
int id ( void ); int id ( void );
@ -290,7 +305,7 @@ private:
/** \brief Temporary item used as pointer to new objecs which must be drawn */ /** \brief Temporary item used as pointer to new objecs which must be drawn */
QCanvasItem *mNewCanvasItem; QCanvasItem *mNewCanvasItem;
/** \breif Resolution in DPI */ /** \brief Resolution in DPI */
int mResolution; int mResolution;
/** \brief canvas scale */ /** \brief canvas scale */