Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dx parameter for sub-pixel rasterization #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andersrein
Copy link

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:

fontdue_difference
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.

Added dx parameter which allows for controlling the horizontal offset
within the pixel. This allows drawing glyphs at the exact floating point
x position provided by accumulating the horizontal advance_width metric
when drawing text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant