Added dx parameter for sub-pixel rasterization #160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When rendering text by rasterizing one glyph at a time and copying the bitmaps for each glyph onto a larger bitmap it is quite complicate to copy from the source bitmap to the target bitmap at sub-pixel precision. I was able to improve this by adding a dx parameter which allows setting the sub-pixel x offset when rasterizing a glyph. This way the source bitmap can be copied to the target bitmap at exact pixel offsets. Have a look at the result:
The top line was rendered using the new sub-pixel offset in order to place the glyph at the exact position of the accumulated horizontal advance. The bottom line shows the best effort rendering of the text by rounding the current x position to the nearest whole pixel. Have a look at the 'd' and 'e' in video on the bottom line. These are too close together. Also the 'u' and 'b' in youtube is too far form each other.