PDA

View Full Version : Load multi language fonts at the same time



lllturtle
30th March 2012, 02:51
Hi guys,
i want to show multi languages(English, HEBREW, Thai, ARABIC, Chinese) as a selection list,
i find something about insert substitution

void QFont::insertSubstitution ( const QString & familyName, const QString & substituteName )
and
void QFont::insertSubstitutions ( const QString & familyName, const QStringList & substituteNames )

but failed , below is my code of loading fonts
first , i'm using the debug message to show the support family, i don't know if this is a proper way to find the support font,
please correct me if it's a wrong solution

/* output the support font */
QFontDatabase qfd ;
qDebug() << qfd.families(QFontDatabase::Hebrew);
qDebug() << qfd.families(QFontDatabase::Arabic);
qDebug() << qfd.families(QFontDatabase::Thai);
qDebug() << qfd.families(QFontDatabase::TraditionalChinese);

after get the debug message , i'm using tool "makeqpf" to create qpf2 files such as
wenquanyi_micro_hei(for chinese), sans_serif(for HEBREW, ARABIC), waree(for Thai)
and i need to load all of them to show the correct words, but failed

In this way, i can show the chinese, english, hebrew, arabic but not thai,


QFont font1("WenQuanYi Micro Hei [prerendered]",14,50,FALSE);
subs << "DejaVu Sans [prerendered]" << "Waree" ;
font1.insertSubstitutions("WenQuanYi Micro Hei [prerendered]", subs);
qApp->setFont(font1);

qDebug() << font1.family() ;
QStringList sl = font1.substitutions() ;
qDebug() << sl.isEmpty() ;
qDebug() << sl ;
qDebug() << font1.substitutes("WenQuanYi Micro Hei [prerendered]") ;

and i just make another test to change the font family


QFont font1("DejaVu Sans [prerendered]",14,50,FALSE);
subs << "WenQuanYi Micro Hei [prerendered]" << "Waree" ;
font1.insertSubstitutions("DejaVu Sans [prerendered]", subs);
qApp->setFont(font1);
if i insert "DejaVu Sans" first, when i open the multi language page,
the program crashed, i guess it's because the program can't show chinese and crashed,
i just can't figure it out why this happened ,
in my eyes , that two ways above was almost the same, can anyone explain for me?

and the final goal is to show all the language at the same time
so i need load waree and show it correctly, please help
thanks

lllturtle
12th April 2012, 08:20
hello~ guys ,
is there someone who know this issue ?
i've also tried to read the "Thai" font "Waree" like below

QFont font1("Waree",14,50,FALSE);
in this way, i can see the "Thai" font in my program,
but the others disappear, (Hebrew, Arabic, Traditional Chinese) all remain in blank
please help !

any reply will be appreciated!!