cur.real_current_font))
text->setCursor(cur, cur.pit(), cur.pos(),
false, !cur.boundary());
+ if (font.language() != ignore_language)
+ // We need a buffer update if we change the language
+ // (e.g., with info insets or if the selection contains
+ // a par label)
+ cur.forceBufferUpdate();
}
}
static bool doInsertInset(Cursor & cur, Text * text,
- FuncRequest const & cmd, bool edit, bool pastesel)
+ FuncRequest const & cmd, bool edit,
+ bool pastesel, bool resetfont = false)
{
Buffer & buffer = cur.bv().buffer();
BufferParams const & bparams = buffer.params();
if (inset_text) {
Font const & font = inset->inheritFont()
? cur.bv().textMetrics(text).displayFont(cur.pit(), cur.pos())
- : buffer.params().getFont();
+ : bparams.getFont();
inset_text->setOuterFont(cur.bv(), font.fontInfo());
}
cur.clearSelection(); // bug 393
cur.finishUndo();
if (inset_text) {
+ if (resetfont) {
+ // Reset of font (not language) is requested.
+ // Used by InsetIndex (#11961).
+ Language const * lang = cur.getFont().language();
+ Font font(bparams.getFont().fontInfo(), lang);
+ cur.paragraph().resetFonts(font);
+ }
inset_text->fixParagraphsFont();
cur.pos() = 0;
cur.pit() = 0;
case LFUN_INDEX_INSERT:
case LFUN_PREVIEW_INSERT:
case LFUN_SCRIPT_INSERT:
- case LFUN_IPA_INSERT:
+ case LFUN_IPA_INSERT: {
+ // Indexes reset font formatting (#11961)
+ bool const resetfont = cmd.action() == LFUN_INDEX_INSERT;
// Open the inset, and move the current selection
// inside it.
- doInsertInset(cur, this, cmd, true, true);
+ doInsertInset(cur, this, cmd, true, true, resetfont);
cur.posForward();
cur.setCurrentFont();
// Some insets are numbered, others are shown in the outline pane so
// let's update the labels and the toc backend.
cur.forceBufferUpdate();
break;
+ }
case LFUN_FLEX_INSERT: {
// Open the inset, and move the current selection
// leave this now in order to insert the next one.
if (inautoarg) {
cur.leaveInset(cur.inset());
+ cur.setCurrentFont();
cur.posForward();
if (arg.insertonnewline && cur.pos() > 0) {
FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
selectWordWhenUnderCursor(cur, WHOLE_WORD_STRICT);
Font font(ignore_font, lang);
toggleAndShow(cur, this, font, toggle);
- // We need a buffer update if we change the language
- // of an info inset
- if (cur.insetInSelection(INFO_CODE))
- cur.forceBufferUpdate();
break;
}
freeFonts.push(make_pair(props, font));
toggleall = toggle;
toggleAndShow(cur, this, font, toggleall);
- // We need a buffer update if we change the language
- // of an info inset
- if (cur.insetInSelection(INFO_CODE))
- cur.forceBufferUpdate();
cur.message(bformat(_("Text properties applied: %1$s"), props));
} else
LYXERR0("Invalid argument of textstyle-update");