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

Zero text halo should be no halo #1074

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/stylefunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ export function stylefunction(
),
opacity
);
if (haloColor) {
if (haloColor && textHaloWidth > 0) {
textHalo.setColor(haloColor);
// spec here : https://docs.mapbox.com/mapbox-gl-js/style-spec/#paint-symbol-text-halo-width
// Halo width must be doubled because it is applied around the center of the text outline
Expand Down
19 changes: 19 additions & 0 deletions test/stylefunction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,25 @@
done(err);
});
});

it('Zero width text halo should be no halo', function(done){

Check failure on line 350 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Replace `(done)` with `·(done)·`
style.layers[0].paint['text-halo-color'] = 'red';
style.layers[0].paint['text-halo-width'] = 0;
apply(document.createElement('div'), style)
.then(function (map) {

Check failure on line 354 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Insert `··`
const layer = map.getLayers().item(0);

Check failure on line 355 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Insert `··`
const styleFunction = layer.getStyle();

Check failure on line 356 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Replace `········` with `··········`
const feature = layer.getSource().getFeatures()[0];

Check failure on line 357 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Insert `··`
const styles = styleFunction(feature, 1);

Check failure on line 358 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Replace `········` with `··········`
const text = styles[0].getText();

Check failure on line 359 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Insert `··`
console.log(text.getStroke());

Check failure on line 360 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Insert `··`

Check failure on line 360 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Unexpected console statement
should(text.getStroke()).be.undefined();

Check failure on line 361 in test/stylefunction.test.js

View workflow job for this annotation

GitHub Actions / test

Insert `··`
done();
})
.catch(function (err) {
done(err);
});
});
});

describe('Declutter mode', function () {
Expand Down