Fix 'lyx -e' with the QT frontend.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6113 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2003-02-12 08:50:16 +00:00
parent 84f1457439
commit c0cebba1d7
2 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2003-02-12 Dekel Tsur <dekelts@tau.ac.il>
* qfont_metrics.C: Add checks for lyxrc.use_gui.
This fixes 'lyx -e' with the QT frontend.
2003-02-10 João Luis Meloni Assirati <assirati@fma.if.usp.br>
* ui/QMathMatrixDialogBase.ui: Fix horizontal alignment tooltip

View File

@ -35,6 +35,8 @@ QFontMetrics const & metrics(LyXFont const & f)
int charwidth(Uchar val, LyXFont const & f)
{
if (!lyxrc.use_gui)
return 1;
return fontloader.charwidth(f, val);
}
@ -45,12 +47,16 @@ namespace font_metrics {
int maxAscent(LyXFont const & f)
{
if (!lyxrc.use_gui)
return 1;
return metrics(f).ascent();
}
int maxDescent(LyXFont const & f)
{
if (!lyxrc.use_gui)
return 1;
// We add 1 as the value returned by QT is different than X
// See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
return metrics(f).descent() + 1;
@ -59,6 +65,8 @@ int maxDescent(LyXFont const & f)
int ascent(char c, LyXFont const & f)
{
if (!lyxrc.use_gui)
return 1;
QRect const & r = metrics(f).boundingRect(c);
return -r.top();
}
@ -66,6 +74,8 @@ int ascent(char c, LyXFont const & f)
int descent(char c, LyXFont const & f)
{
if (!lyxrc.use_gui)
return 1;
QRect const & r = metrics(f).boundingRect(c);
return r.bottom()+1;
}
@ -73,12 +83,16 @@ int descent(char c, LyXFont const & f)
int lbearing(char c, LyXFont const & f)
{
if (!lyxrc.use_gui)
return 1;
return metrics(f).leftBearing(c);
}
int rbearing(char c, LyXFont const & f)
{
if (!lyxrc.use_gui)
return 1;
QFontMetrics const & m(metrics(f));
// Qt rbearing is from the right edge of the char's width().
@ -97,6 +111,8 @@ Encoding const * fontencoding(LyXFont const & f)
int smallcapswidth(char const * s, size_t ls, LyXFont const & f)
{
if (!lyxrc.use_gui)
return 1;
// handle small caps ourselves ...
LyXFont smallfont(f);
@ -123,6 +139,9 @@ int smallcapswidth(char const * s, size_t ls, LyXFont const & f)
int width(char const * s, size_t ls, LyXFont const & f)
{
if (!lyxrc.use_gui)
return ls;
if (f.realShape() == LyXFont::SMALLCAPS_SHAPE) {
return smallcapswidth(s, ls, f);
}