Revert "Correctly set font decorations for multipar insets"

This reverts commit 5791b8bff8.
This commit is contained in:
Enrico Forestieri 2020-08-14 18:01:26 +02:00
parent 9b7db11901
commit 836300cd33
3 changed files with 42 additions and 63 deletions

View File

@ -112,15 +112,6 @@ void Font::setLanguage(Language const * l)
} }
void Font::setProperties(FontInfo const & f)
{
bits_.setFamily(f.family());
bits_.setSeries(f.series());
bits_.setShape(f.shape());
bits_.setSize(f.size());
}
/// Updates font settings according to request /// Updates font settings according to request
void Font::update(Font const & newfont, void Font::update(Font const & newfont,
Language const * document_language, Language const * document_language,
@ -237,7 +228,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
OutputParams const & runparams, OutputParams const & runparams,
Font const & base, Font const & base,
Font const & prev, Font const & prev,
bool const & multipar_inset, bool const & non_inherit_inset,
bool const & needs_cprotection) const bool const & needs_cprotection) const
{ {
int count = 0; int count = 0;
@ -352,7 +343,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
count += strlen(LaTeXSizeSwitchNames[f.size()]) + 1; count += strlen(LaTeXSizeSwitchNames[f.size()]) + 1;
} }
if (f.family() != INHERIT_FAMILY) { if (f.family() != INHERIT_FAMILY) {
if (multipar_inset) { if (non_inherit_inset) {
os << '{'; os << '{';
++count; ++count;
os << '\\' << LaTeXFamilySwitchNames[f.family()] << termcmd; os << '\\' << LaTeXFamilySwitchNames[f.family()] << termcmd;
@ -369,7 +360,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
} }
} }
if (f.series() != INHERIT_SERIES) { if (f.series() != INHERIT_SERIES) {
if (multipar_inset) { if (non_inherit_inset) {
os << '{'; os << '{';
++count; ++count;
os << '\\' << LaTeXSeriesSwitchNames[f.series()] << termcmd; os << '\\' << LaTeXSeriesSwitchNames[f.series()] << termcmd;
@ -386,7 +377,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
} }
} }
if (f.shape() != INHERIT_SHAPE) { if (f.shape() != INHERIT_SHAPE) {
if (multipar_inset) { if (non_inherit_inset) {
os << '{'; os << '{';
++count; ++count;
os << '\\' << LaTeXShapeSwitchNames[f.shape()] << termcmd; os << '\\' << LaTeXShapeSwitchNames[f.shape()] << termcmd;
@ -402,7 +393,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
count += strlen(LaTeXShapeCommandNames[f.shape()]) + 2; count += strlen(LaTeXShapeCommandNames[f.shape()]) + 2;
} }
} }
if (f.color() != Color_inherit && f.color() != Color_ignore && !multipar_inset) { if (f.color() != Color_inherit && f.color() != Color_ignore) {
if (f.color() == Color_none && p.color() != Color_none) { if (f.color() == Color_none && p.color() != Color_none) {
// Color none: Close previous color, if any // Color none: Close previous color, if any
os << '}'; os << '}';
@ -448,7 +439,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
count += 9; count += 9;
} }
} }
if (f.emph() == FONT_ON && !multipar_inset) { if (f.emph() == FONT_ON) {
if (needs_cprotection) { if (needs_cprotection) {
os << "\\cprotect"; os << "\\cprotect";
count += 9; count += 9;
@ -457,7 +448,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
count += 6; count += 6;
} }
// \noun{} is a LyX special macro // \noun{} is a LyX special macro
if (f.noun() == FONT_ON && !multipar_inset) { if (f.noun() == FONT_ON) {
if (needs_cprotection) { if (needs_cprotection) {
os << "\\cprotect"; os << "\\cprotect";
count += 9; count += 9;
@ -468,7 +459,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
// The ulem commands need to be on the deepest nesting level // The ulem commands need to be on the deepest nesting level
// because ulem puts every nested group or macro in a box, // because ulem puts every nested group or macro in a box,
// which prevents linebreaks (#8424, #8733) // which prevents linebreaks (#8424, #8733)
if (f.underbar() == FONT_ON && !multipar_inset) { if (f.underbar() == FONT_ON) {
if (needs_cprotection) { if (needs_cprotection) {
os << "\\cprotect"; os << "\\cprotect";
count += 9; count += 9;
@ -477,7 +468,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
count += 7; count += 7;
++runparams.inulemcmd; ++runparams.inulemcmd;
} }
if (f.uuline() == FONT_ON && !multipar_inset) { if (f.uuline() == FONT_ON) {
if (needs_cprotection) { if (needs_cprotection) {
os << "\\cprotect"; os << "\\cprotect";
count += 9; count += 9;
@ -486,7 +477,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
count += 8; count += 8;
++runparams.inulemcmd; ++runparams.inulemcmd;
} }
if (f.strikeout() == FONT_ON && !multipar_inset) { if (f.strikeout() == FONT_ON) {
if (needs_cprotection) { if (needs_cprotection) {
os << "\\cprotect"; os << "\\cprotect";
count += 9; count += 9;
@ -495,7 +486,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
count += 6; count += 6;
++runparams.inulemcmd; ++runparams.inulemcmd;
} }
if (f.xout() == FONT_ON && !multipar_inset) { if (f.xout() == FONT_ON) {
if (needs_cprotection) { if (needs_cprotection) {
os << "\\cprotect"; os << "\\cprotect";
count += 9; count += 9;
@ -504,7 +495,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
count += 6; count += 6;
++runparams.inulemcmd; ++runparams.inulemcmd;
} }
if (f.uwave() == FONT_ON && !multipar_inset) { if (f.uwave() == FONT_ON) {
if (runparams.inulemcmd) { if (runparams.inulemcmd) {
// needed with nested uwave in xout // needed with nested uwave in xout
// see https://tex.stackexchange.com/a/263042 // see https://tex.stackexchange.com/a/263042
@ -531,8 +522,7 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
Font const & base, Font const & base,
Font const & next, Font const & next,
bool & needPar, bool & needPar,
bool const & closeLanguage, bool const & closeLanguage) const
bool const & multipar_inset) const
{ {
int count = 0; int count = 0;
@ -542,15 +532,15 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
FontInfo f = bits_; FontInfo f = bits_;
f.reduce(base.bits_); f.reduce(base.bits_);
if (f.family() != INHERIT_FAMILY && !multipar_inset) { if (f.family() != INHERIT_FAMILY) {
os << '}'; os << '}';
++count; ++count;
} }
if (f.series() != INHERIT_SERIES && !multipar_inset) { if (f.series() != INHERIT_SERIES) {
os << '}'; os << '}';
++count; ++count;
} }
if (f.shape() != INHERIT_SHAPE && !multipar_inset) { if (f.shape() != INHERIT_SHAPE) {
os << '}'; os << '}';
++count; ++count;
} }
@ -568,17 +558,15 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
} }
if (f.size() != INHERIT_SIZE) { if (f.size() != INHERIT_SIZE) {
// We do not close size group in front of // We do not close size group in front of
// insets with allowMultiPar() true (as opposed // insets with InheritFont() false (as opposed
// to all other font properties) (#8384) // to all other font properties) (#8384)
if (!multipar_inset) { if (needPar && !closeLanguage) {
if (needPar && !closeLanguage) { os << "\\par";
os << "\\par"; count += 4;
count += 4; needPar = false;
needPar = false;
}
os << '}';
++count;
} }
os << '}';
++count;
} }
if (f.underbar() == FONT_ON) { if (f.underbar() == FONT_ON) {
os << '}'; os << '}';

View File

@ -47,8 +47,6 @@ public:
bool isVisibleRightToLeft() const; bool isVisibleRightToLeft() const;
/// ///
void setLanguage(Language const * l); void setLanguage(Language const * l);
///
void setProperties(FontInfo const & f);
/// Returns size of font in LaTeX text notation /// Returns size of font in LaTeX text notation
std::string const latexSize() const; std::string const latexSize() const;
@ -90,8 +88,7 @@ public:
Font const & base, Font const & base,
Font const & next, Font const & next,
bool & needPar, bool & needPar,
bool const & closeLanguage = true, bool const & closeLanguage = true) const;
bool const & multipar_inset = false) const;
/// Build GUI description of font state /// Build GUI description of font state

View File

@ -1067,10 +1067,9 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
? textinset->hasCProtectContent(runparams.moving_arg) ? textinset->hasCProtectContent(runparams.moving_arg)
&& !textinset->text().isMainText() && !textinset->text().isMainText()
: false; : false;
bool const multipar_inset = inset->allowMultiPar();
unsigned int count2 = running_font.latexWriteStartChanges(os, bparams, unsigned int count2 = running_font.latexWriteStartChanges(os, bparams,
runparams, basefont, runparams, basefont,
running_font, multipar_inset, running_font, true,
cprotect); cprotect);
column += count2; column += count2;
// Update the running_font, making sure, however, // Update the running_font, making sure, however,
@ -2414,11 +2413,10 @@ void Paragraph::latex(BufferParams const & bparams,
pos_type body_pos = beginOfBody(); pos_type body_pos = beginOfBody();
unsigned int column = 0; unsigned int column = 0;
Font real_outerfont = outerfont; // If we are inside an non inheritFont() inset, the real outerfont is local_font
// If we are inside an non inheritFont() inset, the real main Font const real_outerfont = (!inInset().inheritFont()
// properties of the outerfont are those of the local_font && runparams.local_font != nullptr)
if (!inInset().inheritFont() && runparams.local_font != nullptr) ? Font(runparams.local_font->fontInfo()) : outerfont;
real_outerfont.setProperties(runparams.local_font->fontInfo());
if (body_pos > 0) { if (body_pos > 0) {
// the optional argument is kept in curly brackets in // the optional argument is kept in curly brackets in
@ -2465,8 +2463,6 @@ void Paragraph::latex(BufferParams const & bparams,
// Yes if greater than 0. This has to be static. // Yes if greater than 0. This has to be static.
THREAD_LOCAL_STATIC int parInline = 0; THREAD_LOCAL_STATIC int parInline = 0;
bool multipar_inset = false;
for (pos_type i = 0; i < size(); ++i) { for (pos_type i = 0; i < size(); ++i) {
// First char in paragraph or after label? // First char in paragraph or after label?
if (i == body_pos) { if (i == body_pos) {
@ -2475,8 +2471,7 @@ void Paragraph::latex(BufferParams const & bparams,
bool needPar = false; bool needPar = false;
column += running_font.latexWriteEndChanges( column += running_font.latexWriteEndChanges(
os, bparams, runparams, os, bparams, runparams,
basefont, basefont, needPar, basefont, basefont, needPar);
multipar_inset);
open_font = false; open_font = false;
} }
basefont = getLayoutFont(bparams, real_outerfont); basefont = getLayoutFont(bparams, real_outerfont);
@ -2543,7 +2538,7 @@ void Paragraph::latex(BufferParams const & bparams,
bool needPar = false; bool needPar = false;
column += running_font.latexWriteEndChanges( column += running_font.latexWriteEndChanges(
os, bparams, rp, basefont, os, bparams, rp, basefont,
basefont, needPar, multipar_inset); basefont, needPar);
open_font = false; open_font = false;
} }
basefont = (body_pos > i) ? getLabelFont(bparams, real_outerfont) basefont = (body_pos > i) ? getLabelFont(bparams, real_outerfont)
@ -2564,8 +2559,7 @@ void Paragraph::latex(BufferParams const & bparams,
bool needPar = false; bool needPar = false;
column += running_font.latexWriteEndChanges( column += running_font.latexWriteEndChanges(
os, bparams, runparams, os, bparams, runparams,
basefont, basefont, needPar, basefont, basefont, needPar);
multipar_inset);
open_font = false; open_font = false;
} }
basefont = (body_pos > i) ? getLabelFont(bparams, real_outerfont) basefont = (body_pos > i) ? getLabelFont(bparams, real_outerfont)
@ -2596,7 +2590,7 @@ void Paragraph::latex(BufferParams const & bparams,
&& runningChange == change && runningChange == change
&& change.type == Change::DELETED && change.type == Change::DELETED
&& !os.afterParbreak()); && !os.afterParbreak());
multipar_inset = bool const multipar_inset =
(c == META_INSET && getInset(i) && getInset(i)->allowMultiPar()); (c == META_INSET && getInset(i) && getInset(i)->allowMultiPar());
// Do we need to close the previous font? // Do we need to close the previous font?
@ -2623,7 +2617,7 @@ void Paragraph::latex(BufferParams const & bparams,
column += running_font.latexWriteEndChanges( column += running_font.latexWriteEndChanges(
os, bparams, runparams, basefont, os, bparams, runparams, basefont,
(i == body_pos-1) ? basefont : current_font, (i == body_pos-1) ? basefont : current_font,
needPar, multipar_inset); needPar);
if (in_ct_deletion) { if (in_ct_deletion) {
// We have to close and then reopen \lyxdeleted, // We have to close and then reopen \lyxdeleted,
// as strikeout needs to be on lowest level. // as strikeout needs to be on lowest level.
@ -2686,7 +2680,7 @@ void Paragraph::latex(BufferParams const & bparams,
OutputParams rp = runparams; OutputParams rp = runparams;
column += running_font.latexWriteEndChanges( column += running_font.latexWriteEndChanges(
os, bparams, rp, basefont, os, bparams, rp, basefont,
basefont, needPar, multipar_inset); basefont, needPar);
os << '}'; os << '}';
column += 1; column += 1;
} }
@ -2791,16 +2785,16 @@ void Paragraph::latex(BufferParams const & bparams,
incremented = true; incremented = true;
} }
} }
// We need to restore the main properties of // We need to restore these after insets with
// these fonts after allowMultiPar() insets // allowMultiPar() true
FontInfo const running_font_info = running_font.fontInfo(); Font const save_running_font = running_font;
FontInfo const basefont_info = basefont.fontInfo(); Font const save_basefont = basefont;
d->latexInset(bparams, os, rp, running_font, d->latexInset(bparams, os, rp, running_font,
basefont, real_outerfont, open_font, basefont, real_outerfont, open_font,
runningChange, style, i, column); runningChange, style, i, column);
if (multipar_inset) { if (multipar_inset) {
running_font.setProperties(running_font_info); running_font = save_running_font;
basefont.setProperties(basefont_info); basefont = save_basefont;
} }
if (incremented) if (incremented)
--parInline; --parInline;
@ -2923,7 +2917,7 @@ void Paragraph::latex(BufferParams const & bparams,
//FIXME: there as we start another \selectlanguage with the next paragraph if //FIXME: there as we start another \selectlanguage with the next paragraph if
//FIXME: we are in need of this. This should be fixed sometime (Jug) //FIXME: we are in need of this. This should be fixed sometime (Jug)
running_font.latexWriteEndChanges(os, bparams, runparams, running_font.latexWriteEndChanges(os, bparams, runparams,
basefont, basefont, needPar, multipar_inset); basefont, basefont, needPar);
#endif #endif
if (needPar) { if (needPar) {
// The \par could not be inserted at the same nesting // The \par could not be inserted at the same nesting