This code was previously in InsetCollapsible for no good reason.
Move it to a new function InsetText::setOuterFont, which can now be
called for other purposes.
Part of investigation of bug #12204.
{
view_[mi.base.bv].auto_open_ = mi.base.bv->cursor().isInside(this);
{
view_[mi.base.bv].auto_open_ = mi.base.bv->cursor().isInside(this);
- FontInfo tmpfont = mi.base.font;
- mi.base.font = getFont();
- mi.base.font.realize(tmpfont);
-
BufferView const & bv = *mi.base.bv;
switch (geometry(bv)) {
BufferView const & bv = *mi.base.bv;
switch (geometry(bv)) {
-
- mi.base.font = tmpfont;
+void InsetText::setOuterFont(BufferView & bv, FontInfo const & outer) const
+{
+ TextMetrics & tm = bv.textMetrics(&text_);
+ FontInfo tmpfont = getFont();
+ tmpfont.realize(outer);
+ tm.font_.fontInfo() = tmpfont;
+}
+
+
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
{
TextMetrics & tm = mi.base.bv->textMetrics(&text_);
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
{
TextMetrics & tm = mi.base.bv->textMetrics(&text_);
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
int const horiz_offset = leftOffset(mi.base.bv) + rightOffset(mi.base.bv);
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << endl;
int const horiz_offset = leftOffset(mi.base.bv) + rightOffset(mi.base.bv);
-
- // Hand font through to contained lyxtext:
- tm.font_.fontInfo() = mi.base.font;
mi.base.textwidth -= horiz_offset;
mi.base.textwidth -= horiz_offset;
+ // Remember the full outer font
+ setOuterFont(*mi.base.bv, mi.base.font);
+ // and use it in these metrics computation.
+ mi.base.font = tm.font_.fontInfo();
+
// This can happen when a layout has a left and right margin,
// and the view is made very narrow. We can't do better than
// to draw it partly out of view (bug 5890).
// This can happen when a layout has a left and right margin,
// and the view is made very narrow. We can't do better than
// to draw it partly out of view (bug 5890).
void read(Lexer & lex) override;
///
void write(std::ostream & os) const override;
void read(Lexer & lex) override;
///
void write(std::ostream & os) const override;
+ /// Let the inset compute and store its reference font from \c outer.
+ void setOuterFont(BufferView & bv, FontInfo const & outer) const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const override;
///
///
void metrics(MetricsInfo & mi, Dimension & dim) const override;
///