From c0cebba1d7ada05eb10e3a634940e7cac3633713 Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Wed, 12 Feb 2003 08:50:16 +0000 Subject: [PATCH] Fix 'lyx -e' with the QT frontend. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6113 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/qfont_metrics.C | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 482dba9fd8..f0f599ed70 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2003-02-12 Dekel Tsur + + * 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 * ui/QMathMatrixDialogBase.ui: Fix horizontal alignment tooltip diff --git a/src/frontends/qt2/qfont_metrics.C b/src/frontends/qt2/qfont_metrics.C index c464ecbadb..5e962c6f81 100644 --- a/src/frontends/qt2/qfont_metrics.C +++ b/src/frontends/qt2/qfont_metrics.C @@ -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); }