PDA

View Full Version : Fixing ugly rotated text



fate
4th September 2015, 00:00
I've seen a few threads on displaying rotated text in the past. I'm working on some proof of concept code and would like to draw text, rotated, with a halo effect on a QPainter. The end goal is to display this over GL rendered scene.

The function calls and translations all work right, but the end result is... well, ugly. I'm seeing serious kerning issues, and 'floating' letters as I apply the rotation. I've done a lot of googling trying to find a better solution here, and was curious if anyone had seen and/or found a way to make this look decent. A few fonts look slightly better, but the general case is as seen in the attached images.

I've tried setting random text hints, as well as converting the text to a path then rendering that. So far, the best option I've found is to create a QImage, render the text to the QImage, then blit the rotated QImage. But, this really seems like I'm doing something wrong...

Is there a recommended way to draw text like this?

Edit: This is Win7 with Qt 5.3.2, font in picture is Calibri (I believe).

kangaba
6th September 2015, 21:31
I would draw the text to an image, make a texture out of this, and then rotate the texture.

fate
8th September 2015, 21:02
I ended up keeping the texture approach.

I create a single QImage texture large enough to fit max string lenght, then draw/clear for all text I'm displaying. With smoothing turned on, it's not overly slow, and gives a fairly decent visual.