[Solved]Support for japanese language in qt in an ARM environment
-
Hi,
Myself a beginner in qt.I am trying to support japanese font(katakana) in qt using ttf file. I am inputting unicode and getting the japanese font out. I tried giving some unicode /0x30A1 as input(the unicode for katakana letter http://www.charbase.com/images/glyph/12449 ) which is small letter a in katakana.But what i get was some arbitrary japanese letter to each digit in the unicode...instead of the appropriate single unicode letter.
@
#include <QtGui>int main(int argc, char** argv)
{
QApplication app(argc, argv);
QFile fontFile("katakana.ttf");
if (!fontFile.open(QIODevice::ReadOnly)) {
qCritical() << "failed to open font file";
}
QByteArray fontData = fontFile.readAll();// Register font to the QFontDatabase / if (QFontDatabase::addApplicationFontFromData(fontData) == -1) { qCritical() << "failed to add a font"; } // Create font object and verify font family QFont font3("Katakana", 25, QFont::Bold, true); QFontInfo fontInfo3(font3); qDebug() << "Expected:" << font3.family() << "Real:" << fontInfo3.family(); // Produce GUI which uses loaded font
char strarry[22]={'0xE382A1','0xE382A2','0xE382A3','0xE382A4'};
strarry[4]='0xE38385';
strarry[5]='0xE38380';
strarry[6]='0xE382A2';QLabel label3;
label3.setText(QString::fromUtf8(strarry));
label3.setFont(font3); label3.show(); return app.exec();
}
@what is the correct way to input unicode of katakana ??
Please help... -
I can input katakana using below code.
@char strarry[] = "\xE3\x82\xA1\xE3\x82\xA2\xE3\x82\xA3\xE3\x82\xA4";@
You can use QChar(int).
ex.
@QString text = QString::fromUtf8(strarry);
text += QChar(0x3042);@ -
Hi takumiasaki
Thanks for your responseI tried the same in my code .But i am getting output as rectangles(parallelogram).What might have went wrong??
I also have a doubt regarding the code snippet,
text += QChar(0x3042);
What is the significance of this...Plz help....