Alex
Alex

Reputation: 159

Qt-Embedded multiple font

My system:

I am trying to mix Latin alphabets with other types of characters e.g. Japanese. I have fonts for Latin alphabets and Japanese characters but they are not the same font. I have studied the posts:

Qt Use Multiple Fonts at the Same Time and how-to-properly-output-multilingual-text-in-qt-embedded

I follow the steps but I can't show correctly all the characters

Is there any way to indicate that if you can not display a character font change?

The code:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtGui>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QString chino = QString::fromUtf8("你好");
QString ruso = QString::fromUtf8("здравствуйт");
QString arabe = QString::fromUtf8("سلام عليك");
QString japones = QString::fromUtf8("今日は");
QString otros = QString::fromUtf8("안녕하세요");
QString mezcla = QString::fromUtf8("今a日sはздdр你عل세요");
QString indu = QString::fromUtf8("Γεια σας,안녕하세요,ज्वजलपा");
ui->textochino->setText(chino);
ui->textoruso->setText(ruso);
ui->textoarabe->setText(arabe);
ui->textojapones->setText(japones);
ui->texto1->setText(mezcla);
ui->texto2->setText(indu);
}

MainWindow::~MainWindow()
{
delete ui;
}

Upvotes: 0

Views: 1346

Answers (1)

Alex
Alex

Reputation: 159

For select a list Font alternatives we can use insertSubstitutions. For example:

QStringList listFonts;
listFonts <<"Verdana" <<"Droid Sans" <<"Lucida Sans" ;
QFont font("Sans");
font.insertSubstitutions("Sans",listFonts);
font.setStyleStrategy(QFont::PreferAntialias);
ui->mix->setFont(font);

Upvotes: 7

Related Questions