[Solved] Problems getting the correct width of BOLD text from QFontMetrics
-
I am using Qt5.2.0 on Windows and Mac OSX 10.9.1 (Mavericks).
I want to get the width of any given string of Bold text in any given font. I have Tried both QFontMetrics and QFontMetricsF. I have tried set the height of the font in points and pixels.
I have tried all variation of these functions:
width()
boundingRect()
tightBoundingRect()
size()However they all give a width that is shorter than the actual displayed width of the text when BOLD text or BOLD italic text is used. This works OK for normal text and normal italic text in the fonts I have tried so far.
I have seen many past posts relating to various problems with the getting the correct width of text but I cannot glean the status of the current version in this respect.
Like, is it all supposed to be working now???
Or, has BOLD text just been forgotten in all the bug fixing work over the years???Can any on please offer me some advice about this issue.
My thanks to all who offer help.
-
Hi,
Are you getting errors for every font ? Or only specific ones ? On both platforms ?
Did you check the "bug report system":http://bugreports.qt-project.org to see if there already something talking about it ?
-
Hello again SGaist, thank you for your interest in my post.
Actually I am working with a legacy application that was originally using the Windows api for text and it does its text thing in a rather complex way.
I did some tests with a simple app and found that I actually can get a reasonable box using those function. Once one understands the meaning of the various font metrics...
So my conclusion is now that the legacy app is messing things up somehow.
I have no time to test this on all fonts but I am very pleased to know that Qt is doing the font stuff right.
Many thanks to all concerned.