]> git.lyx.org Git - lyx.git/blobdiff - src/Font.cpp
Amend 207eaeee9071cb
[lyx.git] / src / Font.cpp
index cd741d1239df86ba143c092427021f44be54e61b..a4ae35727f344321e2d0bd4636f12c91c7503059 100644 (file)
@@ -21,7 +21,6 @@
 #include "Encoding.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "Lexer.h"
 #include "LyXRC.h"
 #include "output_latex.h"
 #include "OutputParams.h"
@@ -31,6 +30,7 @@
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/gettext.h"
+#include "support/Lexer.h"
 #include "support/lstrings.h"
 
 #include <cstring>
@@ -294,7 +294,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
                        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;
@@ -426,7 +426,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
        // 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
@@ -435,9 +435,12 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
                || 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;
                }
@@ -502,8 +505,8 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
                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";
@@ -601,7 +604,7 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
        // 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
@@ -610,9 +613,12 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
                || 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;
                }