X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FFont.cpp;h=ea1b8c17a37ca14c4ad873c7dfc2ca15f69842ac;hb=38a3692a0fce8b0531cef794a08d179e9e33ac33;hp=4813fa240d9e8444b1c5ed8e9031d86327936ee4;hpb=80b94c6bf50dfb5c96ad1ca6003bac93d844e6ce;p=lyx.git diff --git a/src/Font.cpp b/src/Font.cpp index 4813fa240d..ea1b8c17a3 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -40,6 +40,7 @@ using support::subst; using std::endl; using std::string; using std::ostream; +using std::pair; #ifndef CXX_GLOBAL_CSTD using std::strlen; @@ -510,21 +511,21 @@ docstring const Font::stateText(BufferParams * params) const os << lcolor.getGUIName(color()) << ", "; if (emph() != INHERIT) os << bformat(_("Emphasis %1$s, "), - _(GUIMiscNames[emph()])); + _(GUIMiscNames[emph()])); if (underbar() != INHERIT) os << bformat(_("Underline %1$s, "), - _(GUIMiscNames[underbar()])); + _(GUIMiscNames[underbar()])); if (noun() != INHERIT) os << bformat(_("Noun %1$s, "), - _(GUIMiscNames[noun()])); + _(GUIMiscNames[noun()])); if (bits == inherit) os << _("Default") << ", "; if (!params || (language() != params->language)) os << bformat(_("Language: %1$s, "), - _(language()->display())); + _(language()->display())); if (number() != OFF) os << bformat(_(" Number %1$s"), - _(GUIMiscNames[number()])); + _(GUIMiscNames[number()])); return rtrim(os.str(), ", "); } @@ -674,7 +675,7 @@ Font & Font::lyxRead(Lexer & lex) } else if (ttok == "noun") { setNoun(ON); } else { - lex.printError("Illegal misc type `$$TokenĀ“"); + lex.printError("Illegal misc type `$$Token'"); } } else if (tok == "color") { lex.next(); @@ -740,16 +741,31 @@ void Font::lyxWriteChanges(Font const & orgfont, /// Writes the head of the LaTeX needed to impose this font // Returns number of chars written. int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams, - OutputParams const & runparams, - Font const & base, - Font const & prev) const + OutputParams const & runparams, + Font const & base, + Font const & prev) const { bool env = false; int count = 0; if (language()->babel() != base.language()->babel() && language() != prev.language()) { - if (isRightToLeft() != prev.isRightToLeft()) { + if (language()->lang() == "farsi") { + os << "\\textFR{"; + count += 8; + } else if (!isRightToLeft() && + base.language()->lang() == "farsi") { + os << "\\textLR{"; + count += 8; + } else if (language()->lang() == "arabic_arabi") { + os << "\\textAR{"; + count += 8; + } else if (!isRightToLeft() && + base.language()->lang() == "arabic_arabi") { + os << "\\textLR{"; + count += 8; + // currently the remaining RTL languages are arabic_arabtex and hebrew + } else if (isRightToLeft() != prev.isRightToLeft()) { if (isRightToLeft()) { os << "\\R{"; count += 3; @@ -770,18 +786,23 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams, } if (language()->encoding()->package() == Encoding::CJK) { - int const c = switchEncoding(os, bparams, + pair const c = switchEncoding(os, bparams, runparams.moving_arg, *(runparams.encoding), *(language()->encoding())); - if (c > 0) { + if (c.first) { open_encoding_ = true; - count += c; + count += c.second; runparams.encoding = language()->encoding(); } } - if (number() == ON && prev.number() != ON && - language()->lang() == "hebrew") { + // When the current language is Hebrew, Arabic, or Farsi + // the numbers are written Left-to-Right. ArabTeX package + // reorders the number automatically but the packages used + // for Hebrew and Farsi (Arabi) do not. + if (number() == ON && prev.number() != ON + && (language()->lang() == "hebrew" + || language()->lang() == "farsi")) { os << "{\\beginL "; count += 9; } @@ -852,9 +873,9 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams, // Returns number of chars written // This one corresponds to latexWriteStartChanges(). (Asger) int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams, - OutputParams const & runparams, - Font const & base, - Font const & next) const + OutputParams const & runparams, + Font const & base, + Font const & next) const { int count = 0; bool env = false; @@ -908,8 +929,13 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams, } } - if (number() == ON && next.number() != ON && - language()->lang() == "hebrew") { + // When the current language is Hebrew, Arabic, or Farsi + // the numbers are written Left-to-Right. ArabTeX package + // reorders the number automatically but the packages used + // for Hebrew and Farsi (Arabi) do not. + if (number() == ON && next.number() != ON + && (language()->lang() == "hebrew" + || language()->lang() == "farsi")) { os << "\\endL}"; count += 6; } @@ -918,11 +944,11 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams, // We need to close the encoding even if it does not change // to do correct environment nesting Encoding const * const ascii = encodings.getFromLyXName("ascii"); - int const c = switchEncoding(os, bparams, + pair const c = switchEncoding(os, bparams, runparams.moving_arg, *(runparams.encoding), *ascii); - BOOST_ASSERT(c > 0); - count += c; + BOOST_ASSERT(c.first); + count += c.second; runparams.encoding = ascii; open_encoding_ = false; }