maplibre-native: icon halo does not work
Just like for text, on sdf icons, one can add a halo using the style properties icon-halo-color, icon-halo-width etc.
Unlike for text, the halo for icons is not displayed correctly.
Observations
This style definition
SymbolLayer("overlay-symbols", "overlay-source")
.withProperties(
textField(get("label")),
textAnchor(Property.TEXT_ANCHOR_LEFT),
textOffset(arrayOf(1.5f, 0f)),
textMaxWidth(5f),
textHaloColor("white"),
textHaloWidth(1.5f),
iconImage(get("icon")),
iconColor("black"),
iconHaloColor("white"),
iconHaloWidth(1.5f),
)
produces this render result:
The displayed halo width seems to always be ~0 regardless of what is set.
Even when removing the halo, the SDF icon looks like the anti-aliasing does not work correctly:
It very much looks like the halo does only fill the pixels that would otherwise be half transparent.
When setting the icon-halo-width to 6 or above, the whole icon is filled with the halo color. (This might be different bug related to https://github.com/mapbox/mapbox-gl-js/issues/7204 ):
For comparison, this is how the icon looks like when it is not an SDF icon. Halos don’t work on non-SDF icons, of course:
Platform information
- OS: Tested on Android 13, Android 9
- MapLibre: org.maplibre.gl:android-sdk:10.0.2
Additional information
The lower the display density, the more visible is the halo issue.
The above screenshots were made on a device with 438 ppi display density (x3), the below screenshot was made on a device with 256 ppi display density (x1.5):
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Comments: 16 (1 by maintainers)
Commits related to this issue
- add workaround for https://github.com/maplibre/maplibre-native/issues/2175 (don't use icon halo) — committed to Helium314/SCEE by westnordost 3 months ago
Sure. The issue appears for all sprites. I am using the sprites from iD editor presets. This particular sprite can be found here:
https://raw.githubusercontent.com/mapbox/maki/main/icons/restaurant.svg