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:

Screenshot_20240305_190828

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:

Screenshot_20240305_191043

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 ):

Screenshot_20240305_192637


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:

Screenshot_20240305_191500

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):

310207361-275ea8c2-3761-4be4-a8cc-459f815d4389

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 16 (1 by maintainers)

Commits related to this issue

Most upvoted comments

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