Skip to content

Commit ed665d6

Browse files
author
timlinux
committedFeb 13, 2008
Some tweaks to try to ensure proper font sizing in projected maps and to make the scale bar a little skinnier
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8155 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5eb24c4 commit ed665d6

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed
 

‎src/gui/qgsquickprint.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,13 @@ void QgsQuickPrint::printMap()
222222
int myLegendHeightPercent = 65;
223223
int myLogoWidthPercent = 23;
224224
int myLogoHeightPercent = 17;
225-
int mySymbolScalingAmount = myPrintResolutionDpi / myScreenResolutionDpi;
225+
//
226+
// Remember the size and dpi of the maprender
227+
// so we can restore it properly
228+
//
229+
int myOriginalDpi = mpMapRender->outputDpi();
230+
QSize myOriginalSize = mpMapRender->outputSize();
231+
int mySymbolScalingAmount = myPrintResolutionDpi / myOriginalDpi;
226232

227233
//define the font sizes and family
228234
int myMapTitleFontSize = 24;
@@ -337,12 +343,6 @@ void QgsQuickPrint::printMap()
337343
myMapPixmap.fill ( mMapBackgroundColour );
338344
QPainter myMapPainter;
339345
myMapPainter.begin( &myMapPixmap );
340-
//
341-
// Remember the size and dpi of the maprender
342-
// so we can restore it properly
343-
//
344-
int myOriginalDpi = mpMapRender->outputDpi();
345-
QSize myOriginalSize = mpMapRender->outputSize();
346346
// Now resize for print
347347
mpMapRender->setOutputSize(
348348
QSize ( myMapDimensionX, myMapDimensionY ), myPrinter.resolution() );
@@ -795,7 +795,6 @@ void QgsQuickPrint::renderPrintScaleBar(QPainter * thepPainter,
795795
bool mySnappingFlag = true;
796796
QColor mColour = Qt::black;
797797
// Hard coded sizes
798-
int myMajorTickSize=10;
799798
int myTextOffsetX=0;
800799
int myTextOffsetY=5;
801800
int myXMargin=20;
@@ -935,14 +934,14 @@ void QgsQuickPrint::renderPrintScaleBar(QPainter * thepPainter,
935934
myStops << QGradientStop(1.0,QColor("#656565"));
936935
//draw again with the brush in the revers direction to complete teh glossiness
937936
QLinearGradient myReverseGlossyBrush(
938-
QPointF(myOriginX,myOriginY + myMajorTickSize*3),
937+
QPointF(myOriginX,myOriginY + myFontHeight*3),
939938
QPointF(myOriginX,myOriginY));
940939
thepPainter->setBrush(myReverseGlossyBrush);
941940
thepPainter->drawRect(
942941
myOriginX,
943942
myOriginY,
944943
myOriginX + myScaleBarWidthInt,
945-
myOriginY + myMajorTickSize
944+
myOriginY + myFontHeight
946945
);
947946

948947
//
@@ -953,7 +952,6 @@ void QgsQuickPrint::renderPrintScaleBar(QPainter * thepPainter,
953952
//Draw the minimum label buffer
954953
thepPainter->setPen( myBackColor );
955954
myFontWidth = myFontMetrics.width( "0" );
956-
myFontHeight = myFontMetrics.height();
957955

958956
for (int i = 0-myBufferSize; i <= myBufferSize; i++)
959957
{
@@ -1003,22 +1001,21 @@ void QgsQuickPrint::renderPrintScaleBar(QPainter * thepPainter,
10031001
//
10041002
thepPainter->setPen( myBackColor );
10051003
myFontWidth = myFontMetrics.width( myScaleBarUnitLabel );
1006-
myFontHeight = myFontMetrics.height();
10071004
//first the buffer
10081005
for (int i = 0-myBufferSize; i <= myBufferSize; i++)
10091006
{
10101007
for (int j = 0-myBufferSize; j <= myBufferSize; j++)
10111008
{
10121009
thepPainter->drawText( i + (myOriginX+myScaleBarWidthInt+myTextOffsetX),
1013-
j + myOriginY + myMajorTickSize + (myFontHeight*2.5) + myTextOffsetY,
1010+
j + myOriginY + myFontHeight + (myFontHeight*2.5) + myTextOffsetY,
10141011
myScaleBarUnitLabel);
10151012
}
10161013
}
10171014
//then the text itself
10181015
thepPainter->setPen( myForeColor );
10191016
thepPainter->drawText(
10201017
myOriginX + myScaleBarWidthInt + myTextOffsetX,
1021-
myOriginY + myMajorTickSize + (myFontHeight*2.5) + myTextOffsetY,
1018+
myOriginY + myFontHeight + (myFontHeight*2.5) + myTextOffsetY,
10221019
myScaleBarUnitLabel
10231020
);
10241021
}

0 commit comments

Comments
 (0)