Fix bug 4182:

* src/insets/InsetCaption.cpp (draw, metrics):
	- set correct font for caption in Workarea.
* src/insets/insetListings.cpp (latex):
	- set correct font for caption in output.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@20471 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-09-24 17:50:07 +00:00
parent 93a9613d9f
commit e244c4c2b4
3 changed files with 13 additions and 1 deletions

View File

@ -136,6 +136,8 @@ bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
computeFullLabel(*mi.base.bv->buffer());
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;
@ -145,6 +147,7 @@ bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
// Correct for button width, and re-fit
mi.base.textwidth -= dim.wid;
InsetText::metrics(mi, textdim);
mi.base.font = tmpfont;
dim.des = std::max(dim.des - textdim.asc + dim.asc, textdim.des);
dim.asc = textdim.asc;
dim.wid += textdim.wid;
@ -168,11 +171,14 @@ 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();
labelwidth_ = pi.pain.text(x, y, full_label_, pi.base.font);
// add some space to separate the label from the inset text
labelwidth_ += 2 * TEXT_TO_INSET_OFFSET;
InsetText::draw(pi, x + labelwidth_, y);
setPosCache(pi, x, y);
pi.base.font = tmpfont;
}

View File

@ -177,7 +177,11 @@ int InsetListings::latex(Buffer const & buf, odocstream & os,
else
os << "\\lstinline[" << from_ascii(param_string) << "]" << *delimiter;
} else {
docstring const caption = getCaption(buf, runparams);
OutputParams rp = runparams;
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 {

View File

@ -88,6 +88,8 @@ What's new
- Detect (pdf)tex's file:line:error style messages that are used by some
distributions and that caused LyX to ignore LaTeX errors (bug 4222).
- Fix LaTeX error with captions in Program Listings (bug 4182).
* USER INTERFACE:
- Fix a crash when closing a LyX window with document tabs (bug 4123).