]> git.lyx.org Git - features.git/commitdiff
Consistent output of breakable/non-breakable dashes on all TeX engines.
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 16 Dec 2017 15:11:25 +0000 (16:11 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 17 Dec 2017 18:24:46 +0000 (19:24 +0100)
Fixes: #10839
(cherry picked from commit d56a5447f30688286c1fe19f3b51225f4b586b3e)

lib/RELEASE-NOTES
src/LaTeXFeatures.cpp
src/Paragraph.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/ui/FontUi.ui

index ff7e67ee721112a3aeebd1e9ffe9b246b85fdf7a..1788167ad5ac863144599231d6373379ee6763ed 100644 (file)
   if needed, as usual.
 
 * The new setting
-  "Document->Settings->Fonts->Output em- and en-dash as ligatures" forces
-  output of en- and em-dashes as -- and --- when exporting to LaTeX.
-  It is is "true" by default but "false" when opening documents edited
-  with LyX 2.2.
-  See chapter 3.9.1.1 "Dashes and line breaks" of the User Guide and
+  "Document->Settings->Fonts->Disallow line breaks after dashes" forces
+  output of en- and em-dashes as \textendash and \textemdash when exporting
+  to LaTeX. It is is "false" by default but "true" when opening documents
+  edited with LyX 2.2.
+  See chapter 3.9.1.1 "Dashes and Line Breaks" of the User Guide and
   "Caveats when upgrading from earlier versions to 2.3.x" below.
 
 * The following UI translations were dropped, because the lack of translation
   the external_templates file, you will have to move the modifications to
   the respective *.xtemplate file manually.
 
-* By default, LyX 2.3 forces output of all en and em dashes as -- and ---
-  when exporting to LaTeX. This can lead to incorrect line breaks, wrong
-  characters in typewriter fonts, and problems with some LaTeX packages.
-  Unselect "Document->Settings->Fonts->Output em- and en-dash as ligatures"
-  to keep the LyX 2.2 behaviour and avoid these problems. See chapter 3.9.1.1
-  "Dashes and line breaks" of the User Guide for details.
+* By default, LyX 2.3 outputs en- and em-dashes after which a line break can
+  occur in the output. Sometimes, this results in undesired line breaks.
+  Select "Document->Settings->Fonts->Disallow line breaks after dashes"
+  to keep the LyX 2.2 behaviour, where such line breaks have been generally
+  suppressed. See chapter 3.9.1.1, "Dashes and Line Breaks", of the User Guide
+  for details.
 
 * ZWSP characters (u200b) following literal em- and en-dashes are deleted by
   lyx2lyx when converting to 2.3 format. If you used them as optional line
   breaks after dashes, convert them to space insets before opening your
   document with LyX 2.3 or the optional line breaks will be lost!
 
-* If using TeX fonts and en- and em-dashes are output as font ligatures,
+* If using TeX fonts and en- and em-dashes are output in breakable form,
   when exporting documents containing en- and em-dashes to the format of
   LyX 2.0 or earlier, the following line has to be manually added to the
   unicodesymbols file of that LyX version:<br>
index 3f9eb6776267ab6fb3b0c00efb21a1c53d4d9898..d4b0018b73dbe936743f71bc5a52c7fd7a603dfd 100644 (file)
@@ -1318,6 +1318,9 @@ TexString LaTeXFeatures::getMacros() const
                macros << getPreambleSnippets();
        }
 
