Results 1 to 6 of 6

Thread: qfont character count

  1. #1
    Join Date
    Jun 2014
    Posts
    20
    Thanks
    2

    Default qfont character count

    Hello,

    is it possible to know how many characters defined in a *.ttf file?
    i have a custom font *.ttf file after loading it to qfont, would like to know how can i get the total characters in this font.

    anyone ideas?

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: qfont character count

    Closest thing I see is QFontMetrics. It has QFontMetrics::inFont() method that you could perhaps use to iterate over characters you are interested in, but I don't see anything that actually returns the number of characters in a given font.

  3. #3
    Join Date
    Jun 2014
    Posts
    20
    Thanks
    2

    Default Re: qfont character count

    Hello @jthomps,

    that could be the last choice to do it... while if there are only around 100 characters in the font defined i need to iterate 0x0000 to 0xffff.
    I dont understand why there is no explicit way to do it while hints could be found in QFontEngine(not an explicit API im using Qt 4.8)

    Any better ideas?

  4. #4
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: qfont character count

    Quote Originally Posted by cic1988 View Post
    I dont understand why there is no explicit way to do it while hints could be found in QFontEngine(not an explicit API im using Qt 4.8)

    Any better ideas?
    Sorry, I don't have any other ideas and I didn't write/design any of the QFont* classes so I can't speculate why this functionality isn't provided.

    Perhaps you could use a separate thread to iterate over all of the 0x0000 through 0xFFFF possibilities and cache the results so you would have to do this only once for each font, etc.

    A quick google shows there are other font utilities that can do this, perhaps you could use QProcess to execute one of those utilities and consume the output to cache, etc.

    Good luck in your quest for a solution.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: qfont character count

    The function probably does not exist for the simple reason nobody saw a reason for needing such a thing or there is no simple measure of "number of characters". What are you trying to achieve? Ae you trying to measure the number of unicode code points coverable with the font, the number of discrete glyphs renderable with the font, or the number of glyph elements the font has to combine into final glyphs. For example, the font will render a glyph for code point 0x000E Shift Out or 0x000F Shift In but they will be the same glyph and probably not a useful character.

  6. #6
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: qfont character count

    @ChrisW67, you said it better than I could...

Similar Threads

  1. Replies: 2
    Last Post: 9th April 2013, 06:26
  2. Replies: 2
    Last Post: 8th April 2010, 16:16
  3. QFont and DPI
    By ArlexBee-871RBO in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2010, 14:31
  4. Character by Character (Unicode?) File Reading
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2009, 15:28
  5. How to read QStringList character by character
    By iamjayanth in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2009, 11:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.