The goal of my algorithm is to have roughly CHAR_PER_LINE characters on
a line independently from screen resolution, screen dimension, window
size and dots per inch. I increased CHAR_PER_LINE to 210 to get not too
small fonts on my screen (1680x1050, 22 inch, 96dpi). Putting it back to
130 will probably be ok for your configuration but result in a bit large
fonts on my screen.
If the result of the patch is not ok for you, I suggest to add just the
minimum font part of it.
Am 19.08.2015 um 13:01 schrieb Oliver Eichler:
Hi Rainer,
after the patch the font is quite small on my screen. (see qms1.png) The
second screenshot (qms2.png) is the original code.
It has to be kind of dependent of the screen resolution. You should get
this with QGuiApplication::screens(), passing back a list of
QScreen objects.
Oliver
Am 19.08.2015 um 12:46 schrieb rainerU:
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
------------------------------------------------------------------------------
_______________________________________________
Qlandkartegt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users
------------------------------------------------------------------------------
--- qmapshack_orig/src/gis/prj/CDetailsPrj.cpp 2015-08-19 11:20:31.102521000
+0200
+++ qmapshack/src/gis/prj/CDetailsPrj.cpp 2015-08-19 16:33:39.377312029
+0200
@@ -138,6 +138,9 @@
#define ROOT_FRAME_MARGIN 5
#define CHAR_PER_LINE 130
+#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