[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Fri Jul 25 23:51:26 CEST 2008
SVN commit 837860 by fenton:
Fix for printing errors.
Convert all font sizing to pixel based.
M +2 -2 arrowitem.cpp
M +1 -1 labelrenderer.cpp
M +2 -12 labelrenderer.h
M +1 -1 legenditem.cpp
M +1 -1 mainwindow.cpp
M +4 -4 plotitem.cpp
M +5 -3 view.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/arrowitem.cpp #837859:837860
@@ -45,7 +45,7 @@
painter->drawLine(line());
if (_startArrowHead) {
- double deltax = (parentView()->defaultFont().pointSizeF() / 2) * _startArrowScale;
+ double deltax = (parentView()->defaultFont().pixelSize() / 2) * _startArrowScale;
double theta = atan2(double(line().y2() - line().y1()), double(line().x2() - line().x1())) - M_PI / 2.0;
double sina = sin(theta);
double cosa = cos(theta);
@@ -64,7 +64,7 @@
}
if (_endArrowHead) {
- double deltax = (parentView()->defaultFont().pointSizeF() / 2) * _endArrowScale;
+ double deltax = (parentView()->defaultFont().pixelSize() / 2) * _endArrowScale;
double theta = atan2(double(line().y1() - line().y2()), double(line().x1() - line().x2())) - M_PI / 2.0;
double sina = sin(theta);
double cosa = cos(theta);
--- branches/work/kst/portto4/kst/src/libkstapp/labelrenderer.cpp #837859:837860
@@ -54,7 +54,7 @@
QFont f = rc.font();
if (rc.fontSize() != rc.size) {
- f.setPointSize(rc.size);
+ f.setPixelSize(rc.size);
}
if (fi->attributes.bold) {
--- branches/work/kst/portto4/kst/src/libkstapp/labelrenderer.h #837859:837860
@@ -50,18 +50,8 @@
inline void setFont(const QFont& f_in) {
QFont f = f_in;
- _fontSize = f.pointSize();
- // Here is the 'interesting' bit: elsewhere, the label size has been adjusted according to the
- // size of the view window it is being drawn into. This is what we want to do, so that, ignoring
- // aspect ratios being different, a plot (and its children) will be WYSIWYG.
- // So we really should have been specifying the font sizes by their pixel size, rather than by
- // point size (which cares about DPI).
- // BUT: QFont constructs with point size, so here we convert the font to being specified
- // according to pixel size, not point size...
- // TODO REVIEW THIS! Either everything needs to do it this way or no one.
-// if (_fontSize>0) {
-// f.setPixelSize(_fontSize); // device independence has been handled elsewhere - use pixels
-// }
+ _fontSize = f.pixelSize();
+
if (p) {
p->setFont(f);
_ascent = p->fontMetrics().ascent();
--- branches/work/kst/portto4/kst/src/libkstapp/legenditem.cpp #837859:837860
@@ -71,7 +71,7 @@
QSize legendSize(0, 0);
QFont font(_font);
- font.setPointSizeF(parentView()->defaultFont(_fontScale).pointSizeF());
+ font.setPixelSize(parentView()->defaultFont(_fontScale).pixelSize());
foreach(RelationPtr relation, legendItems) {
DrawnLegendItem item;
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #837859:837860
@@ -300,7 +300,7 @@
for (int i = 0; i < printer.numCopies(); ++i) {
foreach (QGraphicsView *view, pages) {
- view->render(&painter, QRectF(), QRect(), Qt::KeepAspectRatio /* IgnoreAspectRatio */);
+ view->render(&painter);
printer.newPage();
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #837859:837860
@@ -1296,7 +1296,7 @@
QFont PlotItem::calculatedLeftLabelFont() {
QFont font(_leftLabelFont);
- font.setPointSizeF(parentView()->defaultFont(_leftLabelFontScale).pointSizeF());
+ font.setPixelSize(parentView()->defaultFont(_leftLabelFontScale).pixelSize());
return font;
}
@@ -1304,7 +1304,7 @@
QFont PlotItem::calculatedRightLabelFont() {
QFont font(_rightLabelFont);
- font.setPointSizeF(parentView()->defaultFont(_rightLabelFontScale).pointSizeF());
+ font.setPixelSize(parentView()->defaultFont(_rightLabelFontScale).pixelSize());
return font;
}
@@ -1312,7 +1312,7 @@
QFont PlotItem::calculatedTopLabelFont() {
QFont font(_topLabelFont);
- font.setPointSizeF(parentView()->defaultFont(_topLabelFontScale).pointSizeF());
+ font.setPixelSize(parentView()->defaultFont(_topLabelFontScale).pixelSize());
return font;
}
@@ -1320,7 +1320,7 @@
QFont PlotItem::calculatedBottomLabelFont() {
QFont font(_bottomLabelFont);
- font.setPointSizeF(parentView()->defaultFont(_bottomLabelFontScale).pointSizeF());
+ font.setPixelSize(parentView()->defaultFont(_bottomLabelFontScale).pixelSize());
return font;
}
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #837859:837860
@@ -380,7 +380,7 @@
fontSize = ApplicationSettings::self()->minimumFontSize();
}
- _defaultFont.setPointSizeF(fontSize);
+ _defaultFont.setPixelSize(fontSize);
_defaultFont.setFamily(ApplicationSettings::self()->defaultFontFamily());
}
@@ -390,13 +390,15 @@
qreal fontSize = (qreal)(height() + width()) / (ApplicationSettings::self()->referenceViewHeight() + ApplicationSettings::self()->referenceViewWidth());
fontSize *= scale;
- fontSize += font.pointSizeF();
+ fontSize += font.pixelSize();
if (fontSize < ApplicationSettings::self()->minimumFontSize()) {
fontSize = ApplicationSettings::self()->minimumFontSize();
}
- font.setPointSizeF(fontSize);
+ if (fontSize > 0) {
+ font.setPixelSize(fontSize);
+ }
return font;
}
More information about the Kst
mailing list