- ucs4_to_qchar() and qchar_to_ucs4() have been inlined.
- ucs4_to_qstring(): pass a QString to avoid a copy.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15266
a592a061-630c-0410-9148-
cb99ea01b6c8
if (!lyx_gui::use_gui)
return ls;
- QString ucs2 = ucs4_to_qstring(s, ls);
+ QString ucs2;
+ ucs4_to_qstring(s, ls, ucs2);
if (smallcaps_shape_)
return smallcapsWidth(ucs2);
encoding = encodings.symbol_encoding();
#endif
-#if 0
QString str;
- str.setLength(ls);
- for (unsigned int i = 0; i < ls; ++i)
- str[i] = QChar(encoding->ucs(s[i]));
-#else
- QString str = ucs4_to_qstring(s, ls);
-#endif
+ ucs4_to_qstring(s, ls, str);
#if 0
// HACK: QT3 refuses to show single compose characters
}
-QString const ucs4_to_qstring(char_type const * str, size_t ls)
+void ucs4_to_qstring(char_type const * str, size_t ls, QString & s)
{
- QString s;
s.reserve(ls);
for (size_t i = 0; i < ls; ++i)
s.append(ucs4_to_qchar(str[i]));
-
- return s;
}
}
-char_type const qchar_to_ucs4(QChar const & qchar)
-{
- return static_cast<lyx::char_type>(qchar.unicode());
-}
-
-
-QChar const ucs4_to_qchar(char_type const & ucs4)
-{
- return QChar(static_cast<unsigned short>(ucs4));
-}
-
-
QString const qt_(char const * str)
{
return toqstr(_(str));
#include "support/docstring.h"
+#include <QChar>
+
#include <vector>
class LengthCombo;
class QComboBox;
class QLineEdit;
class QString;
-class QChar;
std::string makeFontName(std::string const & family, std::string const & foundry);
*/
QString const toqstr(lyx::docstring const & ucs4);
-QString const ucs4_to_qstring(lyx::char_type const * str, size_t ls);
+void ucs4_to_qstring(lyx::char_type const * str, size_t ls, QString & s);
lyx::docstring const qstring_to_ucs4(QString const & qstr);
void qstring_to_ucs4(QString const & qstr, std::vector<lyx::char_type> & ucs4);
-lyx::char_type const qchar_to_ucs4(QChar const & qchar);
-
-QChar const ucs4_to_qchar(lyx::char_type const & ucs4);
+inline lyx::char_type const qchar_to_ucs4(QChar const & qchar) {
+ return static_cast<lyx::char_type>(qchar.unicode());
+}
+inline QChar const ucs4_to_qchar(lyx::char_type const ucs4) {
+ return QChar(static_cast<unsigned short>(ucs4));
+}
/**
* qt_ - i18nize string and convert to unicode