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

icon-text-fit-padding produces inconsistent pixel padding #8476

Open
tristen opened this issue Jul 14, 2019 · 4 comments
Open

icon-text-fit-padding produces inconsistent pixel padding #8476

tristen opened this issue Jul 14, 2019 · 4 comments
Labels
bug 🐞 cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)

Comments

@tristen
Copy link
Member

tristen commented Jul 14, 2019

I'm using two icons that are identical in dimensions. Here's an example of the first:

<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 18" height="18" width="40" version="1.1">
  <path d="M 40,0 0,0 0,18 40,18 Z" fill="#70A5E7" />
</svg>

On duplicate layers to create an outline effect by setting the icon-text-fit-padding values to be 1 pixel larger than the second . But the pixels appear inconsistent in cases

Screen Shot 2019-07-15 at 6 42 36 AM


mapbox-gl-js version: v1.1.0
browser: Google Chrome Version 74.0.3729.169 (Official Build) (64-bit)

Expected behavior

I would expect the value of icon-text-fit-padding in the first layer to be evenly padded by 1 additional pixels

Link to Demonstration

https://jsfiddle.net/s1fxmvn2/embedded/result/?username=tristen

@mourner mourner added bug 🐞 cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) labels Jul 15, 2019
@asheemmamoowala asheemmamoowala added this to the release-queso milestone Jul 19, 2019
@chloekraw chloekraw removed this from the release-queso milestone Aug 2, 2019
@asheemmamoowala asheemmamoowala added this to the release-ristretto milestone Aug 22, 2019
@ansis
Copy link
Contributor

ansis commented Sep 3, 2019

Some speculation: this is caused by linear interpolation. Since we're stretching the icons we can't snap them to a pixel grid. Since we can't snap them to the pixel grid the 1px boundary isn't necessarily one crisp pixel. I'm not sure this can be quickly fixed.

But that is just speculation and someone needs to actually dig in.

@kkaefer
Copy link
Member

kkaefer commented Sep 3, 2019

@ansis I think the opposite is the case: The JSFiddle above uses nearest-neighbor texture scaling. As soon as you rotate the map, it switches to linear interpolation, and—at the expense of being less crisp—all borders show up.

@chloekraw
Copy link
Contributor

Quick note, for a customer implementation we're suggesting that they use 'icon-text-fit-padding': [1, 3, 3, 3] to get a consistent padding across all four sides. There's only one icon used (unlike the jsfiddle). The customer would like an explanation of why this occurs. It's likely okay if we can't fix it.

@kkaefer
Copy link
Member

kkaefer commented Sep 16, 2019

This gets slightly better with #8741, as well as #8730, but won't be entirely resolved. The underlying issue is that we image is still stretched, which means that the frame "border"'s pixels will get stretched into the neighboring pixel. Without #8730, they could be in a pixel that nearest neighbor texture lookups omit entirely. With that change, it means that they border will be somewhat blurry or fainter because it is rendered or stretched across a pixel boundary. To fix this correctly, we need #4143.

@kkaefer kkaefer modified the milestones: release-ristretto, release-s Sep 19, 2019
@chloekraw chloekraw removed this from the release-sangria milestone Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)
Projects
None yet
Development

No branches or pull requests

6 participants