Turn text rendering into a css property.
This MR is mostly about non-anti-aliased rendering. While a very minor feature in the grand scheme of things, it'll be useful to have this sorted for unit-tests purposes.
-
Turn Text Rendering into a CSS property: While SVG does accept it as an xml-attribute, it understands it as a presentation attribute, meaning it can be interpreted as a css property too. -
Make text rendering editable. -
Introduce resolution struct to allow snapping to nearest pixel. -
Use FT_LOAD_TARGET_MONO for optimize speed to get the most appropriate outlines for non-anti-aliased lines. - Handle snapping to nearest pixel:
-
Baseline alignment -
basic layout box. -
Text align, preformatted. -
Text align, wrapped. -
Double check Line height (mostly relevant for text in shape, I think?) -
Text Decor -
Tab Size -
Text Length
-
-
Improve qml for text-align.
The above shows the new text rendering option, as well as the extra buttons for text-align.
Test Plan
- Make a text.
- Add new text rendering option in the paragraph section of the text properties.
- Optimize Legibility will use light hinting for horizontal text and full hinting for vertical. Microsoft's Verdana is a good candidate for testing Hinting, though most fonts will have some basic hinting info in them.
- Optimize Speed will use 'mono hinting'. This is particularly interesting with pixel-art fonts.
The above image shows MS simsun at 400%. The blue text is using optimize speed, and shows how the snapping that has been added to the code allows for the glyphs to be aligned to pixels and thus rasterize the same, no matter the offsets apply. This will be mostly useful for pixel art fonts.
The green text demonstrates "Optimize Legibility" versus the blue text, which demonstrates the default "geometric precision". In horizontal, we use "light hinting", which means that the glyphs are only hinted in the Y-axis. In vertical we use full-hinting, because freetype has no Y only hinting. Either way, due the hinting, the glyphs align to pixels in the vertical axis, which can be a boon for legibility on small resolutions.
Mind, this does require that the text start itself is snapped to the nearest pixel. Not sure how to get around this.
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy. -
Does the patch add a user-visible feature? If yes, is there a documentation MR ready for it at Krita Documentation Repository?