If you enter accents via the kmap mechanism they will not produce a single
precomposed character (e.g. é), but a combining pair (e.g. e + '). IMHO we
should use the precomposed form if it does exist. The attached patch
implements that, and also converts to precomposed form when reading from a
file and copying from the clipboard/selection.
OK to go in?
Georg
Index: src/lyx_cb.C
===================================================================
--- src/lyx_cb.C (Revision 17672)
+++ src/lyx_cb.C (Arbeitskopie)
@@ -327,7 +327,8 @@ void insertPlaintextFile(BufferView * bv
return;
// FIXME: We don't know the encoding of the file
- docstring const tmpstr = from_utf8(getContentsOfPlaintextFile(bv, f, asParagraph));
+ docstring const tmpstr = normalize_kc(from_utf8(
+ getContentsOfPlaintextFile(bv, f, asParagraph)));
if (tmpstr.empty())
return;
Index: src/frontends/qt4/GuiSelection.C
===================================================================
--- src/frontends/qt4/GuiSelection.C (Revision 17672)
+++ src/frontends/qt4/GuiSelection.C (Arbeitskopie)
@@ -58,7 +58,8 @@ void GuiSelection::haveSelection(bool ow
docstring const GuiSelection::get() const
{
- QString const str = qApp->clipboard()->text(QClipboard::Selection);
+ QString const str = qApp->clipboard()->text(QClipboard::Selection)
+ .normalized(QString::NormalizationForm_KC);
lyxerr[Debug::ACTION] << "GuiSelection::get: " << fromqstr(str)
<< endl;
if (str.isNull())
Index: src/frontends/qt4/GuiClipboard.C
===================================================================
--- src/frontends/qt4/GuiClipboard.C (Revision 17672)
+++ src/frontends/qt4/GuiClipboard.C (Arbeitskopie)
@@ -67,7 +67,8 @@ string const GuiClipboard::getAsLyX() co
docstring const GuiClipboard::getAsText() const
{
// text data from other applications
- QString const str = qApp->clipboard()->text(QClipboard::Clipboard);
+ QString const str = qApp->clipboard()->text(QClipboard::Clipboard)
+ .normalized(QString::NormalizationForm_KC);
if (lyxerr.debugging(Debug::ACTION))
lyxerr[Debug::ACTION] << "GuiClipboard::getAsText(): `"
<< fromqstr(str) << "'" << endl;
Index: src/support/docstring.C
===================================================================
--- src/support/docstring.C (Revision 17672)
+++ src/support/docstring.C (Arbeitskopie)
@@ -140,6 +140,12 @@ std::string const to_filesystem8bit(docs
}
+docstring const normalize_kc(docstring const & s)
+{
+ return qstring_to_ucs4(toqstr(s).normalized(QString::NormalizationForm_KC));
+}
+
+
bool operator==(lyx::docstring const & l, char const * r)
{
int const len = l.length();
Index: src/support/docstring.h
===================================================================
--- src/support/docstring.h (Revision 17672)
+++ src/support/docstring.h (Arbeitskopie)
@@ -62,6 +62,9 @@ docstring const from_filesystem8bit(std:
/// convert \p s from ucs4 to the encoding of the file system.
std::string const to_filesystem8bit(docstring const & s);
+/// normalize \p s to precomposed form kc
+docstring const normalize_kc(docstring const & s);
+
/// Compare a docstring with a C string of ASCII characters
bool operator==(lyx::docstring const &, char const *);
Index: src/tex-accent.C
===================================================================
--- src/tex-accent.C (Revision 17672)
+++ src/tex-accent.C (Arbeitskopie)
@@ -103,8 +103,7 @@ docstring const DoAccent(docstring const
<< lyx_accent_table[accent].name << '.' << std::endl;
os << s.substr(1);
}
- // FIXME: We should normalize the result to precomposed form
- return os.str();
+ return normalize_kc(os.str());
}