From: <ai...@us...> - 2014-04-01 19:53:17
|
Revision: 13091 http://sourceforge.net/p/plplot/code/13091 Author: airwin Date: 2014-04-01 19:53:12 +0000 (Tue, 01 Apr 2014) Log Message: ----------- Apply empirically derived (using examples/python/test_circle.py) and examples/python/x02) vertical offset for all text for the Qt5 case. This vertical offset is substantial (greater than half the character box height) and roughly constant for most glyphs/fonts. However, the final value was optimized for the light diagonal cross glyph in test_circle.py. That example shows that other glyphs (except for the well-known asterisk case which is vertically misaligned by font design) have a dispersion in vertical alignments that is larger than for cairo which in turn is larger than for qt with Qt4. Both those latter dispersion results were derived with no empirical vertical offset at all. An additional issue which confuses the issue concerning the best vertical alignment for qt with Qt5, cairo, and qt with Qt4 is the font selection for all those cases is different (as evidenced by different sizes/shapes of glyphs in all three cases and missing glyphs (i.e., Korean for example 24) for the Qt5 case which are present in the other cases. I assume all these issues are due to Qt5 version 5.2.1 font selection and font alignment issues which will be addressed for future Qt5 versions. And when those Qt5 fixes occur, this empirical vertical offset will have to be changed or else withdrawn (set to zero). Modified Paths: -------------- trunk/bindings/qt_gui/plqt.cpp Modified: trunk/bindings/qt_gui/plqt.cpp =================================================================== --- trunk/bindings/qt_gui/plqt.cpp 2014-04-01 19:28:28 UTC (rev 13090) +++ trunk/bindings/qt_gui/plqt.cpp 2014-04-01 19:53:12 UTC (rev 13091) @@ -249,8 +249,27 @@ PLFLT old_sscale, sscale, old_soffset, soffset; PLINT level = 0; PLFLT dyOffset = 0.; - - yOffset = 0.; +#ifdef PLPLOT_USE_QT5 + // Empirical Y offset of text (needed for Qt5 for some reason). + // Note this was derived using the test_circle.py python script + // with the vertical alignment of the light diagonal cross + // optimized. That example shows that other glyphs (except for + // the well-known asterisk case which is vertically misaligned by + // font design) do not have the best vertical alignment. This is + // contrary to the results for cairo and qt with Qt4 which need no + // special empirical Y offset to get good vertical alignment for + // most glyphs of that example (other than the asterisk). An + // additional issue which confuses the decision concerning the + // best vertical alignment for qt with Qt5 is the font selection + // for qt with Qt5 is quite different than that for qt with Qt4 or + // cairo. I assume all these issues are due to Qt5 version 5.2.1 + // font selection and font alignment bugs which will be addressed + // for future Qt5 versions. + PLFLT empirical_yOffset = -0.63 * chrht * POINTS_PER_INCH / 25.4; +#else + PLFLT empirical_yOffset = 0.; +#endif + yOffset = empirical_yOffset; xOffset = 0.; // Scaling factor of 1.45 determined empirically to make all qt results @@ -292,7 +311,7 @@ // dyOffset = -0.5 * currentFontSize * ( 1.0 - sscale ); // But empirically this change in offset should not be applied // so leave it at its initial value of zero. - yOffset = -( currentFontSize * RISE_FACTOR * soffset + dyOffset ); + yOffset = empirical_yOffset - ( currentFontSize * RISE_FACTOR * soffset + dyOffset ); p.setFont( getFont( fci ) ); break; @@ -312,7 +331,7 @@ // dyOffset = 0.5 * currentFontSize * ( 1.0 - sscale ); // But empirically this change in offset should not be applied // so leave it at its initial value of zero. - yOffset = currentFontSize * RISE_FACTOR * soffset + dyOffset; + yOffset = empirical_yOffset + currentFontSize * RISE_FACTOR * soffset + dyOffset; p.setFont( getFont( fci ) ); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |