From: José Matox Date: Sun, 11 Feb 2007 23:52:07 +0000 (+0000) Subject: Convert lyxaccents to unicode (most of the work comes from Georg) X-Git-Tag: 1.6.10~10849 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=76c3d964dfb83642961ecc504e5b10a8694e687b;p=features.git Convert lyxaccents to unicode (most of the work comes from Georg) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17144 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index ece4f3f971..2b8a15f5ce 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -347,7 +347,6 @@ src_insets_header_files = Split(''' insetinclude.h insetindex.h insetlabel.h - insetlatexaccent.h insetline.h insetmarginal.h insetnewline.h @@ -403,7 +402,6 @@ src_insets_files = Split(''' insetinclude.C insetindex.C insetlabel.C - insetlatexaccent.C insetline.C insetmarginal.C insetnewline.C diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index cb129dfb40..f71fdc200a 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -73,7 +73,7 @@ format_relation = [("0_06", [200], generate_minor_versions("0.6" , 4)), ("1_2", [220], generate_minor_versions("1.2" , 4)), ("1_3", [221], generate_minor_versions("1.3" , 7)), ("1_4", range(222,246), generate_minor_versions("1.4" , 3)), - ("1_5", range(246,259), generate_minor_versions("1.5" , 0))] + ("1_5", range(246,260), generate_minor_versions("1.5" , 0))] def formats_list(): diff --git a/lib/lyx2lyx/lyx_1_5.py b/lib/lyx2lyx/lyx_1_5.py index 3bc8a048b0..1da4327719 100644 --- a/lib/lyx2lyx/lyx_1_5.py +++ b/lib/lyx2lyx/lyx_1_5.py @@ -1086,6 +1086,26 @@ def revert_accent(document): document.body[i] = unicodedata.normalize("NFKC", document.body[i]) +def normalize_font_whitespace(document): + """ Before format 259 the font changes were ignored if a + whitespace was the last character in the sequence, this function + transfers the whitespace outside.""" + + if document.backend != "latex": + return + + lines = document.body + + char_properties = ("\\series", "\\emph", "\\color", "\\shape", "\\family") + + for i in range(len(lines)): + words = lines[i].split() + + if len(words) > 1 and words[0] in char_properties \ + and words[1] == "default" and lines[i-1][-1] == " ": + lines[i-1] = lines[i-1][:-1] + lines[i+1] = " " + lines[i+1] + ## # Conversion hub # @@ -1103,9 +1123,11 @@ convert = [[246, []], [255, []], [256, []], [257, [convert_caption]], - [258, [convert_lyxline]]] + [258, [convert_lyxline]], + [259, [convert_accent, normalize_font_whitespace]]] -revert = [[257, []], +revert = [[258, []], + [257, []], [256, [revert_caption]], [255, [revert_encodings]], [254, [revert_clearpage, revert_cleardoublepage]], diff --git a/src/buffer.C b/src/buffer.C index 91b2649307..68a5f8f9dc 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -141,7 +141,7 @@ using std::string; namespace { -int const LYX_FORMAT = 258; +int const LYX_FORMAT = 259; } // namespace anon diff --git a/src/insets/Makefile.am b/src/insets/Makefile.am index 5c3525dc99..40038526f5 100644 --- a/src/insets/Makefile.am +++ b/src/insets/Makefile.am @@ -77,8 +77,6 @@ libinsets_la_SOURCES = \ insetindex.h \ insetlabel.C \ insetlabel.h \ - insetlatexaccent.C \ - insetlatexaccent.h \ insetline.C \ insetline.h \ insetmarginal.h \ diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 94c1e2b19c..e69de29bb2 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -1,626 +0,0 @@ -/** - * \file insetlatexaccent.C - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Lars Gullik Bjønnes - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "insetlatexaccent.h" - -#include "debug.h" -#include "language.h" -#include "LColor.h" -#include "lyxlex.h" -#include "lyxrc.h" -#include "metricsinfo.h" - -#include "frontends/FontMetrics.h" -#include "frontends/Painter.h" - -#include "support/lstrings.h" - - -namespace lyx { - -using support::contains; -using support::trim; - -using std::endl; -using std::string; -using std::auto_ptr; -using std::ostream; - - -/* LatexAccent. Proper handling of accented characters */ -/* This part is done by Ivan Schreter, schreter@ccsun.tuke.sk */ -/* Later modified by Lars G. Bjønnes, larsbj@lyx.org */ - -InsetLatexAccent::InsetLatexAccent() - : candisp(false) -{} - - -InsetLatexAccent::InsetLatexAccent(string const & str) - : contents(str) -{ - checkContents(); -} - - -auto_ptr InsetLatexAccent::doClone() const -{ - return auto_ptr(new InsetLatexAccent(contents)); -} - - -void InsetLatexAccent::checkContents() - // check, if we know the modifier and can display it ok on screen -{ - candisp = false; - - if (contents.empty() || contents.length() < 2) { - lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl; - return; - } - - contents = trim(contents); - if (contents[0] != '\\') { // demand that first char is a '\\' - lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl; - return; - } - - lyxerr[Debug::KEY] << "Decode: " << contents << endl; - - remdot = false; - plusasc = false; - plusdesc = false; - - switch (contents[1]) { // second char should be one of these - case '\'': // acute - modtype = ACUTE; // acute - plusasc = true; // at the top of character - break; - case '`': // grave - modtype = GRAVE; // grave - plusasc = true; // at the top - break; - case '=': // macron - modtype = MACRON; // macron - plusasc = true; // at the top - break; - case '~': // tilde - modtype = TILDE; // tilde - plusasc = true; // at the top - break; - case 'b': // underbar - modtype = UNDERBAR; // underbar - plusdesc = true; // at the bottom - break; - case 'c': // cedilla - modtype = CEDILLA; // cedilla - plusdesc = true; // at the bottom - break; - case 'd': // underdot - modtype = UNDERDOT; // underdot - plusdesc = true; // at the bottom - break; - case 'r': // circle - modtype = CIRCLE; // circle - plusasc = true; // at the top - break; - case 't': // tie - modtype = TIE; // tie - plusasc = true; // at the top - break; - case 'u': // breve - modtype = BREVE; // breve - plusasc = true; // at the top - break; - case 'v': // caron - modtype = CARON; // caron - plusasc = true; // at the top - break; - case 'q': // special caron - modtype = SPECIAL_CARON; // special caron - plusasc = true; // at the top - break; - case 'H': // hungarian umlaut - modtype = HUNGARIAN_UMLAUT; // hungarian umlaut - plusasc = true; // at the top - break; - case '"': // umlaut - modtype = UMLAUT; // umlaut - plusasc = true; // at the top - break; - case '.': // dot - modtype = DOT; // dot - plusasc = true; // at the top - break; - case '^': // circumflex - modtype = CIRCUMFLEX; // circumflex - plusasc = true; // at the top - break; - case 'k': // ogonek - modtype = OGONEK; // ogonek - plusdesc = true; - break; - case 'i': // dot-less-i - modtype = DOT_LESS_I; // dot-less-i - plusasc = true; // at the top (not really needed) - remdot = true; - break; - case 'j': // dot-less-j - modtype = DOT_LESS_J; // dot-less-j - plusasc = true; // at the top (not really needed) - remdot = true; - break; - case 'l': // lslash - modtype = lSLASH; - plusasc = true; // at the top (not really needed) - break; - case 'L': // lslash - modtype = LSLASH; - plusasc = true; // at the top (not really needed) - break; - default: - lyxerr[Debug::KEY] << "Default" << endl; - // unknown accent (or something else) - return; - } - - // we demand that third char is a '{' (Lgb) - if (contents[2] != '{') return; - - // special clause for \i{}, \j{} \l{} and \L{} - if ((modtype == DOT_LESS_I || modtype == DOT_LESS_J - || modtype == lSLASH || modtype == LSLASH) - && contents[3] == '}') { - switch (modtype) { - case DOT_LESS_I: ic = 'i'; break; - case DOT_LESS_J: ic = 'j'; break; - case lSLASH: ic = 'l'; break; - case LSLASH: ic = 'L'; break; - default: - // if this happens something is really wrong - lyxerr << "InsetLaTexAccent: weird error." << endl; - break; - } - //ic = (modtype == DOT_LESS_J ? 'j' : 'i'); - lyxerr[Debug::KEY] << "Contents: [" << contents << ']' - << ", ic: " << ic - << ", top: " << plusasc - << ", bot: " << plusdesc - << ", dot: " << remdot - << ", mod: " << modtype << endl; - // Special case for space - } else if (contents[3] == '}') { - ic = ' '; - } else { - int i = 3; - - // now get the char - ic = contents[3]; // i will always be 3 here - - // ic should now be a alfa-char or '\\' - if (ic == '\\') { - ic = contents[++i]; // will only allow \{\i} and \{\j} - if (ic == 'i' || ic == 'j') - remdot = true; - else - return; - } else if ((ic == 'i'|| ic == 'j') && contents[4] == '}') { - // Do a rewrite: \{i} --> \{\i} - string temp = contents; - temp.erase(3, string::npos); - temp += '\\'; - temp += char(ic); - for (string::size_type j = 4; - j < contents.length(); ++j) - temp+= contents[j]; - contents= temp; - ++i; - remdot = true; - } - - // demand a '}' at the end - if (contents[++i] != '}' && contents[++i]) return; - - // fine, the char is properly decoded now (hopefully) - lyxerr[Debug::KEY] << "Contents: [" << contents << ']' - << ", ic: " << ic - << ", top: " << plusasc - << ", bot: " << plusdesc - << ", dot: " << remdot - << ", mod: " << modtype << endl; - } - candisp = true; -} - - -bool InsetLatexAccent::metrics(MetricsInfo & mi, Dimension & dim) const -{ - LyXFont & font = mi.base.font; - frontend::FontMetrics const & fm = theFontMetrics(font); - - // This function is a bit too simplistic and is just a - // "try to make a fit for all accents" approach, to - // make it better we need to know what kind of accent is - // used and add to max based on that. - if (candisp) { - if (ic == ' ') - dim.asc = fm.ascent('a'); - else - dim.asc = fm.ascent(ic); - if (plusasc) - dim.asc += (fm.maxAscent() + 3) / 3; - - if (ic == ' ') - dim.des = fm.descent('a'); - else - dim.des = fm.descent(ic); - if (plusdesc) - dim.des += 3; - - dim.wid = fm.width(ic); - } else { - dim.asc = fm.maxAscent() + 4; - dim.des = fm.maxDescent() + 4; - docstring dcon(contents.begin(), contents.end()); - dim.wid = fm.width(dcon) + 4; - } - bool const changed = dim_ != dim; - dim_ = dim; - return changed; -} - - -bool InsetLatexAccent::displayISO8859_9(PainterInfo & pi, int x, int y) const -{ - unsigned char tmpic = ic; - - switch (modtype) { - - case CEDILLA: { - if (ic == 'c') tmpic = '\xe7'; - if (ic == 'C') tmpic = '\xc7'; - if (ic == 's') tmpic = '\xfe'; - if (ic == 'S') tmpic = '\xde'; - break; - } - - case BREVE: { - if (ic == 'g') tmpic = '\xf0'; - if (ic == 'G') tmpic = '\xd0'; - break; - } - - case UMLAUT: { - if (ic == 'o') tmpic = '\xf6'; - if (ic == 'O') tmpic = '\xd6'; - if (ic == 'u') tmpic = '\xfc'; - if (ic == 'U') tmpic = '\xdc'; - break; - } - - case DOT: - if (ic == 'I') tmpic = '\xdd'; - break; - - case DOT_LESS_I: - tmpic = '\xfd'; - break; - - default: - return false; - } - - if (tmpic == ic) - return false; - - pi.pain.text(x, y, char(tmpic), pi.base.font); - return true; -} - - -void InsetLatexAccent::drawAccent(PainterInfo const & pi, int x, int y, - char_type accent) const -{ - LyXFont const & font = pi.base.font; - frontend::FontMetrics const & fm = theFontMetrics(font); - - x -= fm.center(accent); - y -= fm.ascent(ic); - y -= fm.descent(accent); - y -= fm.height(accent) / 2; - pi.pain.text(x, y, accent, font); -} - - -void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const -{ - if (lyxrc.font_norm_type == LyXRC::ISO_8859_9) - if (displayISO8859_9(pi, x, baseline)) - return; - - // All the manually drawn accents in this function could use an - // overhaul. Different ways of drawing (what metrics to use) - // should also be considered. - - LyXFont font = pi.base.font; - if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) - font.setLanguage(english_language); - - frontend::FontMetrics const & fm = theFontMetrics(font); - - if (candisp) { - int x2 = int(x + (fm.rbearing(ic) - fm.lbearing(ic)) / 2); - int hg; - int y; - if (plusasc) { - // mark at the top - hg = fm.maxDescent(); - y = baseline - dim_.asc; - if (font.shape() == LyXFont::ITALIC_SHAPE) - x2 += int(0.8 * hg); // italic - } else { - // at the bottom - hg = dim_.des; - y = baseline; - } - - double hg35 = hg * 0.6; - - // display with proper accent mark - // first the letter - pi.pain.text(x, baseline, ic, font); - - if (remdot) { - int tmpvar = baseline - fm.ascent('i'); - int tmpx = 0; - if (font.shape() == LyXFont::ITALIC_SHAPE) - tmpx += int(0.8 * hg); // italic - lyxerr[Debug::KEY] << "Removing dot." << endl; - // remove the dot first - pi.pain.fillRectangle(x + tmpx, tmpvar, dim_.wid, - fm.ascent('i') - - fm.ascent('x') - 1, - backgroundColor()); - // the five lines below is a simple hack to - // make the display of accent 'i' and 'j' - // better. It makes the accent be written - // closer to the top of the dot-less 'i' or 'j'. - char tmpic = ic; // store the ic when we - ic = 'x'; // calculates the ascent of -#ifdef WITH_WARNINGS -#warning metrics? -#endif - int asc = ascent(); // the dot-less version (here: 'x') - ic = tmpic; // set the orig ic back - y = baseline - asc; // update to new y coord. - } - - // now the rest - draw within (x, y, x + wid, y + hg) - switch (modtype) { - case ACUTE: - //drawAccent(pi, x2, baseline, '\xB4'); - drawAccent(pi, x2, baseline, 0xB4); - break; - - case GRAVE: - //drawAccent(pi, x2, baseline, '\x60'); - drawAccent(pi, x2, baseline, 0x60); - break; - - case MACRON: - //drawAccent(pi, x2, baseline, '\xAF'); - drawAccent(pi, x2, baseline, 0xAF); - break; - - case TILDE: - drawAccent(pi, x2, baseline, '~'); - break; - - case UNDERBAR: { - char_type const underbar = 0x5F; //('\x5F'); - pi.pain.text(x2 - fm.center(underbar), - baseline, underbar, font); - break; - } - - case CEDILLA: { - char_type const cedilla = 0xB8; //('\xB8'); - pi.pain.text(x2 - fm.center(cedilla), - baseline, cedilla, font); - break; - } - - case UNDERDOT: - pi.pain.text(x2 - fm.center('.'), - int(baseline + 1.5 * fm.height('.')), - '.', font); - break; - - case DOT: - drawAccent(pi, x2, baseline, '.'); - break; - - case CIRCLE: - //drawAccent(pi, x2, baseline, '\xB0'); - drawAccent(pi, x2, baseline, 0xB0); - break; - - case TIE: - pi.pain.arc(int(x2 + hg35), y + hg / 2, 2 * hg, hg, 0, 360 * 32, - LColor::foreground); - break; - - case BREVE: - pi.pain.arc(int(x2 - hg / 2), y, hg, hg, 0, -360*32, - LColor::foreground); - break; - - case CARON: { - int xp[3], yp[3]; - xp[0] = int(x2 - hg35); yp[0] = int(y + hg35); - xp[1] = int(x2); yp[1] = int(y + hg); - xp[2] = int(x2 + hg35); yp[2] = int(y + hg35); - pi.pain.lines(xp, yp, 3, LColor::foreground); - break; - } - - case SPECIAL_CARON: { - switch (ic) { - case 'L': dim_.wid = int(4.0 * dim_.wid / 5.0); break; - case 't': y -= int(hg35 / 2.0); break; - } - int xp[3], yp[3]; - xp[0] = int(x + dim_.wid); - yp[0] = int(y + hg35 + hg); - - xp[1] = int(x + dim_.wid + (hg35 / 2.0)); - yp[1] = int(y + hg + (hg35 / 2.0)); - - xp[2] = int(x + dim_.wid + (hg35 / 2.0)); - yp[2] = y + int(hg); - - pi.pain.lines(xp, yp, 3, LColor::foreground); - break; - } - - case HUNGARIAN_UMLAUT: - drawAccent(pi, x2, baseline, 0x02DD); - break; - - case UMLAUT: - drawAccent(pi, x2, baseline, '"'); - break; - - case CIRCUMFLEX: - drawAccent(pi, x2, baseline, '\x5E'); - break; - - case OGONEK: { - // this does probably not look like an ogonek, so - // it should certainly be refined - int xp[4], yp[4]; - - xp[0] = x2; - yp[0] = y; - - xp[1] = x2; - yp[1] = y + int(hg35); - - xp[2] = int(x2 - hg35); - yp[2] = y + hg / 2; - - xp[3] = x2 + hg / 4; - yp[3] = y + int(hg); - - pi.pain.lines(xp, yp, 4, LColor::foreground); - break; - } - - case lSLASH: - case LSLASH: { - int xp[2], yp[2]; - - xp[0] = x; - yp[0] = y + int(3 * hg); - - xp[1] = int(x + dim_.wid * 0.75); - yp[1] = y + int(hg); - - pi.pain.lines(xp, yp, 2, LColor::foreground); - break; - } - - case DOT_LESS_I: // dotless-i - case DOT_LESS_J: // dotless-j - // nothing to do for these - break; - } - - } else { - pi.pain.fillRectangle(x + 1, - baseline - dim_.asc + 1, dim_.wid - 2, - dim_.asc + dim_.des - 2, - backgroundColor()); - pi.pain.rectangle(x + 1, baseline - dim_.asc + 1, - dim_.wid - 2, dim_.asc + dim_.des - 2, - LColor::foreground); - docstring dcon(contents.begin(), contents.end()); - pi.pain.text(x + 2, baseline, dcon, font); - } -} - - -void InsetLatexAccent::write(Buffer const &, ostream & os) const -{ - os << "\\i " << contents << "\n"; -} - - -void InsetLatexAccent::read(Buffer const &, LyXLex & lex) -{ - lex.eatLine(); - contents = lex.getString(); - checkContents(); -} - - -int InsetLatexAccent::latex(Buffer const &, odocstream & os, - OutputParams const &) const -{ - os << from_ascii(contents); - return 0; -} - - -int InsetLatexAccent::plaintext(Buffer const &, odocstream & os, - OutputParams const &) const -{ - os << from_ascii(contents); - return 0; -} - - -int InsetLatexAccent::docbook(Buffer const &, odocstream & os, - OutputParams const &) const -{ - // FIXME UNICODE - os << from_ascii(contents); - return 0; -} - - -int InsetLatexAccent::textString(Buffer const & buf, odocstream & os, - OutputParams const & op) const -{ - return plaintext(buf, os, op); -} - - -bool InsetLatexAccent::directWrite() const -{ - return true; -} - - -InsetBase::Code InsetLatexAccent::lyxCode() const -{ - return InsetBase::ACCENT_CODE; -} - - -ostream & operator<<(ostream & o, InsetLatexAccent::ACCENT_TYPES at) -{ - return o << int(at); -} - - -} // namespace lyx diff --git a/src/insets/insetlatexaccent.h b/src/insets/insetlatexaccent.h index 33446bd11a..e69de29bb2 100644 --- a/src/insets/insetlatexaccent.h +++ b/src/insets/insetlatexaccent.h @@ -1,152 +0,0 @@ -// -*- C++ -*- -/** - * \file insetlatexaccent.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Lars Gullik Bjønnes - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef INSET_LATEX_ACCENT_H -#define INSET_LATEX_ACCENT_H - -#include "inset.h" -#include "support/types.h" - - -namespace lyx { - -class Dimension; - - -/** Insertion of accents - - Proper handling of accented characters. - This is class is supposed to handle all LaTeX accents, it - is also possible that the class will change a bit so that - it also can handle other special characters (e.g. Hstroke) - Initiated by Ivan Schreter, later modified by Lgb. - */ -class InsetLatexAccent : public InsetOld { -public: - /// - InsetLatexAccent(); - /// - explicit InsetLatexAccent(std::string const & str); - /// - bool metrics(MetricsInfo &, Dimension &) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - bool displayISO8859_9(PainterInfo & pi, int x, int y) const; - /// - void write(Buffer const &, std::ostream &) const; - /// - void read(Buffer const &, LyXLex & lex); - /// - int latex(Buffer const &, odocstream &, - OutputParams const &) const; - /// - int plaintext(Buffer const &, odocstream &, - OutputParams const &) const; - /// - int docbook(Buffer const &, odocstream &, - OutputParams const &) const; - /// the string that is passed to the TOC - virtual int textString(Buffer const &, odocstream &, - OutputParams const &) const; - /// - bool directWrite() const; - /// - InsetBase::Code lyxCode()const; - /// - inline bool canDisplay(); - // should this inset be handled like a normal charater - bool isChar() const { return true; } - - /// is this equivalent to a letter? - virtual bool isLetter() const { return candisp; } - - /// all the accent types - enum ACCENT_TYPES{ - /// - ACUTE, // 0 - /// - GRAVE, - /// - MACRON, - /// - TILDE, - /// - UNDERBAR, - /// - CEDILLA, // 5 - /// - UNDERDOT, - /// - CIRCLE, - /// - TIE, - /// - BREVE, - /// - CARON, // 10 - /// - SPECIAL_CARON, - /// - HUNGARIAN_UMLAUT, - /// - UMLAUT, - /// - DOT, - /// - CIRCUMFLEX, // 15 - /// - OGONEK, - /// - DOT_LESS_I, - /// - DOT_LESS_J, // 18 - /// - lSLASH, - /// - LSLASH - }; -private: - friend std::ostream & operator<<(std::ostream &, ACCENT_TYPES); - - virtual std::auto_ptr doClone() const; - - /// Check if we know the modifier and can display it ok on screen. - void checkContents(); - /// - void drawAccent(PainterInfo const & pi, int x, int y, char_type accent) const; - /// - std::string contents; - /// can display as proper char - bool candisp; - /// modifier type - ACCENT_TYPES modtype; - - /// remove dot from 'i' and 'j' or transform l, L into lslash, LSLaSH - bool remdot; - /// add something to ascent - accent at the top - bool plusasc; - /// add something to descent - underlined char - bool plusdesc; - /// international char - mutable char ic; -}; - - -bool InsetLatexAccent::canDisplay() -{ - return candisp; -} - - -} // namespace lyx - -#endif diff --git a/src/paragraph.C b/src/paragraph.C index 0f07ba64e0..0cdc33150a 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1058,16 +1058,6 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf, LyXFont const last_font = running_font; - // Spaces at end of font change are simulated to be - // outside font change, i.e. we write "\textXX{text} " - // rather than "\textXX{text }". (Asger) - if (open_font && c == ' ' && i <= size() - 2) { - LyXFont const & next_font = getFont(bparams, i + 1, outerfont); - if (next_font != running_font && next_font != font) { - font = next_font; - } - } - // We end font definition before blanks if (open_font && (font != running_font || @@ -1081,7 +1071,17 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf, open_font = false; } - // Blanks are printed before start of fontswitch + // Do we need to change font? + if ((font != running_font || + font.language() != running_font.language()) && + i != body_pos - 1) + { + column += font.latexWriteStartChanges( + os, basefont, last_font, bparams); + running_font = font; + open_font = true; + } + if (c == ' ') { // Do not print the separation of the optional argument if (i != body_pos - 1) { diff --git a/src/text.C b/src/text.C index d30bdeb20f..60347f7407 100644 --- a/src/text.C +++ b/src/text.C @@ -57,7 +57,6 @@ #include "insets/insettext.h" #include "insets/insetbibitem.h" #include "insets/insethfill.h" -#include "insets/insetlatexaccent.h" #include "insets/insetline.h" #include "insets/insetnewline.h" #include "insets/insetpagebreak.h" @@ -239,10 +238,6 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex, par.insertInset(par.size(), inset.release(), font, change); } - } else if (token == "\\i") { - auto_ptr inset(new InsetLatexAccent); - inset->read(buf, lex); - par.insertInset(par.size(), inset.release(), font, change); } else if (token == "\\backslash") { par.insertChar(par.size(), '\\', font, change); } else if (token == "\\newline") { diff --git a/src/trans_mgr.C b/src/trans_mgr.C index b02a9eba4f..d3fb833abc 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -22,8 +22,6 @@ #include "lyxtext.h" #include "trans.h" -#include "insets/insetlatexaccent.h" - #include "support/lstrings.h" @@ -287,14 +285,7 @@ void TransManager::insert(string const & str, LyXText * text, LCursor & cur) if (chset_.getName() != lyxrc.font_norm || !enc.first) { // Could not find an encoding - InsetLatexAccent ins(str); - if (ins.canDisplay()) { - cap::replaceSelection(cur); - cur.insert(new InsetLatexAccent(ins)); - cur.posRight(); - } else { - insertVerbatim(str, text, cur); - } + insertVerbatim(str, text, cur); return; } string const tmp(1, static_cast(enc.second));