// ArabTeX, though, cannot handle this special behavior, it seems.
bool arabtex = basefont.language()->lang() == "arabic_arabtex"
|| running_font.language()->lang() == "arabic_arabtex";
- if (open_font && inset->noFontChange()) {
+ if (open_font && !inset->inheritFont()) {
bool closeLanguage = arabtex
|| basefont.isRightToLeft() == running_font.isRightToLeft();
unsigned int count = running_font.latexWriteEndChanges(os,
Font const & font, Font const & display_font);
/** Needed to propagate font changes to all text cells of insets
- * that are not allowed inside a font change (bug 1973).
+ * that are not allowed inside a font change (bugs 1973, 6919).
* Must not be called if \p pos denotes an ordinary character or an
* inset that is alowed inside a font change.
- * FIXME: This should be removed, see documentation of noFontChange
- * in insetbase.h
*/
void setInsetFont(BufferView const & bv, pit_type pit, pos_type pos,
Font const & font, bool toggleall = false);
pos_type pos, Font const & font, bool toggleall)
{
Inset * const inset = pars_[pit].getInset(pos);
- LASSERT(inset && inset->noFontChange(), /**/);
+ LASSERT(inset && inset->resetFontEdit(), /**/);
CursorSlice::idx_type endidx = inset->nargs();
for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
pit_type const pit = dit.pit();
pos_type const pos = dit.pos();
Inset * inset = pars_[pit].getInset(pos);
- if (inset && inset->noFontChange()) {
+ if (inset && inset->resetFontEdit()) {
// We need to propagate the font change to all
- // text cells of the inset (bug 1973).
- // FIXME: This should change, see documentation
- // of noFontChange in Inset.h
+ // text cells of the inset (bugs 1973, 6919).
setInsetFont(bv, pit, pos, font, toggleall);
}
TextMetrics const & tm = bv.textMetrics(this);
}
// redo insets
- // FIXME: We should always use getFont(), see documentation of
- // noFontChange() in Inset.h.
Font const bufferfont = buffer.params().getFont();
InsetList::const_iterator ii = par.insetList().begin();
InsetList::const_iterator iend = par.insetList().end();
Dimension dim;
int const w = max_width_ - leftMargin(max_width_, pit, ii->pos)
- right_margin;
- Font const & font = ii->inset->noFontChange() ?
- bufferfont : displayFont(pit, ii->pos);
+ Font const & font = ii->inset->inheritFont() ?
+ displayFont(pit, ii->pos) : bufferfont;
MacroContext mc(&buffer, parPos);
MetricsInfo mi(bv_, font.fontInfo(), w, mc);
ii->inset->metrics(mi, dim);
/// returns whether this inset is allowed in other insets of given mode
virtual bool allowedIn(mode_type) const { return true; }
/**
- * Is this inset allowed within a font change?
- *
- * FIXME: noFontChange means currently that the font change is closed
- * in LaTeX before the inset, and that the contents of the inset
- * will be in default font. This should be changed so that the inset
- * changes the font again.
+ * The font is inherited from the parent for LaTeX export if this
+ * method returns true. No open font changes are closed in front of
+ * the inset for LaTeX export, and the font is inherited for all other
+ * exports as well as on screen.
+ * If this method returns false all open font changes are closed in
+ * front of the inset for LaTeX export. The default font is used
+ * inside the inset for all exports and on screen.
+ */
+ virtual bool inheritFont() const { return true; }
+ /**
+ * If this method returns true all explicitly set font attributes
+ * are reset during editing operations.
+ * For copy/paste the operations the language is never changed, since
+ * the language of a given text never changes if the text is
+ * formatted differently, while other font attribues like size may
+ * need to change if the text is copied from one environment to
+ * another one.
+ * If it returns false no font attribute is reset.
+ * The default implementation returns the negation of inheritFont(),
+ * since inherited inset font attributes do not need to be changed,
+ * and non-inherited ones need to be set explicitly.
*/
- virtual bool noFontChange() const { return false; }
+ virtual bool resetFontEdit() const { return !inheritFont(); }
/// set the change for the entire inset
virtual void setChange(Change const &) {}
bool forcePlainLayout(idx_type = 0) const;
///
bool neverIndent() const { return true; }
- ///
- bool noFontChange() const { return true; }
+ /** returns false if, when outputing LaTeX, font changes should
+ be closed before generating this inset. This is needed for
+ insets that may contain several paragraphs */
+ bool inheritFont() const { return false; }
///
void latex(otexstream &, OutputParams const &) const;
///
}
+bool InsetFlex::resetFontEdit() const
+{
+ if (getLayout().resetsFont())
+ return true;
+ return InsetCollapsable::resetFontEdit();
+}
+
+
InsetLayout::InsetDecoration InsetFlex::decoration() const
{
InsetLayout::InsetDecoration const dec = getLayout().decoration();
InsetLayout const & getLayout() const;
///
InsetCode lyxCode() const { return FLEX_CODE; }
+ ///
+ bool resetFontEdit() const;
/// Default looks
InsetLayout::InsetDecoration decoration() const;
///
void write(std::ostream &) const;
/// should paragraph indendation be ommitted in any case?
- bool neverIndent() const { return true; }
+ bool neverIndent() const { return true; }
///
bool hasSettings() const { return false; }
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
bool insetAllowed(InsetCode) const;
- /** returns true if, when outputing LaTeX, font changes should
+ /** returns false if, when outputing LaTeX, font changes should
be closed before generating this inset. This is needed for
insets that may contain several paragraphs */
- bool noFontChange() const { return true; }
+ bool inheritFont() const { return false; }
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
// Update the counters of this inset and of its contents
void write(std::ostream & os) const;
///
bool insetAllowed(InsetCode) const;
- /** returns true if, when outputing LaTeX, font changes should
+ /** returns false if, when outputing LaTeX, font changes should
be closed before generating this inset. This is needed for
insets that may contain several paragraphs */
- bool noFontChange() const { return true; }
+ bool inheritFont() const { return false; }
};
private:
///
bool isLabeled() const { return true; }
- ///
- bool noFontChange() const { return true; }
+ /// false is needed since listings do their own font handling.
+ bool inheritFont() const { return false; }
///
InsetCode lyxCode() const { return LISTINGS_CODE; }
/// lstinline is inlined, normal listing is displayed
docstring name() const;
///
DisplayType display() const;
- ///
- bool noFontChange() const { return params_.type != InsetNoteParams::Note; }
+ /** returns false if, when outputing LaTeX, font changes should
+ be closed before generating this inset. This is needed for
+ insets that may contain several paragraphs */
+ bool inheritFont() const { return params_.type == InsetNoteParams::Note; }
/// Is the content of this inset part of the output document?
bool producesOutput() const
{ return params_.type == InsetNoteParams::Greyedout; }
bool allowSpellCheck() const { return true; }
///
bool canTrackChanges() const { return true; }
- /** returns true if, when outputing LaTeX, font changes should
+ /** returns false if, when outputing LaTeX, font changes should
be closed before generating this inset. This is needed for
insets that may contain several paragraphs */
- bool noFontChange() const { return true; }
+ bool inheritFont() const { return false; }
///
DisplayType display() const;
///
///
int plaintext(odocstream &, OutputParams const &) const;
///
- bool noFontChange() const { return true; }
+ bool inheritFont() const { return false; }
///
docstring name() const;
// requires a full repaint
bool pi_full_repaint = pi_.full_repaint;
- // FIXME: We should always use font, see documentation of
- // noFontChange() in Inset.h.
- pi_.base.font = inset->noFontChange() ?
- pi_.base.bv->buffer().params().getFont().fontInfo() :
- font.fontInfo();
+ pi_.base.font = inset->inheritFont() ? font.fontInfo() :
+ pi_.base.bv->buffer().params().getFont().fontInfo();
pi_.ltr_pos = (bidi_.level(pos) % 2 == 0);
pi_.change_ = change_.changed() ? change_ : par_.lookupChange(pos);