mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 11:08:41 +00:00
Assure language is properly closed before non-inheriting inset.
This commit is contained in:
parent
8bc76ad9bb
commit
ef11fdc77d
@ -1027,43 +1027,66 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
|
|||||||
close = true;
|
close = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some insets cannot be inside a font change command.
|
|
||||||
// However, even such insets *can* be placed in \L or \R
|
|
||||||
// or their equivalents (for RTL language switches), so we don't
|
|
||||||
// close the language in those cases.
|
|
||||||
// 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->inheritFont() || inset->allowMultiPar())) {
|
if (open_font && (!inset->inheritFont() || inset->allowMultiPar())) {
|
||||||
|
// Some insets cannot be inside a font change command.
|
||||||
|
// However, even such insets *can* be placed in \L or \R
|
||||||
|
// or their equivalents (for RTL language switches), so we don't
|
||||||
|
// close the language in those cases.
|
||||||
|
// ArabTeX, though, cannot handle this special behavior, it seems.
|
||||||
|
bool arabtex = basefont.language()->lang() == "arabic_arabtex"
|
||||||
|
|| running_font.language()->lang() == "arabic_arabtex";
|
||||||
bool closeLanguage = arabtex
|
bool closeLanguage = arabtex
|
||||||
|| basefont.isRightToLeft() == running_font.isRightToLeft();
|
|| basefont.isRightToLeft() == running_font.isRightToLeft();
|
||||||
|
bool lang_closed = false;
|
||||||
|
bool lang_switched_at_inset = false;
|
||||||
|
// Close language if needed
|
||||||
|
if (closeLanguage) {
|
||||||
|
// We need prev_font here as language changes directly at inset
|
||||||
|
// will only be started inside the inset.
|
||||||
|
Font const prev_font = (i > 0) ?
|
||||||
|
owner_->getFont(bparams, i - 1, outerfont)
|
||||||
|
: running_font;
|
||||||
|
Font tmpfont(basefont);
|
||||||
|
tmpfont.setLanguage(prev_font.language());
|
||||||
|
bool needPar = false;
|
||||||
|
unsigned int count = tmpfont.latexWriteEndChanges(os, bparams, runparams,
|
||||||
|
basefont, basefont,
|
||||||
|
needPar, closeLanguage);
|
||||||
|
column += count;
|
||||||
|
lang_closed = count > 0;
|
||||||
|
lang_switched_at_inset = prev_font.language() != running_font.language();
|
||||||
|
}
|
||||||
|
// Now re-do font changes in a way needed here
|
||||||
|
// (using switches with multi-par insets)
|
||||||
InsetText const * textinset = inset->asInsetText();
|
InsetText const * textinset = inset->asInsetText();
|
||||||
bool const cprotect = textinset
|
bool const cprotect = textinset
|
||||||
? textinset->hasCProtectContent(runparams.moving_arg)
|
? textinset->hasCProtectContent(runparams.moving_arg)
|
||||||
&& !textinset->text().isMainText()
|
&& !textinset->text().isMainText()
|
||||||
: false;
|
: false;
|
||||||
unsigned int count = running_font.latexWriteStartChanges(os, bparams,
|
unsigned int count2 = running_font.latexWriteStartChanges(os, bparams,
|
||||||
runparams, basefont,
|
runparams, basefont,
|
||||||
running_font, true,
|
running_font, true,
|
||||||
cprotect);
|
cprotect);
|
||||||
column += count;
|
column += count2;
|
||||||
// if any font properties were closed, update the running_font,
|
// Update the running_font, making sure, however,
|
||||||
// making sure, however, to leave the language as it was
|
// to leave the language as it was.
|
||||||
if (count > 0) {
|
// FIXME: probably a better way to keep track of the old
|
||||||
// FIXME: probably a better way to keep track of the old
|
// language, than copying the entire font?
|
||||||
// language, than copying the entire font?
|
Font const copy_font(running_font);
|
||||||
Font const copy_font(running_font);
|
basefont = owner_->getLayoutFont(bparams, outerfont);
|
||||||
basefont = owner_->getLayoutFont(bparams, outerfont);
|
running_font = basefont;
|
||||||
running_font = basefont;
|
if (!closeLanguage)
|
||||||
if (!closeLanguage)
|
running_font.setLanguage(copy_font.language());
|
||||||
running_font.setLanguage(copy_font.language());
|
// For these, we use switches, so they should be taken as
|
||||||
// For these, we use switches, so no need to close
|
// base inside the inset.
|
||||||
basefont.fontInfo().setSize(copy_font.fontInfo().size());
|
basefont.fontInfo().setSize(copy_font.fontInfo().size());
|
||||||
basefont.fontInfo().setFamily(copy_font.fontInfo().family());
|
basefont.fontInfo().setFamily(copy_font.fontInfo().family());
|
||||||
basefont.fontInfo().setSeries(copy_font.fontInfo().series());
|
basefont.fontInfo().setSeries(copy_font.fontInfo().series());
|
||||||
if (closeLanguage)
|
if (count2 == 0 && (lang_closed || lang_switched_at_inset))
|
||||||
runparams.local_font = &basefont;
|
// All fonts closed
|
||||||
}
|
open_font = false;
|
||||||
|
if (closeLanguage)
|
||||||
|
runparams.local_font = &basefont;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t const previous_row_count = os.texrow().rows();
|
size_t const previous_row_count = os.texrow().rows();
|
||||||
|
Loading…
Reference in New Issue
Block a user