Width QT and fonts

Please help me understand the irregularity in the width of the characters.

Copy the following code:

  QFontMetrics fm(font());
  double x=fm.width("A");
  qDebug()<< "Width of A is " << x;
  x=fm.width("AA");
  qDebug()<< "Width of AA is " << x;
  x=fm.width("AAA");
  qDebug()<< "Width of AAA is " << x;
  x=fm.width("AAAA");
  qDebug()<< "Width of AAAA is " << x;

produced these results:

A width is 11

The AA width is 23

Width of AAA is 34

Width of AAAA is 46

Thank you.

and you can try to use QFont::Monospace or QFont::Courier/QFont::TypeWriter

UPD: QFont::ForceIntegerMetrics 0x0400 imposes the use of integer values in the font engines that support measures fractional fonts. -It may be a choice with your current policy

upd2: QFont enum:tyleStrategy can also affect (bad - smile is QFont: StyleStrategy without spaces)

Tags: BlackBerry Developers

Similar Questions

  • Get the width of a font

    I'm writing my own custom TextBox that has a border and resizes based on the font size.  i.e. the constructor would pull a numberOfCharaters parameter and it will determine its preferred width using the font size.  This works great in height:

    public int getPreferredHeight() {
            return _editField.getFont().getHeight();
    }
    

    However, I don't know how to calculate the width.  I would like to do something like this:

    public int getPreferredWidth() {
            return editField.getFont().getWidth() * _numberOfCharaters;
    }
    

    But all I see is getAdvance, but I don't know what the characters are going to type in the first text box.

    Any ideas?  Thank you.

    Aren't asking you the impossible?  If you have a proportional font, there is no direct relationship between the number of characters and the width they need - because it is based on the actual characters.

    I am not convinced that you can set the way that you either - what happens if the text requires more than one line in height?

    You might find useful the following Thread:

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=10901&query.ID=21...

  • SVG and fonts

    I am my head should be converted to a .svg because it's horrible revised downward in Internet Explorer.

    There are fonts in the .svg but I installed via dreamweaver fonts and fonts work fine elsewhere.

    Have a look HERE. (you need to reduce the browser for 1000px width below to see) You can see 'prayer pond"written in the body with the correct font, but the header doesn't have the right font. For the life of me I can't understand why. I'll have to edit the svg in a txt editor because if I try to change anything in the svg with dreamweaver image turns off completely (even if I cancel editing and resaving it). You can also see other fonts in svg works very well and I installed it exactly the same way.

    Here is the part of the .svg which deals with the police:

    < text transformation = "matrix (0.808 0 0 1 221,228 97.4204)" fill = "#B4D1E4" of the race = "#B4D1E4" police family = the size of the font "" ConeriaScript_Slanted"" = "83.2657" > prayer < / text > "

    < text transformation = "matrix (0.808 0 0 1 517,98 96.3726)" fill = "#B4D1E4" of the race = "#B4D1E4" police family = the size of the font "" ConeriaScript_Slanted"" = "83.2657" > pond < / text > "

    And here's the CSS of the lowest text with the same font (which works):

    . Temp {}

    do-family: 'ConeriaScript_Slanted ';

    font size: xx-large.

    color: #FFF;

    }

    Ah, looks like you forgot to link to it in the SVG itself...

    On the svg fonts | Divya Manian

  • All my configuration page and fonts have changed suddenly, how to restore the previous settings. THX

    All my configuration page and fonts have changed suddenly, how to restore the previous settings. THX

    Hi André Haub,

    Follow the steps in this document to perform a system restore. This process restores your system to a previous point files.

  • Size of the graphics and fonts

    I just bought a laptop Pavilion g7 with Windows 8. I don't know what I hit, but the graphics and fonts have increased in size. How can I put them back to normal?

    H,

    Please try this first: press and hold the Ctrl key and then hit - (less) several times.

    Kind regards.

  • My icons and fonts are great for my screen

    my icons and fonts are big for my screen. In addition, they are everywhere. I tried to make them smaller and not luck.

    Hello

    ·         You will remember to do recent changes on the computer before this problem?

    ·         When there is change on the computer?

    ·         Change is specific to one program, Internet Explorer, or sometimes on the desktop as well?

    I suggest that you follow the steps described in the links:

    http://Windows.Microsoft.com/en-us/Windows-Vista/show-hide-or-resize-desktop-icons

    http://Windows.Microsoft.com/en-us/Windows-Vista/change-Windows-fonts

    http://Windows.Microsoft.com/en-us/Windows-Vista/the-desktop-overview

    Also, follow the steps in the link:

    http://Windows.Microsoft.com/en-us/Windows-Vista/change-screen-resolution

  • Too large on the desktop icons and fonts

    When I started my computer, my icons and fonts have been very large.  I don't know what happened, but I need a way to solve this problem.  It drives me crazy.  I can see everything on my screen.  Thank you for your quick help.

    Hello

    Try the system restore before what happened:

    How to make a Vista system restore
    http://www.Vistax64.com/tutorials/76905-System-Restore-how.html
    I hope this helps.

    Rob - bicycle - Mark Twain said it is good.

  • How to change the fonts and font size in sticky notes

    Original title: reminder

    How can I change the font and font size in sticky notes?

    Hi Jerry,

    Thanks for posting the question in the Microsoft Community!

    See the article to format the text in a sticky note in the site:

    Use reminders

    http://Windows.Microsoft.com/en-us/Windows7/using-sticky-notes

    If the problem persists, or in the future if you face problems of Windows let us know and we would be happy to help you.

  • I want to develop an application Live TV for BlackBerry PlayBook. Please guide where can I find the specifications such as width, height, and icon sizes and design factors etc.

    I want to develop an application Live TV for BlackBerry PlayBook. Please guide where can I find the specifications such as width, height, and icon sizes and design factors etc.

    Guideleines of the user and the specifications on the sizes of icons etc to BlackBerry PlayBook OS Applications

    OK, I downloaed the pdf below for UI guiderlines

    UI_Guidelines_BlackBerry_PlayBook_Tablet_2_1.PDF

    Ok

  • Support of blackBerry Smartphones uninstalling far East characters and fonts

    Hello

    I want to uninstall"character Support and fonts of the far East", as it is the consumption of storage space. So if I uninstall it will it create any problem? Can anyone help meon this?

    Thanks for the help!

    Hi jigar2011,

    You should have no problem of uninstalling all the languages not used your BlackBerry. You can do this by opening your configuration icon and clicking the language icon. Under manage languages, uncheck all the languages that you want to uninstall.

    I hope this helps.

  • change font and font size in all text fields

    Hi, I want to change font and font size in all text fields. I tried under the code, but it changes the font size but has not changed the font. can u pls help me. Thank you...

    Police - Courier New

    the size of the font - 10

    Loop through the fields in the document

    for (var i = 0; i < numFields; i ++) {}

    Get a reference to the current field

    var f = getField (getNthFieldName (i));

    Change the properties of certain types of fields

    {Switch (f.type)}

    case 'text ':

    f.textFont = fonts. Courier New;

    f.textSize = 10;

    }

    }

    You have a good reason to want to use Courier New instead of the built-in Courier font? In all cases, you must change one line to:

    Use the built-in font Courier

    f.textFont = fonts. Court;

    -or-

    Use the Courier New

    f.textFont = "CourierNew;

  • Since I did the update, my master pages don't parpadean more good, there are texts that disappear and fonts which are not well displayed. It worked before. Can you help me?

    Since I did the update, my master pages don't parpadean more good, there are texts that disappear and fonts which are not well displayed. It worked before. Can you help me?

    Yes, thanks it works!

  • Major problem. Synchronization of files and fonts does not!

    We are in the middle of a production of big book of 250 pages and files are not in the CC Panel.

    I deleted the content of OOBE and downloaded the latest CC app on my iMac.

    Problem just started yesterday. (I think)

    I found a solution to my problem of synchronization in the iMac

    In the Library/Preferences/com.adobe.accmac.plist, rename or delete this file.

    I got an instant response and synchronization of files and fonts works. But there is no checkmark in the synchronized files folder, but I can live with that.

    Best regards

    Lasse Martinell

  • Something has changed on my account and now my vector elements and fonts look pixelated in CS6

    Today an illustrator file with vector objects and fonts that I worked on the days looked pixelated when enlargement to more than 400%. I could not find the fix so I have started a new canvas, selected all my pixelated, pasted into a new canvas and all transferred file properly so I could continue to work with my vector elements again.  I was curious to know if anyone knows what does my vector elements change in pixel and how to fix it.  Thank you guys

    View > preview pixelated

    Turn that if necessary there is no tick before preview pixelated

  • Links and fonts in Genereated fixed provision EPUB MOBI files

    I have a fixed provision created in ID CC2014 epub that works as expected. The use of kindlegen to create my mobi file. Hyperlinks in text do not work (image links work very well) and @font-face statement does not work.

    The tags are displayed as I expect when I unzip the epub and review the code. I tried to make it simple ID link and edit the code. None worked. I can ad a link tag to an image in the .xhtml file that works as expected. A button hides the text and does not work as well. Is a hyperlink, a known issue with ID EPUB going mobi?

    There is a @font-face in the css file and a folder of fonts containing the fonts there. Is this a known issue with ID EPUB going mobi?

    Steve, thanks for the input it was useful.

    After a few days to dissect the xhtml and the css generated from the ID, I was able to find a solution by adding TT fonts in the @font face and remove the kit web css for related words. If somebody needs specific information about the workflow, message me and I'll be happy to share.

Maybe you are looking for

  • Firefox Sync will not stay connected.

    Whenever I open Firefox, it I set up my account to sync again by typing my username and password sync key. I was under the impression that the sync account could stay connected. Anyone else know of this problem and how to fix?

  • Windows permissons

    Hi I have a problem with my LV App being able to write to a directory which can be set to read-only.  Is it possible to check and if so, change the permissions of this directory of Labview?

  • Quick Viewer problem

    My wife runs a program of Embird embroidery. While trying to work with a design, a quick Viewer window opens and locks work. The only way out is to restart the computer. Is there a way to turn off or disable quick view? Thanks for any input.

  • Excel 2003

    Excel 2003 - why is there a broken line on the right side of my first article, and why this column print when I print the entire document?

  • The instruction at 0x00000000. at the stop

    I started to receive the generic "education to mem Ref 0 x 00000000 0 00000000..." to stop or restarts in the last month or so.  Except that it does not seem to have an effect on the system. By restoring the system to 15 June, the message disappears.