Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to check if font do support characters (codepoints?)

How to check if font do support characters (codepoints?)

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 637 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    buhtz
    wrote on last edited by buhtz
    #1

    I would like to know if the currently selected font do support a specific character (or string) or if it just renders it with the rectangle-characters like this □□□□□.

    Can I check this somehow on the fly while my PyQt5 application is running?

    label = QLabel('string to check')
    label.rendered?

    Or "asking" the font:
    label.font.codepoints_available('string to check')

    1 Reply Last reply
    0
    • KH-219DesignK Offline
      KH-219DesignK Offline
      KH-219Design
      wrote on last edited by
      #2

      Caveats: On a day-to-day basis I work in C++ and rarely in python. Furthermore, I have not attempted any of what I am sharing here.

      However, it seems that using the lower-level C libraries like libfreetype and/or harfbuzz, this is possible. So it seems likely to me that someone has created a python wrapper of some kind that would expose it in python.

      Apparently (in C), the libfreetype function FT_Get_Char_Index will return 0 if the desired glyph does not exist in a given font:

      http://refspecs.linux-foundation.org/freetype/freetype-doc-2.1.10/docs/reference/ft2-base_interface.html#FT_Get_Char_Index

      And here is an example of someone using pyharfbuzz in a similar way:

      https://askubuntu.com/a/1186237/231504

      www.219design.com
      Software | Electrical | Mechanical | Product Design

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved