mapeditor/tiled

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Add support for fractional pixel font sizes in text shapes #3304

DanielFlaum posted onGitHub

Is your feature request related to a problem? Please describe. Text shapes can only use integer values of pixels for text sizes. This makes fine-tuning text sizes impossible.

image

Describe the solution you'd like Enable text shapes to use fractional font sizes.

Describe alternatives you've considered Sometimes this can be worked around by using a larger size for tiles, but depending on the application this isn't always possible.


I've used "pixel size" for fonts because I wanted the size of the text to be consistent in relationship to the graphics, as opposed to "point size", which could lead to various sizes depending on the current DPI. And unfortunately, QFont::setPixelSize only works with integers, so setting a fractional size in pixels is not possible.

What could probably be done is to allow fractional values in pixels in the font settings, but convert them internally to a point size, taking into account the current DPI.

posted by bjorn about 3 years ago

I don't know how good Qt is with this, but some font renderers do a poor job when using pixel art fonts and point sizes, due to rounding issues. Say you want to use a font at 11px, and internally this gets converted to 14.666... points (except of course, rounded since it's contained in some float) at 96dpi. When this point size gets converted back to pixels for rendering, you might end up with something like 10.96px, and slightly blurred rendering. With hinted fonts this is usually not a problem, but not all fonts have hinting, and not all font renderers use it.

So, if implementing this, please test it with some pixel art fonts (especially vector ones, but I can see this being an issue for bitmap fonts too) that are intended to be used at specific pixel sizes. Alternatively, set the font size in points only when the user's input has a decimal component, and use setPixelSize otherwise, to avoid any conversions and the associated risks.

posted by eishiya about 3 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests