Consistent output of breakable/non-breakable dashes on all TeX engines.

Fixes: #10839
This commit is contained in:
Juergen Spitzmueller 2017-12-16 16:11:25 +01:00
parent 4c093a50c2
commit d56a5447f3
4 changed files with 28 additions and 10 deletions

View File

@ -1318,6 +1318,9 @@ TexString LaTeXFeatures::getMacros() const
macros << getPreambleSnippets(); macros << getPreambleSnippets();
} }
if (mustProvide("xetexdashbreakstate"))
macros << "\\XeTeXdashbreakstate 0" << '\n';
if (mustProvide("papersize")) { if (mustProvide("papersize")) {
if (runparams_.flavor == OutputParams::LATEX if (runparams_.flavor == OutputParams::LATEX
|| runparams_.flavor == OutputParams::DVILUATEX) || runparams_.flavor == OutputParams::DVILUATEX)

View File

@ -1289,7 +1289,10 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
case 0x2013: case 0x2013:
case 0x2014: 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) { if (c == 0x2013) {
// en-dash // en-dash
os << "--"; os << "--";
@ -1417,6 +1420,14 @@ bool Paragraph::Private::latexSpecialT3(char_type const c, otexstream & os,
os << "\\textvertline" << termcmd; os << "\\textvertline" << termcmd;
column += 14; column += 14;
return true; return true;
case 0x2013:
os << "\\textendash" << termcmd;
column += 12;
return true;
case 0x2014:
os << "\\textemdash" << termcmd;
column += 12;
return true;
default: default:
return false; return false;
} }
@ -1425,11 +1436,11 @@ bool Paragraph::Private::latexSpecialT3(char_type const c, otexstream & os,
void Paragraph::Private::validate(LaTeXFeatures & features) const 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_) { if (layout_->inpreamble && inset_owner_) {
bool const is_command = layout_->latextype == LATEX_COMMAND; 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; Font f;
// Using a string stream here circumvents the encoding // Using a string stream here circumvents the encoding
// switching machinery of odocstream. Therefore the // switching machinery of odocstream. Therefore the
@ -1509,7 +1520,6 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
} }
// then the contents // then the contents
BufferParams const bp = features.buffer().masterParams();
for (pos_type i = 0; i < int(text_.size()) ; ++i) { for (pos_type i = 0; i < int(text_.size()) ; ++i) {
char_type c = text_[i]; char_type c = text_[i];
if (c == 0x0022) { if (c == 0x0022) {
@ -1519,6 +1529,12 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
|| ((&owner_->getFontSettings(bp, i))->language()->internalFontEncoding())) || ((&owner_->getFontSettings(bp, i))->language()->internalFontEncoding()))
features.require("textquotedbl"); 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); BufferEncodings::validate(c, features);
} }
} }

View File

@ -2074,7 +2074,6 @@ void GuiDocument::updateFontOptions()
fontModule->fontsRomanCO->currentIndex()).toString(); fontModule->fontsRomanCO->currentIndex()).toString();
fontModule->fontScCB->setEnabled(providesSC(font)); fontModule->fontScCB->setEnabled(providesSC(font));
fontModule->fontOsfCB->setEnabled(providesOSF(font)); fontModule->fontOsfCB->setEnabled(providesOSF(font));
fontModule->dashesCB->setEnabled(tex_fonts);
updateMathFonts(font); updateMathFonts(font);
} }
@ -3210,7 +3209,7 @@ void GuiDocument::applyView()
fromqstr(fontModule->cjkFontLE->text()); fromqstr(fontModule->cjkFontLE->text());
bp_.use_microtype = fontModule->microtypeCB->isChecked(); 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->scaleSansSB->value();
bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale; bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale;
@ -3745,7 +3744,7 @@ void GuiDocument::paramsToDialog()
fontModule->cjkFontLE->setText(QString()); fontModule->cjkFontLE->setText(QString());
fontModule->microtypeCB->setChecked(bp_.use_microtype); 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->fontScCB->setChecked(bp_.fonts_expert_sc);
fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures); fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures);

View File

@ -297,10 +297,10 @@
<item row="11" column="1"> <item row="11" column="1">
<widget class="QCheckBox" name="dashesCB"> <widget class="QCheckBox" name="dashesCB">
<property name="toolTip"> <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>
<property name="text"> <property name="text">
<string>Output en- and &amp;em-dashes as ligatures</string> <string>Disallow l&amp;ine breaks at dashes</string>
</property> </property>
</widget> </widget>
</item> </item>