From d5d5562e0292d69fdd511bb13f715827eded652e Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Sun, 10 Apr 2005 14:07:33 +0000 Subject: [PATCH] Fix font inside inset (bugs 1766, 1809) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9799 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/insets/ChangeLog | 7 +++++++ src/insets/insetcharstyle.C | 4 ++++ src/insets/insetert.C | 3 +++ src/insets/insetfootlike.C | 19 +++++++++++++++++++ src/insets/insetfootlike.h | 4 ++++ src/rowpainter.C | 10 ++++++++-- 7 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 9930e770a9..7f3c5915d9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-04-10 Martin Vermeer + + * rowpainter.C (RowPainter, getFont): fix font inside inset + (bugs 1766, 1809) + 2005-04-06 Martin Vermeer * CutAndPaste.C (eraseSelection): more precise fix for bug 1654, diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 6533543083..c6aa3b772d 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2005-04-10 Martin Vermeer + + * insetcharstyle.C (metrics, draw): + * insetert.C (metrics, draw): + * insetfootlike.[Ch] (metrics, draw): fix font inside inset + (bugs 1766, 1809) + 2005-04-05 Martin Vermeer * insetexternal.C (validate): diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index c9d8ecf515..f904390fe1 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -102,6 +102,8 @@ void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont tmpfont = mi.base.font; getDrawFont(mi.base.font); + mi.base.font.reduce(LyXFont(LyXFont::ALL_SANE)); + mi.base.font.realize(tmpfont); mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET; InsetText::metrics(mi, dim); mi.base.font = tmpfont; @@ -121,6 +123,8 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const LyXFont tmpfont = pi.base.font; getDrawFont(pi.base.font); + // I don't understand why the above .reduce and .realize aren't + //needed, or even wanted, here. It just works. -- MV 10.04.2005 InsetText::draw(pi, x, y); pi.base.font = tmpfont; diff --git a/src/insets/insetert.C b/src/insets/insetert.C index b15c22b511..72ac3ef684 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -373,6 +373,7 @@ void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont tmpfont = mi.base.font; getDrawFont(mi.base.font); + mi.base.font.realize(tmpfont); InsetCollapsable::metrics(mi, dim); mi.base.font = tmpfont; dim_ = dim; @@ -383,6 +384,8 @@ void InsetERT::draw(PainterInfo & pi, int x, int y) const { LyXFont tmpfont = pi.base.font; getDrawFont(pi.base.font); + // I don't understand why the above .realize isn't needed, or + // even wanted, here. It just works. -- MV 10.04.2005 InsetCollapsable::draw(pi, x, y); pi.base.font = tmpfont; } diff --git a/src/insets/insetfootlike.C b/src/insets/insetfootlike.C index 19cea62904..6e33522aed 100644 --- a/src/insets/insetfootlike.C +++ b/src/insets/insetfootlike.C @@ -42,6 +42,25 @@ InsetFootlike::InsetFootlike(InsetFootlike const & in) } +void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const +{ + LyXFont tmpfont = mi.base.font; + mi.base.font = LyXFont(LyXFont::ALL_SANE); + InsetCollapsable::metrics(mi, dim); + mi.base.font = tmpfont; + dim_ = dim; +} + + +void InsetFootlike::draw(PainterInfo & pi, int x, int y) const +{ + LyXFont tmpfont = pi.base.font; + pi.base.font = LyXFont(LyXFont::ALL_SANE); + InsetCollapsable::draw(pi, x, y); + pi.base.font = tmpfont; +} + + void InsetFootlike::write(Buffer const & buf, ostream & os) const { os << getInsetName() << "\n"; diff --git a/src/insets/insetfootlike.h b/src/insets/insetfootlike.h index 0a7fd2c025..09752a8d49 100644 --- a/src/insets/insetfootlike.h +++ b/src/insets/insetfootlike.h @@ -24,6 +24,10 @@ public: /// InsetFootlike(InsetFootlike const &); /// + void metrics(MetricsInfo &, Dimension &) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// void write(Buffer const & buf, std::ostream & os) const; /// bool insetAllowed(InsetBase::Code) const; diff --git a/src/rowpainter.C b/src/rowpainter.C index 36c354a55c..438c5125e8 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -115,6 +115,9 @@ private: double separator_; double hfill_; double label_hfill_; + + // Hack to get 1.4cvs working + LyXFont font_; }; @@ -122,7 +125,7 @@ RowPainter::RowPainter(PainterInfo & pi, LyXText const & text, pit_type pit, Row const & row, int x, int y) : bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()), row_(row), pit_(pit), par_(text.paragraphs()[pit]), - xo_(x), yo_(y), width_(text_.width()) + xo_(x), yo_(y), width_(text_.width()), font_(pi.base.font) { RowMetrics m = text_.computeRowMetrics(pit, row_); x_ = m.x + xo_; @@ -142,7 +145,10 @@ RowPainter::RowPainter(PainterInfo & pi, /// "temporary" LyXFont const RowPainter::getFont(pos_type pos) const { - return text_.getFont(par_, pos); + LyXFont lf(font_); + lf.reduce(LyXFont(LyXFont::ALL_SANE)); + lf.realize(text_.getFont(par_, pos)); + return lf; } -- 2.39.2