]> git.lyx.org Git - lyx.git/blobdiff - src/Font.cpp
Run codespell on src/frontends
[lyx.git] / src / Font.cpp
index a6e6c9190f364f5ec8811ec6bc178ed169274b1d..695fb893f9d28f031d393b9b99886b9fa2712a00 100644 (file)
@@ -59,7 +59,7 @@ namespace {
 char const * LaTeXFamilyNames[NUM_FAMILIES + 2] =
 { "textrm", "textsf", "texttt", "error1", "error2", "error3", "error4",
   "error5", "error6", "error7", "error8", "error9", "error10", "error11",
-  "error12", "error13" };
+  "error12", "error13", "error14" };
 
 char const * LaTeXSeriesNames[NUM_SERIES + 2] =
 { "textmd", "textbf", "error4", "error5" };
@@ -228,8 +228,13 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
            && language() != prev.language()) {
                if (!language()->polyglossia().empty()) {
                        string tmp = "\\text" + language()->polyglossia();
-                       if (!language()->polyglossiaOpts().empty())
+                       if (!language()->polyglossiaOpts().empty()) {
                                tmp += "[" + language()->polyglossiaOpts() + "]";
+                               if (runparams.use_hyperref && runparams.moving_arg)
+                                       // We need to strip the command for
+                                       // the pdf string, see #11813
+                                       tmp = "\\texorpdfstring{" + tmp + "}{}";
+                       }
                        tmp += "{";
                        os << from_ascii(tmp);
                        count += tmp.length();
@@ -338,17 +343,23 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
        */
        // If the current language is Hebrew, Arabic, or Farsi
        // the numbers are written Left-to-Right. ArabTeX package
-       // and bidi (polyglossia) reorder the number automatically
+       // and bidi (polyglossia with XeTeX) reorder the number automatically
        // but the packages used for Hebrew and Farsi (Arabi) do not.
-       if (!runparams.use_polyglossia
+       if (!runparams.useBidiPackage()
            && !runparams.pass_thru
            && bits_.number() == FONT_ON
            && prev.fontInfo().number() != FONT_ON
            && (language()->lang() == "hebrew"
                || language()->lang() == "farsi"
                || language()->lang() == "arabic_arabi")) {
-               os << "{\\beginL ";
-               count += 9;
+               if (runparams.use_polyglossia) {
+                       // LuaTeX/luabidi
+                       os << "\\LR{";
+                       count += 5;
+               } else {
+                       os << "{\\beginL ";
+                       count += 9;
+               }
        }
        if (f.emph() == FONT_ON) {
                os << "\\emph{";
@@ -499,17 +510,23 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
 
        // If the current language is Hebrew, Arabic, or Farsi
        // the numbers are written Left-to-Right. ArabTeX package
-       // and bidi (polyglossia) reorder the number automatically
+       // and bidi (polyglossia with XeTeX) reorder the number automatically
        // but the packages used for Hebrew and Farsi (Arabi) do not.
-       if (!runparams.use_polyglossia
+       if (!runparams.useBidiPackage()
            && !runparams.pass_thru
            && bits_.number() == FONT_ON
            && next.fontInfo().number() != FONT_ON
            && (language()->lang() == "hebrew"
                || language()->lang() == "farsi"
                || language()->lang() == "arabic_arabi")) {
-               os << "\\endL}";
-               count += 6;
+               if (runparams.use_polyglossia) {
+                       // LuaTeX/luabidi
+                       os << "}";
+                       count += 1;
+               } else {
+                       os << "\\endL}";
+                       count += 6;
+               }
        }
 
        if (open_encoding_) {
@@ -526,8 +543,7 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
 
        if (closeLanguage
            && language() != base.language() && language() != next.language()
-           && (language()->encoding()->package() != Encoding::CJK
-                       || bparams.useNonTeXFonts)) {
+           && (language()->encoding()->package() != Encoding::CJK)) {
                os << '}';
                ++count;
                bool const using_begin_end =
@@ -762,7 +778,7 @@ ostream & operator<<(ostream & os, FontInfo const & f)
 ostream & operator<<(ostream & os, Font const & font)
 {
        return os << font.bits_
-               << " lang: " << (font.lang_ ? font.lang_->lang() : 0);
+               << " lang: " << (font.lang_ ? font.lang_->lang() : nullptr);
 }