odocstream::pos_type const len = os.os().tellp();
if (inset->forceLTR(runparams)
+ // babel with Xe/LuaTeX does not need a switch
+ // and \L is not defined there.
+ && (!runparams.isFullUnicode() || !runparams.use_babel)
&& running_font.isRightToLeft()
// ERT is an exception, it should be output with no
// decorations at all
&& inset->lyxCode() != ERT_CODE) {
- if (runparams.use_polyglossia) {
+ if (runparams.use_polyglossia)
+ // (lua)bidi
os << "\\LRE{";
- } else if (running_font.language()->lang() == "farsi"
- || running_font.language()->lang() == "arabic_arabi")
+ else if (running_font.language()->lang() == "farsi"
+ || running_font.language()->lang() == "arabic_arabi")
os << "\\textLR{" << termcmd;
else
+ // babel classic
os << "\\L{";
close = true;
}
char_type c = d->text_[pos];
// Return unchanged character in LTR languages
- // or if we use poylglossia/bidi (XeTeX).
- if (rp.useBidiPackage()
- || !getFontSettings(bparams, pos).isRightToLeft())
+ // or if we use poylglossia/bidi (XeTeX)
+ // or with babel and Xe/LuaTeX.
+ if (!getFontSettings(bparams, pos).isRightToLeft()
+ || rp.useBidiPackage()
+ || (rp.use_babel && rp.isFullUnicode()))
return c;
// Without polyglossia/bidi, we need to account for some special cases.
bool is_last_par,
bool ignore_fonts) const
{
- std::vector<docstring> prependedParagraphs;
- std::vector<docstring> generatedParagraphs;
- std::vector<docstring> appendedParagraphs;
+ // Return values: segregation of the content of this paragraph.
+ std::vector<docstring> prependedParagraphs; // Anything that must be output before the main tag of this paragraph.
+ std::vector<docstring> generatedParagraphs; // The main content of the paragraph.
+ std::vector<docstring> appendedParagraphs; // Anything that must be output after the main tag of this paragraph.
+
+ // Internal string stream to store the output before being added to one of the previous lists.
odocstringstream os;
// If there is an argument that must be output before the main tag, do it before handling the rest of the paragraph.
std::vector<docstring> delayedChars; // When a font tag ends with a space, output it after the closing font tag.
// This requires to store delayed characters at some point.
- DocBookFontState fs; // Track whether we have opened font tags
+ // Track whether we have opened font tags
+ DocBookFontState fs;
DocBookFontState old_fs = fs;
Layout const & style = *d->layout_;
- FontInfo font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
- string const default_family = buf.masterBuffer()->params().fonts_default_family;
+ // Conversion of the font opening/closing into DocBook tags.
vector<xml::FontTag> tagsToOpen;
vector<xml::EndFontTag> tagsToClose;
// Output one paragraph (i.e. one string entry in generatedParagraphs).
generatedParagraphs.push_back(os.str());
- // Create a new XMLStream for the new paragraph, completely independent from the previous one. This implies
+ // Create a new XMLStream for the new paragraph, completely independent of the previous one. This implies
// that the string stream must be reset.
os.str(from_ascii(""));
delete xs;
// Restore the fonts for the new paragraph, so that the right tags are opened for the new entry.
if (!ignore_fonts_i) {
- font_old = outerfont.fontInfo();
fs = old_fs;
}
}
// Determine which tags should be opened or closed regarding fonts.
+ FontInfo const font_old = (i == 0 ?
+ (style.labeltype == LABEL_MANUAL ? style.labelfont : style.font) :
+ getFont(buf.masterBuffer()->params(), i - 1, outerfont).fontInfo());
Font const font = getFont(buf.masterBuffer()->params(), i, outerfont);
- tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, font, default_family, fs);
+ tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(
+ font_old, font, buf.masterBuffer()->params().fonts_default_family, fs);
if (!ignore_fonts_i) {
vector<xml::EndFontTag>::const_iterator cit = tagsToClose.begin();
delayedChars.emplace_back(1, c);
}
} else { // No need to delay the character.
- if (c == '\'')
+ if (c == '\'' && !ignore_fonts)
*xs << XMLStream::ESCAPE_NONE << "’";
else
*xs << c;
}
}
- font_old = font.fontInfo();
}
// FIXME, this code is just imported from XHTML
char_type c = getUChar(buf.masterBuffer()->params(),
runparams, i);
if (c == ' ' && (style.free_spacing || runparams.free_spacing))
- xs << XMLStream::ESCAPE_NONE << " ";
+ xs << XMLStream::ESCAPE_NONE << " ";
else if (c == '\'')
xs << XMLStream::ESCAPE_NONE << "’";
else