Hi Oliver,
I propose the attached patch to improve screen font size selection. It
implements the following changes:
- calculate font size based on average char width
- limit font size to a min/max range
- make font size (in points) independent from logical dpi
The result for common screen sizes and QMS window configurations should
be the same as previously.
I did nothing for printing. I have a quickshot patch for my immediate
need. A product solution could be similar to the printer preview of
Firefox or to save the HTML doc in a file, which is probably more simple
to implement.
Rainer
Am 16.08.2015 um 21:04 schrieb Oliver Eichler:> Hi Rainer,
>
> a configuration dialog is always a bad idea anyway.
>
> On my systems the print and desktop version look pretty much the same in
> terms of line breaks. But I never spent too much time to dig into the Qt
> docs about resolution and stuff. It should be possible to get all this
> information.
>
> Anyway the opinion about a readable font size will differ. So maybe a
> combobox to increase the fontsize by -2..2 could be a solution. It could
> be placed next to the sorting mode.
>
> I did quite some changes to get rid of crashes in the CDetailsPrj class
> today. So you want to update before you proceed.
>
> Oliver
>
diff -Naur qmapshack_orig/src/gis/prj/CDetailsPrj.cpp
qmapshack/src/gis/prj/CDetailsPrj.cpp
--- qmapshack_orig/src/gis/prj/CDetailsPrj.cpp 2015-08-19 11:20:31.102521000
+0200
+++ qmapshack/src/gis/prj/CDetailsPrj.cpp 2015-08-19 11:23:17.211334041
+0200
@@ -137,7 +137,10 @@
}
#define ROOT_FRAME_MARGIN 5
-#define CHAR_PER_LINE 130
+#define CHAR_PER_LINE 210
+#define STD_FONT_SIZE 12
+#define MAX_FONT_SIZE 14
+#define MIN_FONT_SIZE 6
bool sortTrkByTime(const CGisItemTrk * trk1, const CGisItemTrk * trk2)
{
@@ -154,13 +157,18 @@
int w = doc.textWidth();
int nItems = 0;
- QFontMetrics fm(QFont(font().family(),12));
- int pointSize = ((10 * (w - 2 * ROOT_FRAME_MARGIN)) / (CHAR_PER_LINE *
fm.width("X")));
- if(pointSize == 0)
+ QFontMetrics fm(QFont(font().family(),STD_FONT_SIZE));
+ int pointSize = (qreal)(w - 2 * ROOT_FRAME_MARGIN) /
(fm.averageCharWidth() * CHAR_PER_LINE) * STD_FONT_SIZE;
+ if (pointSize > MAX_FONT_SIZE)
{
- return;
+ pointSize = MAX_FONT_SIZE;
}
-
+ if (pointSize < MIN_FONT_SIZE)
+ {
+ pointSize = MIN_FONT_SIZE;
+ }
+ qDebug() << "pointSize:" << pointSize;
+
QFont f = textDesc->font();
f.setPointSize(pointSize);
textDesc->setFont(f);
------------------------------------------------------------------------------
_______________________________________________
Qlandkartegt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users