Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:13:52+00:00 2026-06-10T00:13:52+00:00

I need to display several international scripts within a same string in a QLabel.

  • 0

I need to display several international scripts within a same string in a QLabel.

For instance the QLabel could display:

چاچي चाची ćāćī (dim. of ćāćā, q.v.), s.f. A paternal aunt (=ćaćī, q.v.)

The above string includes Latin script, Perso-Arabic script and Devanāgarī script (which belongs to he family of Indic scripts).

Each script requires different font families and sizes. For instance, the first word in the string is Urdu, and requires a font that is able to display ے. Moreover, I may want to use a certain type of calligraphy (Urdu traditionally uses “Nastaleeq” script). Besides, calligraphies may require an increases in font size to be readable (not all scripts fall into regular square shapes like Mandarin pictograms, if you have little idea of the diversity of international scripts, take a look at Omniglot.) In conclusion I want each script to be displayed with a particular font and size.

Currently I feed the QLabel with a complex HTML string which I compose bit by bit by specifying the font and size to use for specific sections of the string.

<font family="SomeFamilyforUrdu" size="10>اردو</font> <font family="SomeFamilyforDevanagari" size="8">हिन्दी</font> <font family="FontforLatin" size=5>English</font>

Qt4 also offers QLabel.setFont(QFont), but so far I did not see any means to specify font families and sizes according to script families.

Is it possible to set conditions to the QFont so it applies different families and sizes depending on the script it paints into the QLabel?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:13:53+00:00Added an answer on June 10, 2026 at 12:13 am

    The QFontDatabase.families() function returns a list of fonts that support a specific Writing System.

    EDIT

    Fundamentally, your question seems to be about unicode and it’s support for assignment of script names to unicode code points. Theoretically, Qt could use the unicode database to determine the script of each text character that it renders and potentially use that information to apply a different format to it.

    However, there doesn’t appear to be any obvious APIs providing support for this.

    For instance, it would seem plausible that the QChar class might have an enum for unicode script names and a scriptName function that would return the appropriate value from it for a particular unicode character. But there’s no such thing in either Qt4 or Qt5.

    So I’m going stick my neck out here, and guess that html/css is the only way to achieve what you want at this point in time.

    UPDATE

    It seems that python’s unicodedata module doesn’t have support for script names either.

    However, this answer provides a workaround to that which could potentially allow a home-grown solution to be developed.

    Here’s a demo script which auto-generates html for a QLabel using the unicodedata2 module from the answer above:

    # -*- coding: utf8 -*-
    
    import unicodedata2
    from itertools import groupby
    from PyQt4 import QtGui, QtCore
    
    text = (u'چاچي चाची ćāćī (dim. of ćāćā, q.v.), '
            u's.f. A paternal aunt (=ćaćī, q.v.)')
    
    markup = [
    """
    <html>
    <style type="text/css">
    body {font-family: Sans Serif; font-size: 8pt}
    span.arabic {font-family: ClearlyU Arabic; font-size: 18pt}
    span.devanagari {font-family: ClearlyU Devanagari; font-size: 12pt}
    </style>
    <body>
    """
    ]
    
    for script, group in groupby(text, unicodedata2.script):
        script = script.lower()
        chunk = ''.join(group)
        if script == 'common' or script == 'latin':
            markup.append(chunk)
        else:
            markup.append('<span class="%s">%s</span>' % (script, chunk))
    
    markup.append(
    """
    </body>
    </html>
    """
    )
    
    class Window(QtGui.QWidget):
        def __init__(self):
            QtGui.QWidget.__init__(self)
            self.label = QtGui.QLabel(self)
            layout = QtGui.QVBoxLayout(self)
            layout.addWidget(self.label)
            self.label.setText(''.join(markup))
    
    if __name__ == '__main__':
    
        import sys
        app = QtGui.QApplication(sys.argv)
        window = Window()
        window.show()
        sys.exit(app.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the QT application we develop we need to display several 'Viewer windows' (to
For an app that I am writing I need to display several views (in
I have several places where I need to display an alert and handle the
I need to display a table in rich text within a form window. It
I need to create and display several multiple choices dialogs. Those are dialogs with
I need to display a google map with several markers. The problem I have
I need to display several graphs which have a common X Axis and a
I need to display several models name & objects in a template Here is
I'm positioning a VideoView with AbsoluteLayout (I need to display it on several places
I have several tables from which I need to display data. Schools ------- id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.