[solved] how to set local fonts



  • hi all,
    how to set local fonts. I am trying with this code. this is working for english but not for “lohit tamil”.

       @ ui->label1->setStyleSheet ("font: 40pt \"Lohit Tamil\";");
            ui->label1->setText("சென்னை");
            //ui->label1->setText("tamil");
            ui->label1->show();@

  • Lifetime Qt Champion

    Hi,

    Is that fond known to the system ? If it's custom, did you register it with QFontDatabase ?



  • how to do it. I am not getting.

    [quote author="SGaist" date="1411588373"]Hi,

    Is that fond known to the system ? If it's custom, did you register it with QFontDatabase ?[/quote]


  • Moderators

    Hi,

    Check "QFontDatabase::addApplicationFont":http://qt-project.org/doc/qt-5/qfontdatabase.html#addApplicationFont.



  • I am new to Qt. I am not understanding. Please give me some guide.

    [quote author="p3c0" date="1411640348"]Hi,

    Check "QFontDatabase::addApplicationFont":http://qt-project.org/doc/qt-5/qfontdatabase.html#addApplicationFont.[/quote]


  • Moderators

    Do you have a .ttf file for your font ?
    Or have you made sure that the font is already available inside Qt ?



  • yes i checked tamit fonts (Lohit Tamil) available in qt.

    [quote author="p3c0" date="1411709461"]Do you have a .ttf file for your font ?
    Or have you made sure that the font is already available inside Qt ?[/quote]


  • Moderators

    What does this output ?
    @
    QFontDatabase d;
    foreach(QString fmly, d.families(QFontDatabase::Tamil))
    {
    qDebug() << fmly;
    }
    @



  • @QFontDatabase d;
    foreach(QString fmly, d.families(QFontDatabase::Tamil))
    {
    qDebug("சென்னை") << fmly;
    ui->label1->show();
    }@

    error:--
    /home/dev6/Desktop/animation-build-desktop-Qt_4_8_1_in_PATH__System__Release/../animation/dialog.cpp:43: error: no match for 'operator<<' in 'qDebug(((const char*)"\37777777740\37777777656\37777777632\37777777740\37777777657\37777777606\37777777740\37777777656\37777777651\37777777740\37777777657\37777777615\37777777740\37777777656\37777777651\37777777740\37777777657\37777777610")) << fmly'-

    [quote author="p3c0" date="1411714136"]What does this output ?
    @
    QFontDatabase d;
    foreach(QString fmly, d.families(QFontDatabase::Tamil))
    {
    qDebug() << fmly;
    }
    @[/quote]


  • Moderators

    No.. Just use as it is as shown earlier. It will just print a list of fonts available under Tamil Writingsystem.



  • @QFontDatabase label1;
    foreach(QString fmly, label1.families(QFontDatabase::Tamil))
    {
    //qDebug("சென்னை") << fmly;
    qDebug("சென்னை");
    ui->label1->show();
    }@

    no output. getting blank.

    bq. bq. bq. Application output:

    Starting /home/dev6/Desktop/animation-build-desktop-Qt_4_8_1_in_PATH__System__Release/animation...
    சென்னை
    சென்னை
    சென்னை
    சென்னை
    சென்னை
    சென்னை
    சென்னை
    சென்னை bq.

    [quote author="p3c0" date="1411714136"]What does this output ?
    @
    QFontDatabase d;
    foreach(QString fmly, d.families(QFontDatabase::Tamil))
    {
    qDebug() << fmly;
    }
    @[/quote]



  • okay i will try now



  • bq. 3 errors:

    /home/dev6/Desktop/animation-build-desktop-Qt_4_8_1_in_PATH__System__Release/../animation/dialog.cpp:43: error: invalid use of incomplete type 'struct QDebug'

    /usr/include/qt4/QtCore/qglobal.h:1764: error: forward declaration of 'struct QDebug'

    /usr/include/qt4/QtCore/qglobal.h:1767: warning: inline function 'QDebug qDebug()' used but never defined [enabled by default]

    [quote author="p3c0" date="1411717583"]No.. Just use as it is as shown earlier. It will just print a list of fonts available under Tamil Writingsystem.[/quote]


  • Moderators

    #include <QDebug>



  • Starting /home/dev6/Desktop/animation-build-desktop-Qt_4_8_1_in_PATH__System__Release/animation...
    "Lohit Tamil"
    "TAMu_Kadambri"
    "TAMu_Kalyani"
    "TAMu_Maduram"
    "TSCu_Comic"
    "TSCu_Paranar [macromedia]"
    "TSCu_Paranar [unknown]"
    "TSCu_Times"
    /home/dev6/Desktop/animation-build-desktop-Qt_4_8_1_in_PATH__System__Release/animation exited with code 0

    [quote author="p3c0" date="1411718354"]#include <QDebug>[/quote]



  • Now what i have to do



  • tamil fonts are available. now what i have to do. help me please


  • Moderators

    Try this:
    @
    ui->label->setText(QString::fromUtf8("சென்னை"));
    @



  • Yes i got it now :)
    Thank you somuch.. I dont have words.. thank you somuch.. thanks to you all.

    [quote author="p3c0" date="1411721384"]Try this:
    @
    ui->label->setText(QString::fromUtf8("சென்னை"));
    @[/quote]


  • Moderators

    That's fine :)
    Please mark the post as solved.
    Happy Coding...



  • okay.. :)

    Happy


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.