PDA

View Full Version : Getting OpenType support missing for script OUTPUT



techfreak
6th May 2015, 10:20
I have a simple QlineEdit on my UI. It allows me to enter Hindi language characters (copy from google translator and paste) - (जॉन) 11161

But when I change any of the style using stylesheet, for e.g. color changed to red. Now if I paste the same hindi language text (जॉन) it show cubes (boxes) in place of characters and I get output message "OpenType support missing for script"

Also I tried this using two edit boxes with one of it having color defined in style sheet, I see boxes on other edit box as well (even though I haven't touched its style at all)

There is no code required, just create hello world program, in designer add a editbox, defined 1 or more style e.g. color in stylesheet and try paste HINDI language characters "जॉन"

Could anyone help me on this.

techfreak
14th May 2015, 13:08
QStringList fileList;
fileList<<"akshar.ttf"<<"DroidSansDevanagari-Regular.ttf"<<"aparaj.ttf";
fileList<<"chandas.ttf"<<"mangal.ttf"<<"Kruti_Dev_010.ttf";

QStringList::const_iterator constIterator;
for (constIterator = fileList.constBegin(); constIterator != fileList.constEnd(); ++constIterator)
{
QFile res(":/new/prefix1/" + *constIterator);

if (res.open(QIODevice::ReadOnly))
{
if (QFontDatabase::addApplicationFontFromData(res.rea dAll()) != -1) {
qDebug()<<"successfully loaded font " + *constIterator;
}
else
{
qDebug()<<"failed to load font " + *constIterator;
}
}
else
{
QString errMsg;
errMsg = res.errorString();
qDebug()<<"font file open failed : = " + errMsg ;
}
res.close();

QFont font;
font.setFamily("akshar");
QApplication::setFont(font);
// QTextCodec::setCodecForLocale(QTextCodec::codecFor Name("UTF-8"));
}

ui->lineEdit->setFont(QFont("akshar", 10));
ui->lineEdit->setFont(QFont("mangal", 10));
ui->lineEdit->setText(QObject::tr("जॉन"));
ui->lineEdit->hide();
}

This doesnt seem good solution, but for here through some trial and error. I am loading fonts (which to my knowledge Qt already supports) as with hello world program it works well until I add one button to UI.

What I am doing now ? I am creating lineedit, setting font for it, and then setting a HINDI test on it. Then hide this LineEdit as I dont need it.

Because of doing all I mentioned above now my UI allows me to paste different language text on to other line edits on same UI screen - see attachment.

What I discovered seems stupid solution but without this line edit will show boxes for hindi text. I tested difference between my working hello world and non working hello world program using version control there is no difference in code, so somehow QT tool runtime forgets HINDI suddenly and then never understands it. But my work around make UI to understand HINDI and allied languages.