In TextEdit, is there a way to get the width or height of a string?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By KramchayDig

I already know how to get the length of a string which only counts the number of the characters but I’m fascinated that I can’t find any basic method in getting the width or height of a string by pixels. Has anyone able to find its method?

:bust_in_silhouette: Reply From: Sogeking

Width and height of your string depends on your font and its size.
I guess you could fit your text in a Label and check its Rect size.

Other than that I don’t know either. Hope that helps.