+       if (mustProvide("xetexdashbreakstate"))
+               macros << "\\XeTeXdashbreakstate 0" << '\n';
+
        if (mustProvide("papersize")) {
                if (runparams_.flavor == OutputParams::LATEX
                    || runparams_.flavor == OutputParams::DVILUATEX)
index 291881911bff5a7a4b7930b2028b3c3ddc6a266b..fcf4a73a8153de3a05ac41a13d218a04fccae70b 100644 (file)
@@ -1289,7 +1289,10 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
 
        case 0x2013:
        case 0x2014:
-               if (bparams.use_dash_ligatures && !bparams.useNonTeXFonts) {
+               // XeTeX's dash behaviour is determined via a global setting
+               if (bparams.use_dash_ligatures
+                   && owner_->getFontSettings(bparams, i).fontInfo().family() != TYPEWRITER_FAMILY
+                   && (!bparams.useNonTeXFonts || runparams.flavor != OutputParams::XETEX)) {
                        if (c == 0x2013) {
                                // en-dash
                                os << "--";
@@ -1417,6 +1420,14 @@ bool Paragraph::Private::latexSpecialT3(char_type const c, otexstream & os,
                os << "\\textvertline" << termcmd;
                column += 14;
                return true;
+       case 0x2013:
+               os << "\\textendash" << termcmd;
+               column += 12;
+               return true;
+       case 0x2014:
+               os << "\\textemdash" << termcmd;
+               column += 12;
+               return true;
        default:
                return false;
        }
@@ -1425,11 +1436,11 @@ bool Paragraph::Private::latexSpecialT3(char_type const c, otexstream & os,
 
 void Paragraph::Private::validate(LaTeXFeatures & features) const
 {
+       Buffer const & buf = inset_owner_->buffer();
+       BufferParams const & bp = features.runparams().is_child
+               ? buf.masterParams() : buf.params();
        if (layout_->inpreamble && inset_owner_) {
                bool const is_command = layout_->latextype == LATEX_COMMAND;
-               Buffer const & buf = inset_owner_->buffer();
-               BufferParams const & bp = features.runparams().is_child
-                       ? buf.masterParams() : buf.params();
                Font f;
                // Using a string stream here circumvents the encoding
                // switching machinery of odocstream. Therefore the
@@ -1509,7 +1520,6 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
        }
 
        // then the contents
-       BufferParams const bp = features.buffer().masterParams();
        for (pos_type i = 0; i < int(text_.size()) ; ++i) {
                char_type c = text_[i];
                if (c == 0x0022) {
@@ -1519,6 +1529,12 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
                                 || ((&owner_->getFontSettings(bp, i))->language()->internalFontEncoding()))
                                features.require("textquotedbl");
                }
+               if (!bp.use_dash_ligatures
+                   && (c == 0x2013 || c == 0x2014)
+                   && bp.useNonTeXFonts
+                   && features.runparams().flavor == OutputParams::XETEX)
+                       // XeTeX's dash behaviour is determined via a global setting
+                       features.require("xetexdashbreakstate");
                BufferEncodings::validate(c, features);
        }
 }
index 385b3760ddc637671e7e2ec7c36dbd5c4af8c200..cea4e78d2f7af1a0802fdfab4fd1afe228fa14fa 100644 (file)
@@ -2073,7 +2073,6 @@ void GuiDocument::updateFontOptions()
                                fontModule->fontsRomanCO->currentIndex()).toString();
        fontModule->fontScCB->setEnabled(providesSC(font));
        fontModule->fontOsfCB->setEnabled(providesOSF(font));
-       fontModule->dashesCB->setEnabled(tex_fonts);
        updateMathFonts(font);
 }
 
@@ -3209,7 +3208,7 @@ void GuiDocument::applyView()
                fromqstr(fontModule->cjkFontLE->text());
 
        bp_.use_microtype = fontModule->microtypeCB->isChecked();
-       bp_.use_dash_ligatures = fontModule->dashesCB->isChecked();
+       bp_.use_dash_ligatures = !fontModule->dashesCB->isChecked();
 
        bp_.fonts_sans_scale[nontexfonts] = fontModule->scaleSansSB->value();
        bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale;
@@ -3744,7 +3743,7 @@ void GuiDocument::paramsToDialog()
                fontModule->cjkFontLE->setText(QString());
 
        fontModule->microtypeCB->setChecked(bp_.use_microtype);
-       fontModule->dashesCB->setChecked(bp_.use_dash_ligatures);
+       fontModule->dashesCB->setChecked(!bp_.use_dash_ligatures);
 
        fontModule->fontScCB->setChecked(bp_.fonts_expert_sc);
        fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures);
index f0b3fb7e8b2870e8c25862cf5b8107c8c338a07b..fc98c1b7ebdd0e7108c32eaecbf91c2b066a992b 100644 (file)
    <item row="11" column="1">
     <widget class="QCheckBox" name="dashesCB">
      <property name="toolTip">
-      <string>Use font ligatures -- and --- instead of \textendash and \textemdash for en- and em-dashes</string>
+      <string>By default, a line break can occur after en- and em-dashes and before em-dashes. Checking this box prevents that.</string>
      </property>
      <property name="text">
-      <string>Output en- and &amp;em-dashes as ligatures</string>
+      <string>Disallow l&amp;ine breaks at dashes</string>
      </property>
     </widget>
    </item>