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

ristretto backport: Fix icon text fit #8795

Merged
merged 8 commits into from
Sep 24, 2019

Conversation

kkaefer
Copy link
Contributor

@kkaefer kkaefer commented Sep 24, 2019

Backports #8741 to release-ristretto


We're adding a 1 pixel border around all icons when adding them to the image atlas texture to avoid having neighboring icons bleed into the current image when using linear texture interpolation. When stretching icons to fit the text's dimensions with icon-text-fit, however, we didn't account for this correctly: We didn't add the border in this case, resulting in stretched icons that didn't quite cover the whole text. When the difference between the icon's original size and the stretched size was small, this wasn't really noticeable, especially in cases where we were using nearest neighbor texture interpolation instead of linear interpolation. When accounting for the 1 pixel border, have to to take into account that there's no longer a 1:1 mapping between vertex units and pixel units, and expand the vertices adequately.

Here's an example:

Before After
actual actual

This example uses a really small icon icon-text-fit so that the discrepancy between the true size and the scaled size is big, which leads to a large error.

Native patch is forthcoming.

kkaefer and others added 8 commits September 24, 2019 10:08
We're adding a 1 pixel border around all icons when adding them to the image atlas texture to avoid having neighboring icons bleed into the current image when using linear texture interpolation. When stretching icons to fit the text's dimensions with `icon-text-fit`, however, we didn't account for this correctly: We didn't add the border in this case, resulting in stretched icons that didn't quite cover the whole text. When the difference between the icon's original size and the stretched size was small, this wasn't really noticeable, especially in cases where we were using nearest neighbor texture interpolation instead of linear interpolation. When accounting for the 1 pixel border, have to to take into account that there's no longer a 1:1 mapping between vertex units and pixel units, and expand the vertices adequately.
also add a lot more unit and render tests
@kkaefer kkaefer self-assigned this Sep 24, 2019
@kkaefer kkaefer added this to the release-ristretto milestone Sep 24, 2019
@kkaefer kkaefer merged commit 1eadcba into release-ristretto Sep 24, 2019
@kkaefer kkaefer deleted the backport-ristretto-8741-fix-icon-text-fit branch September 24, 2019 08:48
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.

3 participants