Skip to content

Commit

Permalink
add dds support for text-offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Molly Lloyd committed Mar 25, 2017
1 parent 30c639f commit b0fd18f
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ class SymbolBucket {
const lineHeight = layout['text-line-height'] * oneEm;
const maxWidth = layout['symbol-placement'] !== 'line' ? layout['text-max-width'] * oneEm : 0;
const spacing = layout['text-letter-spacing'] * oneEm;
const textOffset = [layout['text-offset'][0] * oneEm, layout['text-offset'][1] * oneEm];
const fontstack = this.fontstack = layout['text-font'].join(',');
const textAlongLine = layout['text-rotation-alignment'] === 'map' && layout['symbol-placement'] === 'line';

Expand All @@ -332,6 +331,7 @@ class SymbolBucket {
let shapedTextOrientations;
if (feature.text) {
const allowsVerticalWritingMode = scriptDetection.allowsVerticalWritingMode(feature.text);
const textOffset = this.layers[0].getLayoutValue('text-offset', {zoom: this.zoom}, feature.properties).map((t)=> t * oneEm);

shapedTextOrientations = {
[WritingMode.horizontal]: shapeText(feature.text, stacks[fontstack], maxWidth, lineHeight, horizontalAlign, verticalAlign, justify, spacing, textOffset, oneEm, WritingMode.horizontal),
Expand Down
5 changes: 4 additions & 1 deletion src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@
"units": "ems",
"function": "interpolated",
"zoom-function": true,
"property-function": true,
"length": 2,
"default": [
0,
Expand All @@ -1423,7 +1424,9 @@
"ios": "2.0.0",
"macos": "0.1.0"
},
"data-driven styling": {}
"data-driven styling": {
"js": "0.35.0"
}
}
},
"text-allow-overlap": {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": 8,
"metadata": {
"test": {
"height": 256
}
},
"center": [
13.418056,
52.499167
],
"zoom": 14,
"sources": {
"mapbox": {
"type": "vector",
"maxzoom": 14,
"tiles": [
"local://tiles/{z}-{x}-{y}.mvt"
]
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-color": "white"
}
},
{
"id": "literal",
"type": "symbol",
"source": "mapbox",
"source-layer": "poi_label",
"layout": {
"symbol-placement": "point",
"text-allow-overlap": true,
"text-ignore-placement": true,
"text-field": "Test",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"text-offset": {
"base": 1,
"stops": [
[
0,
[
0,
10
]
],
[
50,
[
20,
10
]
]
],
"property": "localrank"
}
}
}
]
}

0 comments on commit b0fd18f

Please sign in to comment.