X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FParagraph.cpp;h=fcf4a73a8153de3a05ac41a13d218a04fccae70b;hb=63c1979401271381e7667f8e55a018a728788aaa;hp=309c20caffc442873690df490b044340bd997236;hpb=094341fa5a9597775a7adae723223e7580ab6b3a;p=lyx.git diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 309c20caff..fcf4a73a81 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -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 @@ -1490,6 +1501,16 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const for (; icit != iend; ++icit) { if (icit->inset) { features.inDeletedInset(owner_->isDeleted(icit->pos)); + if (icit->inset->lyxCode() == FOOT_CODE) { + // FIXME: an item inset would make things much easier. + if ((layout_->latextype == LATEX_LIST_ENVIRONMENT + || (layout_->latextype == LATEX_ITEM_ENVIRONMENT + && layout_->margintype == MARGIN_FIRST_DYNAMIC)) + && (icit->pos < begin_of_body_ + || (icit->pos == begin_of_body_ + && (icit->pos == 0 || text_[icit->pos - 1] != ' ')))) + features.saveNoteEnv("description"); + } icit->inset->validate(features); features.inDeletedInset(false); if (layout_->needprotect && @@ -1499,15 +1520,21 @@ 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) { if (features.runparams().isFullUnicode() && bp.useNonTeXFonts) features.require("textquotedblp"); - else if (bp.main_font_encoding() != "T1") + else if (bp.main_font_encoding() != "T1" + || ((&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); } } @@ -2453,6 +2480,8 @@ void Paragraph::latex(BufferParams const & bparams, runparams.wasDisplayMath = runparams.inDisplayMath; runparams.inDisplayMath = false; bool deleted_display_math = false; + Change const & change = runparams.inDeletedInset + ? runparams.changeOfDeletedInset : lookupChange(i); // Check whether a display math inset follows if (d->text_[i] == META_INSET @@ -2467,11 +2496,28 @@ void Paragraph::latex(BufferParams const & bparams, // cannot set it here because it is a counter. deleted_display_math = isDeleted(i); } + if (bparams.output_changes && deleted_display_math + && runningChange == change + && change.type == Change::DELETED + && !os.afterParbreak()) { + // A display math in the same paragraph follows. + // We have to close and then reopen \lyxdeleted, + // otherwise the math will be shifted up. + OutputParams rp = runparams; + if (open_font) { + bool needPar = false; + column += running_font.latexWriteEndChanges( + os, bparams, rp, basefont, + basefont, needPar); + open_font = false; + } + basefont = getLayoutFont(bparams, outerfont); + running_font = basefont; + column += Changes::latexMarkChange(os, bparams, + Change(Change::INSERTED), change, rp); + } } - Change const & change = runparams.inDeletedInset - ? runparams.changeOfDeletedInset : lookupChange(i); - if (bparams.output_changes && runningChange != change) { if (open_font) { bool needPar = false; @@ -2522,6 +2568,7 @@ void Paragraph::latex(BufferParams const & bparams, bool const using_begin_end = runparams.use_polyglossia || !lang_end_command.empty(); if (!running_lang.empty() && + (!using_begin_end || running_lang == openLanguageName()) && current_font.language()->encoding()->package() == Encoding::CJK) { string end_tag = subst(lang_end_command, "$$lang", @@ -2548,7 +2595,7 @@ void Paragraph::latex(BufferParams const & bparams, char_type const c = d->text_[i]; // A display math inset inside an ulem command will be output - // as a box of width \columnwidth, so we have to either disable + // as a box of width \linewidth, so we have to either disable // indentation if the inset starts a paragraph, or start a new // line to accommodate such box. This has to be done before // writing any font changing commands. @@ -3870,13 +3917,13 @@ void Paragraph::locateWord(pos_type & from, pos_type & to, to = from; return; } - // no break here, we go to the next + // fall through case WHOLE_WORD: // If we are already at the beginning of a word, do nothing if (!from || isWordSeparator(from - 1)) break; - // no break here, we go to the next + // fall through case PREVIOUS_WORD: // always move the cursor to the beginning of previous word