Skip to content

Commit

Permalink
Fix TextLayer sdf mode (#4911)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Sep 1, 2020
1 parent 5e480de commit 703ca20
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const EMPTY_ARRAY = [];

const defaultProps = {
backgroundColor: {type: 'color', value: null, optional: true},
getIconOffsets: {type: 'accessor', value: x => x.offsets}
getIconOffsets: {type: 'accessor', value: x => x.offsets},
alphaCutoff: 0
};

export default class MultiIconLayer extends IconLayer {
Expand Down
4 changes: 2 additions & 2 deletions modules/layers/src/text-layer/text-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default class TextLayer extends CompositeLayer {
getAngle,
getPixelOffset,
billboard,
sdf,
fontSettings,
sizeScale,
sizeUnits,
sizeMinPixels,
Expand All @@ -274,7 +274,7 @@ export default class TextLayer extends CompositeLayer {

return new SubLayerClass(
{
sdf,
sdf: fontSettings.sdf,
iconAtlas: texture,
iconMapping: mapping,
backgroundColor,
Expand Down
30 changes: 30 additions & 0 deletions test/modules/layers/text-layer/text-layer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,36 @@ test('TextLayer', t => {
t.end();
});

test('TextLayer - sdf', t => {
const testCases = [
{
props: {
data: FIXTURES.points,
getText: d => d.ADDRESS,
getPosition: d => d.COORDINATES
},
onAfterUpdate: ({subLayer}) => {
t.notOk(subLayer.props.sdf, 'sublayer props.sdf');
t.is(subLayer.props.alphaCutoff, 0, 'sublayer props.alphaCutoff');
}
},
{
updateProps: {
fontSettings: {
sdf: true,
buffer: 10
}
},
onAfterUpdate: ({subLayer}) => {
t.ok(subLayer.props.sdf, 'sublayer props.sdf');
}
}
];
testLayer({Layer: TextLayer, testCases, onError: t.notOk});

t.end();
});

test('TextLayer - binary', t => {
const value = new Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33]);
const startIndices = [0, 6];
Expand Down

0 comments on commit 703ca20

Please sign in to comment.