LyX needs help: Broken font metrics computation
Ruurd Reitsma
rareitsma at yahoo.com
Wed Jan 5 14:59:43 CET 2005
"Michael Schmitt" <michael.schmitt at teststep.org>
wrote in message news:006201c4f291$7bbc8a70$14b2a8c0 at fachwerkrechner...
> However, we have a serious problem with the computation of font metrics. I
> have generated a small test case that illustrates the problem:
>
> #include <qapplication.h>
>
> int main(int argc, char **argv) {
> QApplication app(argc, argv);
> QFont f("times",18,QFont::Bold);
> QFontMetrics fm(f);
> QRect r = fm.boundingRect('x');
> printf( "top: %d bottom: %d", r.top(), r.bottom());
> return 0;
> }
>
> If you compile and run this program with GPL'd Qt/Win32, it outputs
>
> top: 16 bottom:36
>
> However, if you run exactly the same program with Qt/X11 on cygwin (or on
> Linux), you get the following output:
>
> top: -9 bottom: -1
>
On the Lyx side, this helps:
--- ../../qfont_metrics.C 2003-02-14 12:22:48.000000000 +0100
+++ frontends/qt2/qfont_metrics.C 2005-01-05 14:32:20.677692800 +0100
@@ -77,7 +77,11 @@
if (!lyxrc.use_gui)
return 1;
QRect const & r = metrics(f).boundingRect(c);
+#if defined(Q_WS_WIN)
+ return -r.bottom()-1;
+#else
return r.bottom()+1;
+#endif
}
At least, with Non-Commercial 3.2.1. Here, the
lyx_gui::needs_ugly_metrics_hack() is also needed. This ugly_metrics_hack is
not needed for the free 3.3.3.
Anyway, I don´t have a X11 LyX handy to compare with. I suspect the
horizontal metrics are also inverted (accents etc.)
Ruurd
More information about the kde-cygwin
mailing list