[LyX master] Suppress babel RTL commands when using polyglossia (part of #8251)
The branch, master, has been updated. - Log - commit a1e2e12ba4443c2d67a96fcabbddc9337598f828 Author: Juergen Spitzmueller sp...@lyx.org Date: Mon Jul 23 08:40:37 2012 +0200 Suppress babel RTL commands when using polyglossia (part of #8251) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index d93594a..807abbd 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1076,6 +1076,7 @@ void Paragraph::Private::latexInset(BufferParams const bparams, odocstream::pos_type const len = os.os().tellp(); if (inset-forceLTR() +!runparams.use_polyglossia running_font.isRightToLeft() // ERT is an exception, it should be output with no // decorations at all diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 8e796db..58505cc 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2493,7 +2493,8 @@ void Tabular::TeXRow(otexstream os, row_type row, Paragraph const par = inset-paragraphs().front(); bool rtl = par.isRTL(buffer().params()) !par.empty() -getPWidth(cell).zero(); +getPWidth(cell).zero() +!runparams.use_polyglossia; if (rtl) { string const lang = --- Summary of changes: src/Paragraph.cpp |1 + src/insets/InsetTabular.cpp |3 ++- 2 files changed, 3 insertions(+), 1 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX master] Fixes to the language package call
The branch, master, has been updated. - Log - commit 566a5f2b7513ffbd75cc92f713dc2636f37e Author: Juergen Spitzmueller sp...@lyx.org Date: Mon Jul 23 11:36:55 2012 +0200 Fixes to the language package call * Assure that really no language package is called when none is selected. * Only call global custom package if global is desired. This is a candidate for branch as well. diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 128b9ec..872fd30 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2648,7 +2648,8 @@ string BufferParams::babelCall(string const lang_opts, bool const langoptions) if (lang_package != auto lang_package != babel lang_package != default lang_package != none) return lang_package; - if (lyxrc.language_package_selection == LyXRC::LP_CUSTOM) + if (lang_package == auto +lyxrc.language_package_selection == LyXRC::LP_CUSTOM) return lyxrc.language_custom_package; // suppress the babel call if there is no BabelName defined // for the document language in the lib/languages file and if no diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 6de5db6..489d7a4 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -292,16 +292,14 @@ LaTeXFeatures::LaTeXFeatures(Buffer const b, BufferParams const p, bool LaTeXFeatures::useBabel() const { - if (usePolyglossia()) + if (usePolyglossia() + || bufferParams().lang_package == none + || (bufferParams().lang_package == default +lyxrc.language_package_selection == LyXRC::LP_NONE)) return false; - if (bufferParams().lang_package == default) - return (lyxrc.language_package_selection != LyXRC::LP_NONE) - || (bufferParams().language-lang() != lyxrc.default_language -!bufferParams().language-babel().empty()) - || this-hasLanguages(); - return (bufferParams().lang_package != none) - || (bufferParams().language-lang() != lyxrc.default_language -!bufferParams().language-babel().empty()) + + return (bufferParams().language-lang() != lyxrc.default_language +!bufferParams().language-babel().empty()) || this-hasLanguages(); } --- Summary of changes: src/BufferParams.cpp |3 ++- src/LaTeXFeatures.cpp | 16 +++- 2 files changed, 9 insertions(+), 10 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX master] Fix thinko
The branch, master, has been updated. - Log - commit 508dd27e4488240e0991f36c3b29340101f934af Author: Juergen Spitzmueller sp...@lyx.org Date: Mon Jul 23 11:39:41 2012 +0200 Fix thinko diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 872fd30..6c975d6 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2648,7 +2648,7 @@ string BufferParams::babelCall(string const lang_opts, bool const langoptions) if (lang_package != auto lang_package != babel lang_package != default lang_package != none) return lang_package; - if (lang_package == auto + if (lang_package == default lyxrc.language_package_selection == LyXRC::LP_CUSTOM) return lyxrc.language_custom_package; // suppress the babel call if there is no BabelName defined --- Summary of changes: src/BufferParams.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX master] Rework language package detection
The branch, master, has been updated. - Log - commit 6c1326cdeba128486cc46deadf6b1dde50ab9c77 Author: Juergen Spitzmueller sp...@lyx.org Date: Mon Jul 23 14:34:24 2012 +0200 Rework language package detection This puts the diverse use[LangPack] function into one (less error-prone) function and differentiates the custom package from the babel case diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 6c975d6..36edd59 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1923,6 +1923,15 @@ bool BufferParams::writeLaTeX(otexstream os, LaTeXFeatures features, } } + // Load custom language package here + if (features.langPackage() == LaTeXFeatures::LANG_PACK_CUSTOM) { + if (lang_package == default) + lyxpreamble += from_utf8(lyxrc.language_custom_package); + else + lyxpreamble += from_utf8(lang_package); + lyxpreamble += '\n'; + } + docstring const i18npreamble = features.getTClassI18nPreamble(use_babel, use_polyglossia); if (!i18npreamble.empty()) @@ -2645,12 +2654,6 @@ string const BufferParams::font_encoding() const string BufferParams::babelCall(string const lang_opts, bool const langoptions) const { - if (lang_package != auto lang_package != babel -lang_package != default lang_package != none) - return lang_package; - if (lang_package == default -lyxrc.language_package_selection == LyXRC::LP_CUSTOM) - return lyxrc.language_custom_package; // suppress the babel call if there is no BabelName defined // for the document language in the lib/languages file and if no // other languages are used (lang_opts is then empty) diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 489d7a4..1a976f9 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -290,33 +290,69 @@ LaTeXFeatures::LaTeXFeatures(Buffer const b, BufferParams const p, {} -bool LaTeXFeatures::useBabel() const +LaTeXFeatures::LangPackage LaTeXFeatures::langPackage() const { - if (usePolyglossia() - || bufferParams().lang_package == none - || (bufferParams().lang_package == default -lyxrc.language_package_selection == LyXRC::LP_NONE)) - return false; - - return (bufferParams().language-lang() != lyxrc.default_language -!bufferParams().language-babel().empty()) - || this-hasLanguages(); -} - - -bool LaTeXFeatures::usePolyglossia() const -{ - if (bufferParams().lang_package == default) - return (lyxrc.language_package_selection == LyXRC::LP_AUTO) -isRequired(polyglossia) -isAvailable(polyglossia) -!params_.documentClass().provides(babel) -this-hasOnlyPolyglossiaLanguages(); - return (bufferParams().lang_package == auto) -isRequired(polyglossia) + string const local_lp = bufferParams().lang_package; + + // Locally, custom is just stored as a string + // in bufferParams().lang_package. + if (local_lp != auto +local_lp != babel +local_lp != default +local_lp != none) +return LANG_PACK_CUSTOM; + + if (local_lp == none) + return LANG_PACK_NONE; + + /* If auto is selected, we load polyglossia if required, +* else we select babel. +* If babel is selected (either directly or via the auto +* mechanism), we really do only require it if we have +* a language that needs it. +*/ + bool const polyglossia_required = + isRequired(polyglossia) isAvailable(polyglossia) !params_.documentClass().provides(babel) this-hasOnlyPolyglossiaLanguages(); + bool const babel_required = + (bufferParams().language-lang() != lyxrc.default_language + !bufferParams().language-babel().empty()) + || !this-getBabelLanguages().empty(); + + if (local_lp == auto) { + // polyglossia requirement has priority over babel + if (polyglossia_required) + return LANG_PACK_POLYGLOSSIA; + else if (babel_required) + return LANG_PACK_BABEL; + } + + if (local_lp == babel) { + if (babel_required) + return LANG_PACK_BABEL; + } + + if (local_lp == default) { + switch (lyxrc.language_package_selection) { + case LyXRC::LP_AUTO: + // polyglossia requirement has priority over babel + if (polyglossia_required) +
[LyX master] Fix direction of brackets in Hebrew when using Polyglossia (bug #8251)
The branch, master, has been updated. - Log - commit 0b5c20fc0ff12d4f3981faf92deb9081452ecabf Author: Juergen Spitzmueller sp...@lyx.org Date: Mon Jul 23 14:56:00 2012 +0200 Fix direction of brackets in Hebrew when using Polyglossia (bug #8251) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 807abbd..8126a2f 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -330,6 +330,7 @@ public: /// void latexSpecialChar( otexstream os, + BufferParams const bparams, OutputParams const runparams, Font const running_font, Change const running_change, @@ -1156,6 +1157,7 @@ void Paragraph::Private::latexInset(BufferParams const bparams, void Paragraph::Private::latexSpecialChar(otexstream os, + BufferParams const bparams, OutputParams const runparams, Font const running_font, Change const running_change, @@ -1164,7 +1166,10 @@ void Paragraph::Private::latexSpecialChar(otexstream os, pos_type end_pos, unsigned int column) { - char_type const c = text_[i]; + // With polyglossia, brackets and stuff need not be reversed + // in RTL scripts (see bug #8251) + char_type const c = (runparams.use_polyglossia) ? + owner_-getUChar(bparams, i) : text_[i]; if (style.pass_thru || runparams.pass_thru) { if (c != '\0') { @@ -1897,16 +1902,23 @@ FontSize Paragraph::highestFontInRange char_type Paragraph::getUChar(BufferParams const bparams, pos_type pos) const { char_type c = d-text_[pos]; - if (!lyxrc.rtl_support) + if (!lyxrc.rtl_support || !getFontSettings(bparams, pos).isRightToLeft()) return c; + // FIXME: The arabic special casing is due to the difference of arabic + // round brackets input introduced in r18599. Check if this should be + // unified with Hebrew or at least if all bracket types should be + // handled the same (file format change in either case). + string const lang = getFontSettings(bparams, pos).language()-lang(); + bool const arabic = lang == arabic_arabtex || lang == arabic_arabi || + lang == farsi; char_type uc = c; switch (c) { case '(': - uc = ')'; + uc = arabic ? c : ')'; break; case ')': - uc = '('; + uc = arabic ? c : '('; break; case '[': uc = ']'; @@ -1927,9 +1939,8 @@ char_type Paragraph::getUChar(BufferParams const bparams, pos_type pos) const uc = ''; break; } - if (uc != c getFontSettings(bparams, pos).isRightToLeft()) - return uc; - return c; + + return uc; } @@ -2567,7 +2578,7 @@ void Paragraph::latex(BufferParams const bparams, } else { if (i = start_pos (end_pos == -1 || i end_pos)) { try { - d-latexSpecialChar(os, rp, running_font, runningChange, + d-latexSpecialChar(os, bparams, rp, running_font, runningChange, style, i, end_pos, column); } catch (EncodingException e) { if (runparams.dryrun) { diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index c33bd79..7c7fd3e 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -237,6 +237,8 @@ void RowPainter::paintChars(pos_type vpos, FontInfo const font, str.reserve(100); str.push_back(prev_char); + // FIXME: Why only round brackets and why the difference to + // Hebrew? See also Paragraph::getUChar if (arabic) { char_type c = str[0]; if (c == '(') @@ -326,6 +328,8 @@ void RowPainter::paintChars(pos_type vpos, FontInfo const font, break; */ + // FIXME: Why only round brackets and why the difference to + // Hebrew? See also Paragraph::getUChar if (arabic) { if (c == '(') c = ')'; --- Summary of changes: src/Paragraph.cpp | 27 +++ src/rowpainter.cpp |4 2 files changed, 23 insertions(+), 8 deletions(-)
[LyX master] Whitespace
The branch, master, has been updated. - Log - commit b55a6454d905e0f46cc8ada6d7929483e5ffe62d Author: Juergen Spitzmueller sp...@lyx.org Date: Mon Jul 23 14:59:45 2012 +0200 Whitespace diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 8126a2f..71f6891 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1910,8 +1910,8 @@ char_type Paragraph::getUChar(BufferParams const bparams, pos_type pos) const // unified with Hebrew or at least if all bracket types should be // handled the same (file format change in either case). string const lang = getFontSettings(bparams, pos).language()-lang(); - bool const arabic = lang == arabic_arabtex || lang == arabic_arabi || - lang == farsi; + bool const arabic = lang == arabic_arabtex || lang == arabic_arabi + || lang == farsi; char_type uc = c; switch (c) { case '(': --- Summary of changes: src/Paragraph.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX 2.0.x] Suppress babel RTL commands when using polyglossia (part of #8251)
The branch, 2.0.x, has been updated. - Log - commit d10927c6f263bde4c33aad7a28d8e103844f27d6 Author: Juergen Spitzmueller sp...@lyx.org Date: Mon Jul 23 08:40:37 2012 +0200 Suppress babel RTL commands when using polyglossia (part of #8251) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 389e292..55df8b4 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1068,6 +1068,7 @@ void Paragraph::Private::latexInset(BufferParams const bparams, odocstream::pos_type const len = os.os().tellp(); if (inset-forceLTR() +!runparams.use_polyglossia running_font.isRightToLeft() // ERT is an exception, it should be output with no // decorations at all diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 1e91d5c..768b8cf 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2518,7 +2518,8 @@ void Tabular::TeXRow(otexstream os, row_type row, Paragraph const par = inset-paragraphs().front(); bool rtl = par.isRTL(buffer().params()) !par.empty() -getPWidth(cell).zero(); +getPWidth(cell).zero() +!runparams.use_polyglossia; if (rtl) { string const lang = diff --git a/status.20x b/status.20x index c720566..65a6e57 100644 --- a/status.20x +++ b/status.20x @@ -88,11 +88,14 @@ What's new - Write correct DTD for MathML (bug #8160). -- Make the ~ char in Basque, Estonian and Galician non-active (bug #8265). +- Make the ~ char in Basque, Estonian and Galician non-active (bug 8265). - Embrace babel settings to \makeatletter ... \makeatother if they contain an @ glyph. +- Fix LaTeX errors with right-to-left text when using XeTeX/Polyglossia + (part of bug 8251). + * USER INTERFACE --- Summary of changes: src/Paragraph.cpp |1 + src/insets/InsetTabular.cpp |3 ++- status.20x |5 - 3 files changed, 7 insertions(+), 2 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX 2.0.x] arabi requires the language option to be passed to babel directly. Candidate for branch
The branch, 2.0.x, has been updated. - Log - commit 0fcd35565c0b9ed4218aeb82c957c41a89846ad4 Author: Juergen Spitzmueller sp...@lyx.org Date: Mon Jul 23 11:03:25 2012 +0200 arabi requires the language option to be passed to babel directly. Candidate for branch diff --git a/lib/languages b/lib/languages index 94c0189..b7566b3 100644 --- a/lib/languages +++ b/lib/languages @@ -124,6 +124,7 @@ Language arabic_arabi PolyglossiaName arabic Encoding cp1256 RTL true + AsBabelOptions true LangCode ar_SA End diff --git a/status.20x b/status.20x index 65a6e57..450591c 100644 --- a/status.20x +++ b/status.20x @@ -86,7 +86,7 @@ What's new - Fixed the layout file for scientific articles published by the American Psychological Association (APA) (bug 8187). -- Write correct DTD for MathML (bug #8160). +- Write correct DTD for MathML (bug 8160). - Make the ~ char in Basque, Estonian and Galician non-active (bug 8265). @@ -96,6 +96,8 @@ What's new - Fix LaTeX errors with right-to-left text when using XeTeX/Polyglossia (part of bug 8251). +- Fix babel call with Arabic (arabi). + * USER INTERFACE --- Summary of changes: lib/languages |1 + status.20x|4 +++- 2 files changed, 4 insertions(+), 1 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX master] Suppress babel RTL commands when using polyglossia (part of #8251)
The branch, master, has been updated. - Log - commit a1e2e12ba4443c2d67a96fcabbddc9337598f828 Author: Juergen SpitzmuellerDate: Mon Jul 23 08:40:37 2012 +0200 Suppress babel RTL commands when using polyglossia (part of #8251) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index d93594a..807abbd 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1076,6 +1076,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, odocstream::pos_type const len = os.os().tellp(); if (inset->forceLTR() + && !runparams.use_polyglossia && running_font.isRightToLeft() // ERT is an exception, it should be output with no // decorations at all diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 8e796db..58505cc 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2493,7 +2493,8 @@ void Tabular::TeXRow(otexstream & os, row_type row, Paragraph const & par = inset->paragraphs().front(); bool rtl = par.isRTL(buffer().params()) && !par.empty() - && getPWidth(cell).zero(); + && getPWidth(cell).zero() + && !runparams.use_polyglossia; if (rtl) { string const lang = --- Summary of changes: src/Paragraph.cpp |1 + src/insets/InsetTabular.cpp |3 ++- 2 files changed, 3 insertions(+), 1 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX master] Fixes to the language package call
The branch, master, has been updated. - Log - commit 566a5f2b7513ffbd75cc92f713dc2636f37e Author: Juergen SpitzmuellerDate: Mon Jul 23 11:36:55 2012 +0200 Fixes to the language package call * Assure that really no language package is called when none is selected. * Only call global custom package if global is desired. This is a candidate for branch as well. diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 128b9ec..872fd30 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2648,7 +2648,8 @@ string BufferParams::babelCall(string const & lang_opts, bool const langoptions) if (lang_package != "auto" && lang_package != "babel" && lang_package != "default" && lang_package != "none") return lang_package; - if (lyxrc.language_package_selection == LyXRC::LP_CUSTOM) + if (lang_package == "auto" + && lyxrc.language_package_selection == LyXRC::LP_CUSTOM) return lyxrc.language_custom_package; // suppress the babel call if there is no BabelName defined // for the document language in the lib/languages file and if no diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 6de5db6..489d7a4 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -292,16 +292,14 @@ LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, bool LaTeXFeatures::useBabel() const { - if (usePolyglossia()) + if (usePolyglossia() + || bufferParams().lang_package == "none" + || (bufferParams().lang_package == "default" + && lyxrc.language_package_selection == LyXRC::LP_NONE)) return false; - if (bufferParams().lang_package == "default") - return (lyxrc.language_package_selection != LyXRC::LP_NONE) - || (bufferParams().language->lang() != lyxrc.default_language - && !bufferParams().language->babel().empty()) - || this->hasLanguages(); - return (bufferParams().lang_package != "none") - || (bufferParams().language->lang() != lyxrc.default_language - && !bufferParams().language->babel().empty()) + + return (bufferParams().language->lang() != lyxrc.default_language + && !bufferParams().language->babel().empty()) || this->hasLanguages(); } --- Summary of changes: src/BufferParams.cpp |3 ++- src/LaTeXFeatures.cpp | 16 +++- 2 files changed, 9 insertions(+), 10 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX master] Fix thinko
The branch, master, has been updated. - Log - commit 508dd27e4488240e0991f36c3b29340101f934af Author: Juergen SpitzmuellerDate: Mon Jul 23 11:39:41 2012 +0200 Fix thinko diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 872fd30..6c975d6 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2648,7 +2648,7 @@ string BufferParams::babelCall(string const & lang_opts, bool const langoptions) if (lang_package != "auto" && lang_package != "babel" && lang_package != "default" && lang_package != "none") return lang_package; - if (lang_package == "auto" + if (lang_package == "default" && lyxrc.language_package_selection == LyXRC::LP_CUSTOM) return lyxrc.language_custom_package; // suppress the babel call if there is no BabelName defined --- Summary of changes: src/BufferParams.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX master] Rework language package detection
The branch, master, has been updated. - Log - commit 6c1326cdeba128486cc46deadf6b1dde50ab9c77 Author: Juergen SpitzmuellerDate: Mon Jul 23 14:34:24 2012 +0200 Rework language package detection This puts the diverse use[LangPack] function into one (less error-prone) function and differentiates the custom package from the babel case diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 6c975d6..36edd59 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1923,6 +1923,15 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, } } + // Load custom language package here + if (features.langPackage() == LaTeXFeatures::LANG_PACK_CUSTOM) { + if (lang_package == "default") + lyxpreamble += from_utf8(lyxrc.language_custom_package); + else + lyxpreamble += from_utf8(lang_package); + lyxpreamble += '\n'; + } + docstring const i18npreamble = features.getTClassI18nPreamble(use_babel, use_polyglossia); if (!i18npreamble.empty()) @@ -2645,12 +2654,6 @@ string const BufferParams::font_encoding() const string BufferParams::babelCall(string const & lang_opts, bool const langoptions) const { - if (lang_package != "auto" && lang_package != "babel" - && lang_package != "default" && lang_package != "none") - return lang_package; - if (lang_package == "default" - && lyxrc.language_package_selection == LyXRC::LP_CUSTOM) - return lyxrc.language_custom_package; // suppress the babel call if there is no BabelName defined // for the document language in the lib/languages file and if no // other languages are used (lang_opts is then empty) diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 489d7a4..1a976f9 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -290,33 +290,69 @@ LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, {} -bool LaTeXFeatures::useBabel() const +LaTeXFeatures::LangPackage LaTeXFeatures::langPackage() const { - if (usePolyglossia() - || bufferParams().lang_package == "none" - || (bufferParams().lang_package == "default" - && lyxrc.language_package_selection == LyXRC::LP_NONE)) - return false; - - return (bufferParams().language->lang() != lyxrc.default_language - && !bufferParams().language->babel().empty()) - || this->hasLanguages(); -} - - -bool LaTeXFeatures::usePolyglossia() const -{ - if (bufferParams().lang_package == "default") - return (lyxrc.language_package_selection == LyXRC::LP_AUTO) - && isRequired("polyglossia") - && isAvailable("polyglossia") - && !params_.documentClass().provides("babel") - && this->hasOnlyPolyglossiaLanguages(); - return (bufferParams().lang_package == "auto") - && isRequired("polyglossia") + string const local_lp = bufferParams().lang_package; + + // Locally, custom is just stored as a string + // in bufferParams().lang_package. + if (local_lp != "auto" + && local_lp != "babel" + && local_lp != "default" + && local_lp != "none") +return LANG_PACK_CUSTOM; + + if (local_lp == "none") + return LANG_PACK_NONE; + + /* If "auto" is selected, we load polyglossia if required, +* else we select babel. +* If babel is selected (either directly or via the "auto" +* mechanism), we really do only require it if we have +* a language that needs it. +*/ + bool const polyglossia_required = + isRequired("polyglossia") && isAvailable("polyglossia") && !params_.documentClass().provides("babel") && this->hasOnlyPolyglossiaLanguages(); + bool const babel_required = + (bufferParams().language->lang() != lyxrc.default_language +&& !bufferParams().language->babel().empty()) + || !this->getBabelLanguages().empty(); + + if (local_lp == "auto") { + // polyglossia requirement has priority over babel + if (polyglossia_required) + return LANG_PACK_POLYGLOSSIA; + else if (babel_required) + return LANG_PACK_BABEL; + } + + if (local_lp == "babel") { + if (babel_required) + return LANG_PACK_BABEL; + } + + if (local_lp == "default") { + switch (lyxrc.language_package_selection) { + case LyXRC::LP_AUTO: + //
[LyX master] Fix direction of brackets in Hebrew when using Polyglossia (bug #8251)
The branch, master, has been updated. - Log - commit 0b5c20fc0ff12d4f3981faf92deb9081452ecabf Author: Juergen SpitzmuellerDate: Mon Jul 23 14:56:00 2012 +0200 Fix direction of brackets in Hebrew when using Polyglossia (bug #8251) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 807abbd..8126a2f 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -330,6 +330,7 @@ public: /// void latexSpecialChar( otexstream & os, + BufferParams const & bparams, OutputParams const & runparams, Font const & running_font, Change const & running_change, @@ -1156,6 +1157,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, void Paragraph::Private::latexSpecialChar(otexstream & os, + BufferParams const & bparams, OutputParams const & runparams, Font const & running_font, Change const & running_change, @@ -1164,7 +1166,10 @@ void Paragraph::Private::latexSpecialChar(otexstream & os, pos_type end_pos, unsigned int & column) { - char_type const c = text_[i]; + // With polyglossia, brackets and stuff need not be reversed + // in RTL scripts (see bug #8251) + char_type const c = (runparams.use_polyglossia) ? + owner_->getUChar(bparams, i) : text_[i]; if (style.pass_thru || runparams.pass_thru) { if (c != '\0') { @@ -1897,16 +1902,23 @@ FontSize Paragraph::highestFontInRange char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const { char_type c = d->text_[pos]; - if (!lyxrc.rtl_support) + if (!lyxrc.rtl_support || !getFontSettings(bparams, pos).isRightToLeft()) return c; + // FIXME: The arabic special casing is due to the difference of arabic + // round brackets input introduced in r18599. Check if this should be + // unified with Hebrew or at least if all bracket types should be + // handled the same (file format change in either case). + string const & lang = getFontSettings(bparams, pos).language()->lang(); + bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" || + lang == "farsi"; char_type uc = c; switch (c) { case '(': - uc = ')'; + uc = arabic ? c : ')'; break; case ')': - uc = '('; + uc = arabic ? c : '('; break; case '[': uc = ']'; @@ -1927,9 +1939,8 @@ char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const uc = '<'; break; } - if (uc != c && getFontSettings(bparams, pos).isRightToLeft()) - return uc; - return c; + + return uc; } @@ -2567,7 +2578,7 @@ void Paragraph::latex(BufferParams const & bparams, } else { if (i >= start_pos && (end_pos == -1 || i < end_pos)) { try { - d->latexSpecialChar(os, rp, running_font, runningChange, + d->latexSpecialChar(os, bparams, rp, running_font, runningChange, style, i, end_pos, column); } catch (EncodingException & e) { if (runparams.dryrun) { diff --git a/src/rowpainter.cpp b/src/rowpainter.cpp index c33bd79..7c7fd3e 100644 --- a/src/rowpainter.cpp +++ b/src/rowpainter.cpp @@ -237,6 +237,8 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font, str.reserve(100); str.push_back(prev_char); + // FIXME: Why only round brackets and why the difference to + // Hebrew? See also Paragraph::getUChar if (arabic) { char_type c = str[0]; if (c == '(') @@ -326,6 +328,8 @@ void RowPainter::paintChars(pos_type & vpos, FontInfo const & font, break; */ + // FIXME: Why only round brackets and why the difference to + // Hebrew? See also Paragraph::getUChar if (arabic) { if (c == '(') c = ')'; --- Summary of changes: src/Paragraph.cpp | 27 +++ src/rowpainter.cpp |4 2 files
[LyX master] Whitespace
The branch, master, has been updated. - Log - commit b55a6454d905e0f46cc8ada6d7929483e5ffe62d Author: Juergen SpitzmuellerDate: Mon Jul 23 14:59:45 2012 +0200 Whitespace diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 8126a2f..71f6891 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1910,8 +1910,8 @@ char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const // unified with Hebrew or at least if all bracket types should be // handled the same (file format change in either case). string const & lang = getFontSettings(bparams, pos).language()->lang(); - bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" || - lang == "farsi"; + bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" + || lang == "farsi"; char_type uc = c; switch (c) { case '(': --- Summary of changes: src/Paragraph.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX 2.0.x] Suppress babel RTL commands when using polyglossia (part of #8251)
The branch, 2.0.x, has been updated. - Log - commit d10927c6f263bde4c33aad7a28d8e103844f27d6 Author: Juergen SpitzmuellerDate: Mon Jul 23 08:40:37 2012 +0200 Suppress babel RTL commands when using polyglossia (part of #8251) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 389e292..55df8b4 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1068,6 +1068,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams, odocstream::pos_type const len = os.os().tellp(); if (inset->forceLTR() + && !runparams.use_polyglossia && running_font.isRightToLeft() // ERT is an exception, it should be output with no // decorations at all diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 1e91d5c..768b8cf 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -2518,7 +2518,8 @@ void Tabular::TeXRow(otexstream & os, row_type row, Paragraph const & par = inset->paragraphs().front(); bool rtl = par.isRTL(buffer().params()) && !par.empty() - && getPWidth(cell).zero(); + && getPWidth(cell).zero() + && !runparams.use_polyglossia; if (rtl) { string const lang = diff --git a/status.20x b/status.20x index c720566..65a6e57 100644 --- a/status.20x +++ b/status.20x @@ -88,11 +88,14 @@ What's new - Write correct DTD for MathML (bug #8160). -- Make the ~ char in Basque, Estonian and Galician non-active (bug #8265). +- Make the ~ char in Basque, Estonian and Galician non-active (bug 8265). - Embrace babel settings to \makeatletter ... \makeatother if they contain an @ glyph. +- Fix LaTeX errors with right-to-left text when using XeTeX/Polyglossia + (part of bug 8251). + * USER INTERFACE --- Summary of changes: src/Paragraph.cpp |1 + src/insets/InsetTabular.cpp |3 ++- status.20x |5 - 3 files changed, 7 insertions(+), 2 deletions(-) hooks/post-receive -- The LyX Source Repository
[LyX 2.0.x] arabi requires the language option to be passed to babel directly. Candidate for branch
The branch, 2.0.x, has been updated. - Log - commit 0fcd35565c0b9ed4218aeb82c957c41a89846ad4 Author: Juergen SpitzmuellerDate: Mon Jul 23 11:03:25 2012 +0200 arabi requires the language option to be passed to babel directly. Candidate for branch diff --git a/lib/languages b/lib/languages index 94c0189..b7566b3 100644 --- a/lib/languages +++ b/lib/languages @@ -124,6 +124,7 @@ Language arabic_arabi PolyglossiaName arabic Encoding cp1256 RTL true + AsBabelOptions true LangCode ar_SA End diff --git a/status.20x b/status.20x index 65a6e57..450591c 100644 --- a/status.20x +++ b/status.20x @@ -86,7 +86,7 @@ What's new - Fixed the layout file for scientific articles published by the American Psychological Association (APA) (bug 8187). -- Write correct DTD for MathML (bug #8160). +- Write correct DTD for MathML (bug 8160). - Make the ~ char in Basque, Estonian and Galician non-active (bug 8265). @@ -96,6 +96,8 @@ What's new - Fix LaTeX errors with right-to-left text when using XeTeX/Polyglossia (part of bug 8251). +- Fix babel call with Arabic (arabi). + * USER INTERFACE --- Summary of changes: lib/languages |1 + status.20x|4 +++- 2 files changed, 4 insertions(+), 1 deletions(-) hooks/post-receive -- The LyX Source Repository