#include "Encoding.h"
#include "Language.h"
#include "LaTeXFeatures.h"
-#include "Lexer.h"
#include "LyXRC.h"
#include "output_latex.h"
#include "OutputParams.h"
#include "support/convert.h"
#include "support/debug.h"
#include "support/gettext.h"
+#include "support/Lexer.h"
#include "support/lstrings.h"
#include <cstring>
/// Updates font settings according to request
void Font::update(Font const & newfont,
- Language const * document_language,
+ Language const * default_lang,
bool toggleall)
{
bits_.update(newfont.fontInfo(), toggleall);
if (newfont.language() == language() && toggleall)
- if (language() == document_language)
+ if (language() == default_lang)
setLanguage(default_language);
else
- setLanguage(document_language);
+ setLanguage(default_lang);
else if (newfont.language() == reset_language)
- setLanguage(document_language);
+ setLanguage(default_lang);
else if (newfont.language() != ignore_language)
setLanguage(newfont.language());
}
OutputParams const & runparams,
Font const & base,
Font const & prev,
- bool const & non_inherit_inset,
- bool const & needs_cprotection) const
+ bool non_inherit_inset,
+ bool needs_cprotection) const
{
int count = 0;
os << "\\textLR{";
count += 8;
// currently the remaining RTL languages are arabic_arabtex and hebrew
- } else if (isRightToLeft() != prev.isRightToLeft()) {
+ } else if (isRightToLeft() != prev.isRightToLeft() && !runparams.isFullUnicode()) {
if (needs_cprotection) {
os << "\\cprotect";
count += 9;
p.reduce(prev.bits_);
if (f.size() != INHERIT_SIZE) {
- os << '{';
- ++count;
- os << '\\'
- << LaTeXSizeSwitchNames[f.size()] << termcmd;
- count += strlen(LaTeXSizeSwitchNames[f.size()]) + 1;
+ if (!runparams.find_effective()) {
+ os << '{';
+ ++count;
+ os << '\\'
+ << LaTeXSizeSwitchNames[f.size()] << termcmd;
+ count += strlen(LaTeXSizeSwitchNames[f.size()]) + 1;
+ }
+ else {
+ os << '\\'
+ << LaTeXSizeSwitchNames[f.size()] << '{';
+ count += strlen(LaTeXSizeSwitchNames[f.size()]) + 2;
+ }
}
if (f.family() != INHERIT_FAMILY) {
if (non_inherit_inset) {
os << '}';
++count;
} else if (f.color() != Color_none) {
- if (needs_cprotection) {
- os << "\\cprotect";
- count += 9;
- }
os << "\\textcolor{"
<< from_ascii(lcolor.getLaTeXName(f.color()))
<< "}{";
// the numbers are written Left-to-Right. ArabTeX package
// and bidi (polyglossia with XeTeX) reorder the number automatically
// but the packages used for Hebrew and Farsi (Arabi) do not.
- if (!runparams.useBidiPackage()
+ if (!bparams.useBidiPackage(runparams)
&& !runparams.pass_thru
&& bits_.number() == FONT_ON
&& prev.fontInfo().number() != FONT_ON
|| language()->lang() == "arabic_arabi")) {
if (runparams.use_polyglossia) {
// LuaTeX/luabidi
- os << "\\LR{";
- count += 5;
- } else {
+ // \LR needs extra grouping
+ // (possibly a LuaTeX bug)
+ os << "{\\LR{";
+ count += 6;
+ } else if (!runparams.isFullUnicode()) {
+ // not needed with babel/lua|xetex
os << "{\\beginL ";
count += 9;
}
if (runparams.inulemcmd) {
// needed with nested uwave in xout
// see https://tex.stackexchange.com/a/263042
- os << "\\ULdepth=1000pt";
- count += 15;
+ os << "\\ULdepth=\\maxdimen";
+ count += 18;
}
if (needs_cprotection) {
os << "\\cprotect";
Font const & base,
Font const & next,
bool & needPar,
- bool const & closeLanguage) const
+ bool closeLanguage) const
{
int count = 0;
// the numbers are written Left-to-Right. ArabTeX package
// and bidi (polyglossia with XeTeX) reorder the number automatically
// but the packages used for Hebrew and Farsi (Arabi) do not.
- if (!runparams.useBidiPackage()
+ if (!bparams.useBidiPackage(runparams)
&& !runparams.pass_thru
&& bits_.number() == FONT_ON
&& next.fontInfo().number() != FONT_ON
|| language()->lang() == "arabic_arabi")) {
if (runparams.use_polyglossia) {
// LuaTeX/luabidi
- os << "}";
- count += 1;
- } else {
+ // luabidi's \LR needs extra grouping
+ // (possibly a LuaTeX bug)
+ os << "}}";
+ count += 2;
+ } else if (!runparams.isFullUnicode()) {
+ // not needed with babel/lua|xetex
os << "\\endL}";
count += 6;
}
bool const using_begin_end =
runparams.use_polyglossia ||
!lyxrc.language_command_end.empty();
- if (using_begin_end)
+ if (using_begin_end && !languageStackEmpty())
popLanguageName();
}
if (token == "family") {
int const next = lex.getInteger();
+ if (next == -1)
+ return false;
bits_.setFamily(FontFamily(next));
} else if (token == "series") {
int const next = lex.getInteger();
+ if (next == -1)
+ return false;
bits_.setSeries(FontSeries(next));
} else if (token == "shape") {
int const next = lex.getInteger();
+ if (next == -1)
+ return false;
bits_.setShape(FontShape(next));
} else if (token == "size") {
int const next = lex.getInteger();
+ if (next == -1)
+ return false;
bits_.setSize(FontSize(next));
// FIXME: shall style be handled there? Probably not.
} else if (token == "emph" || token == "underbar"
|| token == "nospellcheck") {
int const next = lex.getInteger();
+ if (next == -1)
+ return false;
FontState const misc = FontState(next);
if (token == "emph")
} else if (token == "color") {
int const next = lex.getInteger();
+ if (next == -1)
+ return false;
bits_.setColor(ColorCode(next));
/**
Language const * doc_language = bparams.language;
if (bits_.noun() == FONT_ON) {
- LYXERR(Debug::LATEX, "font.noun: " << bits_.noun());
+ LYXERR(Debug::OUTFILE, "font.noun: " << bits_.noun());
features.require("noun");
- LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText()));
+ LYXERR(Debug::OUTFILE, "Noun enabled. Font: " << to_utf8(stateText()));
}
if (bits_.underbar() == FONT_ON) {
- LYXERR(Debug::LATEX, "font.underline: " << bits_.underbar());
+ LYXERR(Debug::OUTFILE, "font.underline: " << bits_.underbar());
features.require("ulem");
- LYXERR(Debug::LATEX, "Underline enabled. Font: " << to_utf8(stateText()));
+ LYXERR(Debug::OUTFILE, "Underline enabled. Font: " << to_utf8(stateText()));
}
if (bits_.strikeout() == FONT_ON) {
- LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout());
+ LYXERR(Debug::OUTFILE, "font.strikeout: " << bits_.strikeout());
features.require("ulem");
- LYXERR(Debug::LATEX, "Strike out enabled. Font: " << to_utf8(stateText()));
+ LYXERR(Debug::OUTFILE, "Strike out enabled. Font: " << to_utf8(stateText()));
}
if (bits_.xout() == FONT_ON) {
- LYXERR(Debug::LATEX, "font.xout: " << bits_.xout());
+ LYXERR(Debug::OUTFILE, "font.xout: " << bits_.xout());
features.require("ulem");
- LYXERR(Debug::LATEX, "Cross out enabled. Font: " << to_utf8(stateText()));
+ LYXERR(Debug::OUTFILE, "Cross out enabled. Font: " << to_utf8(stateText()));
}
if (bits_.uuline() == FONT_ON) {
- LYXERR(Debug::LATEX, "font.uuline: " << bits_.uuline());
+ LYXERR(Debug::OUTFILE, "font.uuline: " << bits_.uuline());
features.require("ulem");
- LYXERR(Debug::LATEX, "Double underline enabled. Font: " << to_utf8(stateText()));
+ LYXERR(Debug::OUTFILE, "Double underline enabled. Font: " << to_utf8(stateText()));
}
if (bits_.uwave() == FONT_ON) {
- LYXERR(Debug::LATEX, "font.uwave: " << bits_.uwave());
+ LYXERR(Debug::OUTFILE, "font.uwave: " << bits_.uwave());
features.require("ulem");
- LYXERR(Debug::LATEX, "Wavy underline enabled. Font: " << to_utf8(stateText()));
+ LYXERR(Debug::OUTFILE, "Wavy underline enabled. Font: " << to_utf8(stateText()));
}
switch (bits_.color()) {
case Color_none:
break;
default:
features.require("color");
- LYXERR(Debug::LATEX, "Color enabled. Font: " << to_utf8(stateText()));
+ LYXERR(Debug::OUTFILE, "Color enabled. Font: " << to_utf8(stateText()));
}
// FIXME: Do something for background and soul package?
&& lang_ != latex_language)
{
features.useLanguage(lang_);
- LYXERR(Debug::LATEX, "Found language " << lang_->lang());
+ LYXERR(Debug::OUTFILE, "Found language " << lang_->lang());
}
}