]> git.lyx.org Git - features.git/commitdiff
Fix bug 4182, partially:
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 24 Sep 2007 17:51:15 +0000 (17:51 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 24 Sep 2007 17:51:15 +0000 (17:51 +0000)
* src/insets/InsetCaption.cpp (draw, metrics):
- set correct font for caption in Workarea.
* src/insets/insetListings.cpp (latex):
- try to set correct font for caption in output (doesn't work yet).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20472 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetCaption.cpp
src/insets/InsetListings.cpp

index 98d0dd01160ba1615c7a3fdf0b231bbcd5112252..171606137ebb7b463152708e04099e314b5daa89 100644 (file)
@@ -127,6 +127,8 @@ void InsetCaption::addToToc(TocList & toclist, Buffer const & buf, ParConstItera
 
 void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
 {
+       Font tmpfont = mi.base.font;
+       mi.base.font = mi.base.bv->buffer().params().getFont();
        labelwidth_ = theFontMetrics(mi.base.font).width(full_label_);
        // add some space to separate the label from the inset text
        labelwidth_ += 2 * TEXT_TO_INSET_OFFSET;
@@ -135,6 +137,7 @@ void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
        // Correct for button and label width
        mi.base.textwidth -= dim.wid;
        InsetText::metrics(mi, textdim);
+       mi.base.font = tmpfont;
        mi.base.textwidth += dim.wid;
        dim.des = std::max(dim.des - textdim.asc + dim.asc, textdim.des);
        dim.asc = textdim.asc;
@@ -152,8 +155,11 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const
 
        // Answer: the text inset (in buffer_funcs.cpp: setCaption).
 
+       Font tmpfont = pi.base.font;
+       pi.base.font = pi.base.bv->buffer().params().getFont();
        pi.pain.text(x, y, full_label_, pi.base.font);
        InsetText::draw(pi, x + labelwidth_, y);
+       pi.base.font = tmpfont;
 }
 
 
index 0c6b472da86d171f4f73db9d0686dc52fcaa8fb2..cfbcf8d1d6588828123fd69c3bc01310b0ce0887 100644 (file)
@@ -198,7 +198,13 @@ int InsetListings::latex(Buffer const & buf, odocstream & os,
                 os << code
                    << *delimiter;
        } else {
-               docstring const caption = getCaption(buf, runparams);
+               OutputParams rp = runparams;
+               // FIXME: the line below would fix bug 4182,
+               // but real_current_font moved to cursor.
+               //rp.local_font = &text_.real_current_font;
+               rp.moving_arg = true;
+               docstring const caption = getCaption(buf, rp);
+               runparams.encoding = rp.encoding;
                if (param_string.empty() && caption.empty())
                        os << "\n\\begingroup\n\\inputencoding{latin1}\n\\begin{lstlisting}\n";
                else {