[LyX/master] Strip polyglossia options from pdf string

Juergen Spitzmueller spitz at lyx.org
Sun Apr 5 13:03:29 UTC 2020


commit f9999039ac7278a719513fdd15c34f12846a1189
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sun Apr 5 15:23:22 2020 +0200

    Strip polyglossia options from pdf string
    
    Fixes #11813
---
 src/Buffer.cpp       |    2 ++
 src/Font.cpp         |    7 ++++++-
 src/OutputParams.cpp |    2 +-
 src/OutputParams.h   |    4 ++++
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ec11ac2..4be7e21 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -1858,6 +1858,7 @@ Buffer::ExportStatus Buffer::writeLaTeXSource(otexstream & os,
 	// This is only set once per document (in master)
 	if (!runparams.is_child) {
 		runparams.use_polyglossia = features.usePolyglossia();
+		runparams.use_hyperref = features.isRequired("hyperref");
 		runparams.use_CJK = features.mustProvide("CJK");
 	}
 	LYXERR(Debug::LATEX, "  Buffer validation done.");
@@ -4108,6 +4109,7 @@ unique_ptr<TexRow> Buffer::getSourceCode(odocstream & os, string const & format,
 			LaTeXFeatures features(*this, params(), runparams);
 			validate(features);
 			runparams.use_polyglossia = features.usePolyglossia();
+			runparams.use_hyperref = features.isRequired("hyperref");
 			// latex or literate
 			otexstream ots(os);
 			// output above
diff --git a/src/Font.cpp b/src/Font.cpp
index a6580fd..c344ac9 100644
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -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();
diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp
index d26955e..d10de5e 100644
--- a/src/OutputParams.cpp
+++ b/src/OutputParams.cpp
@@ -22,7 +22,7 @@ OutputParams::OutputParams(Encoding const * enc)
 	: flavor(LATEX), math_flavor(NotApplicable), nice(false), is_child(false),
 	  moving_arg(false), intitle(false), inbranch(false), inulemcmd(0),
 	  local_font(0),master_language(0), encoding(enc), free_spacing(false),
-	  use_babel(false), use_polyglossia(false), use_CJK(false),
+	  use_babel(false), use_polyglossia(false), use_hyperref(false), use_CJK(false),
 	  use_indices(false), use_japanese(false), linelen(0), depth(0),
 	  exportdata(new ExportData), postpone_fragile_stuff(false), inDisplayMath(false),
 	  wasDisplayMath(false), inComment(false), openbtUnit(false), only_childbibs(false),
diff --git a/src/OutputParams.h b/src/OutputParams.h
index 5503d8b..5aa6080 100644
--- a/src/OutputParams.h
+++ b/src/OutputParams.h
@@ -177,6 +177,10 @@ public:
 	*/
 	bool use_polyglossia;
 
+	/** Do we use hyperref?
+	*/
+	bool use_hyperref;
+
 	/// Do we use the CJK package?
 	bool use_CJK;
 


More information about the lyx-cvs mailing list