diff --git a/src/symbol/placement.js b/src/symbol/placement.js index 8b9a65216a7..c580da49fb1 100644 --- a/src/symbol/placement.js +++ b/src/symbol/placement.js @@ -237,7 +237,7 @@ export class Placement { attemptAnchorPlacement(anchor: TextAnchor, textBox: SingleCollisionBox, width: number, height: number, textBoxScale: number, rotateWithMap: boolean, pitchWithMap: boolean, textPixelRatio: number, posMatrix: mat4, collisionGroup: CollisionGroup, - textAllowOverlap: boolean, symbolInstance: SymbolInstance, bucket: SymbolBucket, orientation: number): ?{ box: Array, offscreen: boolean } { + textAllowOverlap: boolean, symbolInstance: SymbolInstance, bucket: SymbolBucket, orientation: number): ?{ shift: Point, placedGlyphBoxes: { box: Array, offscreen: boolean } } { const textOffset = [symbolInstance.textOffset0, symbolInstance.textOffset1]; const shift = calculateVariableLayoutShift(anchor, width, height, textOffset, textBoxScale); @@ -274,7 +274,7 @@ export class Placement { this.placedOrientations[symbolInstance.crossTileID] = orientation; } - return placedGlyphBoxes; + return {shift, placedGlyphBoxes}; } } @@ -308,6 +308,7 @@ export class Placement { const rotateWithMap = layout.get('text-rotation-alignment') === 'map'; const pitchWithMap = layout.get('text-pitch-alignment') === 'map'; + const hasIconTextFit = layout.get('icon-text-fit') !== 'none'; const zOrderByViewportY = layout.get('symbol-z-order') === 'viewport-y'; if (!bucket.collisionArrays && collisionBoxArray) { @@ -326,6 +327,7 @@ export class Placement { let placeText = false; let placeIcon = false; let offscreen = true; + let shift = null; let placed = {box: null, offscreen: null}; let placedVertical = {box: null, offscreen: null}; @@ -426,14 +428,18 @@ export class Placement { for (let i = 0; i < placementAttempts; ++i) { const anchor = anchors[i % anchors.length]; const allowOverlap = (i >= anchors.length); - placedBox = this.attemptAnchorPlacement( + const result = this.attemptAnchorPlacement( anchor, collisionTextBox, width, height, textBoxScale, rotateWithMap, pitchWithMap, textPixelRatio, posMatrix, collisionGroup, allowOverlap, symbolInstance, bucket, orientation); - if (placedBox && placedBox.box && placedBox.box.length) { - placeText = true; - break; + if (result) { + placedBox = result.placedGlyphBoxes; + if (placedBox && placedBox.box && placedBox.box.length) { + placeText = true; + shift = result.shift; + break; + } } } @@ -508,7 +514,14 @@ export class Placement { iconFeatureIndex = collisionArrays.iconFeatureIndex; } if (collisionArrays.iconBox) { - placedIconBoxes = this.collisionIndex.placeCollisionBox(collisionArrays.iconBox, + + const iconBox = hasIconTextFit && shift ? + shiftVariableCollisionBox( + collisionArrays.iconBox, shift.x, shift.y, + rotateWithMap, pitchWithMap, this.transform.angle) : + collisionArrays.iconBox; + + placedIconBoxes = this.collisionIndex.placeCollisionBox(iconBox, layout.get('icon-allow-overlap'), textPixelRatio, posMatrix, collisionGroup.predicate); placeIcon = placedIconBoxes.box.length > 0; offscreen = offscreen && placedIconBoxes.offscreen; @@ -709,6 +722,7 @@ export class Placement { const variablePlacement = layout.get('text-variable-anchor'); const rotateWithMap = layout.get('text-rotation-alignment') === 'map'; const pitchWithMap = layout.get('text-pitch-alignment') === 'map'; + const hasIconTextFit = layout.get('icon-text-fit') !== 'none'; // If allow-overlap is true, we can show symbols before placement runs on them // But we have to wait for placement if we potentially depend on a paired icon/text // with allow-overlap: false. @@ -802,8 +816,8 @@ export class Placement { bucket.hasTextCollisionBoxData() || bucket.hasTextCollisionCircleData()) { const collisionArrays = bucket.collisionArrays[s]; if (collisionArrays) { + let shift = new Point(0, 0); if (collisionArrays.textBox) { - let shift = new Point(0, 0); let used = true; if (variablePlacement) { const variableOffset = this.variableOffsets[crossTileID]; @@ -832,7 +846,9 @@ export class Placement { } if (collisionArrays.iconBox) { - updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, false); + updateCollisionVertices(bucket.iconCollisionBox.collisionVertexArray, opacityState.icon.placed, false, + hasIconTextFit ? shift.x : 0, + hasIconTextFit ? shift.y : 0); } const textCircles = collisionArrays.textCircles; diff --git a/src/symbol/quads.js b/src/symbol/quads.js index 9a64a789f5e..6d3b857f717 100644 --- a/src/symbol/quads.js +++ b/src/symbol/quads.js @@ -44,58 +44,35 @@ export type SymbolQuad = { * Create the quads used for rendering an icon. * @private */ -export function getIconQuads(anchor: Anchor, +export function getIconQuads( shapedIcon: PositionedIcon, - layer: SymbolStyleLayer, - alongLine: boolean, - shapedText: Shaping | null, - feature: Feature): Array { + iconRotate: number): Array { const image = shapedIcon.image; - const layout = layer.layout; // If you have a 10px icon that isn't perfectly aligned to the pixel grid it will cover 11 actual // pixels. The quad needs to be padded to account for this, otherwise they'll look slightly clipped // on one edge in some cases. const border = 1; - const top = shapedIcon.top - border / image.pixelRatio; - const left = shapedIcon.left - border / image.pixelRatio; - const bottom = shapedIcon.bottom + border / image.pixelRatio; - const right = shapedIcon.right + border / image.pixelRatio; - let tl, tr, br, bl; - - // text-fit mode - if (layout.get('icon-text-fit') !== 'none' && shapedText) { - const iconWidth = (right - left), - iconHeight = (bottom - top), - size = layout.get('text-size').evaluate(feature, {}) / 24, - textLeft = shapedText.left * size, - textRight = shapedText.right * size, - textTop = shapedText.top * size, - textBottom = shapedText.bottom * size, - textWidth = textRight - textLeft, - textHeight = textBottom - textTop, - padT = layout.get('icon-text-fit-padding')[0], - padR = layout.get('icon-text-fit-padding')[1], - padB = layout.get('icon-text-fit-padding')[2], - padL = layout.get('icon-text-fit-padding')[3], - offsetY = layout.get('icon-text-fit') === 'width' ? (textHeight - iconHeight) * 0.5 : 0, - offsetX = layout.get('icon-text-fit') === 'height' ? (textWidth - iconWidth) * 0.5 : 0, - width = layout.get('icon-text-fit') === 'width' || layout.get('icon-text-fit') === 'both' ? textWidth : iconWidth, - height = layout.get('icon-text-fit') === 'height' || layout.get('icon-text-fit') === 'both' ? textHeight : iconHeight; - tl = new Point(textLeft + offsetX - padL, textTop + offsetY - padT); - tr = new Point(textLeft + offsetX + padR + width, textTop + offsetY - padT); - br = new Point(textLeft + offsetX + padR + width, textTop + offsetY + padB + height); - bl = new Point(textLeft + offsetX - padL, textTop + offsetY + padB + height); - // Normal icon size mode - } else { - tl = new Point(left, top); - tr = new Point(right, top); - br = new Point(right, bottom); - bl = new Point(left, bottom); - } - - const angle = layer.layout.get('icon-rotate').evaluate(feature, {}) * Math.PI / 180; + // Expand the box to respect the 1 pixel border in the atlas image. We're using `image.paddedRect - border` + // instead of image.displaySize because we only pad with one pixel for retina images as well, and the + // displaySize uses the logical dimensions, not the physical pixel dimensions. + const iconWidth = shapedIcon.right - shapedIcon.left; + const expandX = (iconWidth * image.paddedRect.w / (image.paddedRect.w - 2 * border) - iconWidth) / 2; + const left = shapedIcon.left - expandX; + const right = shapedIcon.right + expandX; + + const iconHeight = shapedIcon.bottom - shapedIcon.top; + const expandY = (iconHeight * image.paddedRect.h / (image.paddedRect.h - 2 * border) - iconHeight) / 2; + const top = shapedIcon.top - expandY; + const bottom = shapedIcon.bottom + expandY; + + const tl = new Point(left, top); + const tr = new Point(right, top); + const br = new Point(right, bottom); + const bl = new Point(left, bottom); + + const angle = iconRotate * Math.PI / 180; if (angle) { const sin = Math.sin(angle), diff --git a/src/symbol/shaping.js b/src/symbol/shaping.js index ad2e2db54aa..0c95738fb87 100644 --- a/src/symbol/shaping.js +++ b/src/symbol/shaping.js @@ -1,5 +1,6 @@ // @flow +import assert from 'assert'; import { charHasUprightVerticalOrientation, charAllowsIdeographicBreaking, @@ -19,7 +20,7 @@ const WritingMode = { horizontalOnly: 3 }; -export {shapeText, shapeIcon, getAnchorAlignment, WritingMode}; +export {shapeText, shapeIcon, fitIconToText, getAnchorAlignment, WritingMode}; // The position of a glyph relative to the text's anchor point. export type PositionedGlyph = { @@ -581,3 +582,46 @@ function shapeIcon(image: ImagePosition, iconOffset: [number, number], iconAncho const y2 = y1 + image.displaySize[1]; return {image, top: y1, bottom: y2, left: x1, right: x2}; } + +function fitIconToText(shapedIcon: PositionedIcon, shapedText: Shaping, + textFit: string, + padding: [ number, number, number, number ], + iconOffset: [ number, number ], fontScale: number): PositionedIcon { + assert(textFit !== 'none'); + assert(Array.isArray(padding) && padding.length === 4); + assert(Array.isArray(iconOffset) && iconOffset.length === 2); + + const image = shapedIcon.image; + + // We don't respect the icon-anchor, because icon-text-fit is set. Instead, + // the icon will be centered on the text, then stretched in the given + // dimensions. + + const textLeft = shapedText.left * fontScale; + const textRight = shapedText.right * fontScale; + + let top, right, bottom, left; + if (textFit === 'width' || textFit === 'both') { + // Stretched horizontally to the text width + left = iconOffset[0] + textLeft - padding[3]; + right = iconOffset[0] + textRight + padding[1]; + } else { + // Centered on the text + left = iconOffset[0] + (textLeft + textRight - image.displaySize[0]) / 2; + right = left + image.displaySize[0]; + } + + const textTop = shapedText.top * fontScale; + const textBottom = shapedText.bottom * fontScale; + if (textFit === 'height' || textFit === 'both') { + // Stretched vertically to the text height + top = iconOffset[1] + textTop - padding[0]; + bottom = iconOffset[1] + textBottom + padding[2]; + } else { + // Centered on the text + top = iconOffset[1] + (textTop + textBottom - image.displaySize[1]) / 2; + bottom = top + image.displaySize[1]; + } + + return {image, top, right, bottom, left}; +} diff --git a/src/symbol/symbol_layout.js b/src/symbol/symbol_layout.js index 56da5cca3af..28cc9146dd5 100644 --- a/src/symbol/symbol_layout.js +++ b/src/symbol/symbol_layout.js @@ -4,7 +4,7 @@ import Anchor from './anchor'; import {getAnchors, getCenterAnchor} from './get_anchors'; import clipLine from './clip_line'; -import {shapeText, shapeIcon, WritingMode} from './shaping'; +import {shapeText, shapeIcon, WritingMode, fitIconToText} from './shaping'; import {getGlyphQuads, getIconQuads} from './quads'; import CollisionFeature from './collision_feature'; import {warnOnce} from '../util/util'; @@ -377,6 +377,15 @@ function addFeature(bucket: SymbolBucket, symbolPlacement = layout.get('symbol-placement'), textRepeatDistance = symbolMinDistance / 2; + const iconTextFit = layout.get('icon-text-fit'); + // Adjust shaped icon size when icon-text-fit is used. + if (shapedIcon && iconTextFit !== 'none') { + if (defaultHorizontalShaping) { + shapedIcon = fitIconToText(shapedIcon, defaultHorizontalShaping, iconTextFit, + layout.get('icon-text-fit-padding'), iconOffset, fontScale); + } + } + const addSymbolAtAnchor = (line, anchor) => { if (anchor.x < 0 || anchor.x >= EXTENT || anchor.y < 0 || anchor.y >= EXTENT) { // Symbol layers are drawn across tile boundaries, We filter out symbols @@ -577,10 +586,8 @@ function addSymbol(bucket: SymbolBucket, //If the style specifies an `icon-text-fit` then the icon would have to shift along with it. // For more info check `updateVariableAnchors` in `draw_symbol.js` . if (shapedIcon) { - const iconQuads = getIconQuads(anchor, shapedIcon, layer, - iconAlongLine, getDefaultHorizontalShaping(shapedTextOrientations.horizontal), - feature); const iconRotate = layer.layout.get('icon-rotate').evaluate(feature, {}); + const iconQuads = getIconQuads(shapedIcon, iconRotate); iconCollisionFeature = new CollisionFeature(collisionBoxArray, line, anchor, featureIndex, sourceLayerIndex, bucketIndex, shapedIcon, iconBoxScale, iconPadding, /*align boxes to line*/false, bucket.overscaling, iconRotate); numIconVertices = iconQuads.length * 4; diff --git a/test/ignores.json b/test/ignores.json index 4d3a632dd89..c9e88b1e890 100644 --- a/test/ignores.json +++ b/test/ignores.json @@ -13,19 +13,7 @@ "render-tests/mixed-zoom/z10-z11": "current behavior conflicts with https://github.com/mapbox/mapbox-gl-js/pull/6803. can be fixed when https://github.com/mapbox/api-maps/issues/1480 is done", "render-tests/fill-extrusion-pattern/tile-buffer": "https://github.com/mapbox/mapbox-gl-js/issues/4403", "render-tests/symbol-sort-key/text-ignore-placement": "skip - text drawn over icons", - "render-tests/icon-text-fit/both-padding": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/both": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/height-padding": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/height": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/placement-line": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/width-padding": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/width": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/both-collision-variable-anchor-text-fit": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/both-collision-variable-anchor": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/icon-text-fit/both-collision": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/regressions/mapbox-gl-js#5631": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/text-variable-anchor/all-anchors-icon-text-fit": "https://github.com/mapbox/mapbox-gl-js/issues/8583", - "render-tests/text-variable-anchor/icon-text-fit-collision-box": "https://github.com/mapbox/mapbox-gl-js/issues/8583", + "render-tests/text-variable-anchor/remember-last-placement": "skip - not sure this is correct behavior", "render-tests/text-writing-mode/point_label/cjk-variable-anchors-vertical-horizontal-mode-icon-text-fit": "https://github.com/mapbox/mapbox-gl-js/issues/8583", "render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit": "https://github.com/mapbox/mapbox-gl-js/issues/8583", "render-tests/icon-image/icon-sdf-non-sdf-one-layer": "skip - render sdf icon and normal icon in one layer" diff --git a/test/integration/geojson/anchors.json b/test/integration/geojson/anchors.json new file mode 100644 index 00000000000..8a8840cb78f --- /dev/null +++ b/test/integration/geojson/anchors.json @@ -0,0 +1,85 @@ +{ + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "properties": { + "anchor": "center" + }, + "geometry": { + "type": "Point", + "coordinates": [ 0, 0 ] + } + }, { + "type": "Feature", + "properties": { + "anchor": "left" + }, + "geometry": { + "type": "Point", + "coordinates": [ 30, 0 ] + } + }, { + "type": "Feature", + "properties": { + "anchor": "top-left" + }, + "geometry": { + "type": "Point", + "coordinates": [ 20, -15 ] + } + }, { + "type": "Feature", + "properties": { + "anchor": "top" + }, + "geometry": { + "type": "Point", + "coordinates": [ 0, -25 ] + } + }, { + "type": "Feature", + "properties": { + "anchor": "top-right" + }, + "geometry": { + "type": "Point", + "coordinates": [ -20, -15 ] + } + }, { + "type": "Feature", + "properties": { + "anchor": "right" + }, + "geometry": { + "type": "Point", + "coordinates": [ -30, 0 ] + } + }, { + "type": "Feature", + "properties": { + "anchor": "bottom-left" + }, + "geometry": { + "type": "Point", + "coordinates": [ 20, 15 ] + } + }, { + "type": "Feature", + "properties": { + "anchor": "bottom" + }, + "geometry": { + "type": "Point", + "coordinates": [ 0, 25 ] + } + }, { + "type": "Feature", + "properties": { + "anchor": "bottom-right" + }, + "geometry": { + "type": "Point", + "coordinates": [ -20, 15 ] + } + }] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/both-padding/expected.png b/test/integration/render-tests/icon-text-fit/both-padding/expected.png index 488099e3dbf..fb545001ce7 100644 Binary files a/test/integration/render-tests/icon-text-fit/both-padding/expected.png and b/test/integration/render-tests/icon-text-fit/both-padding/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-1x-image-2x-screen/expected.png b/test/integration/render-tests/icon-text-fit/both-text-anchor-1x-image-2x-screen/expected.png new file mode 100644 index 00000000000..69a22d5e171 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/both-text-anchor-1x-image-2x-screen/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-1x-image-2x-screen/style.json b/test/integration/render-tests/icon-text-fit/both-text-anchor-1x-image-2x-screen/style.json new file mode 100644 index 00000000000..087a99dd604 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/both-text-anchor-1x-image-2x-screen/style.json @@ -0,0 +1,193 @@ +{ + "version": 8, + "metadata": { + "test": { + "pixelRatio": 2, + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit-1x", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-1x-screen/expected.png b/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-1x-screen/expected.png new file mode 100644 index 00000000000..6b27859c39e Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-1x-screen/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-1x-screen/style.json b/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-1x-screen/style.json new file mode 100644 index 00000000000..d21af0963b4 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-1x-screen/style.json @@ -0,0 +1,192 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit-2x", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-2x-screen/expected.png b/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-2x-screen/expected.png new file mode 100644 index 00000000000..585b0d15857 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-2x-screen/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-2x-screen/style.json b/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-2x-screen/style.json new file mode 100644 index 00000000000..1e75952eb13 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/both-text-anchor-2x-image-2x-screen/style.json @@ -0,0 +1,194 @@ +{ + "version": 8, + "metadata": { + "test": { + "pixelRatio": 2, + "width": 200, + "height": 150, + "allowed": 0.001 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-anchor/expected.png b/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-anchor/expected.png new file mode 100644 index 00000000000..95ca30121e0 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-anchor/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-anchor/style.json b/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-anchor/style.json new file mode 100644 index 00000000000..354b691aa72 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-anchor/style.json @@ -0,0 +1,201 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true, + "icon-anchor": "top-left" + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-offset/expected.png b/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-offset/expected.png new file mode 100644 index 00000000000..6f2af350db5 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-offset/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-offset/style.json b/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-offset/style.json new file mode 100644 index 00000000000..9218b731040 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/both-text-anchor-icon-offset/style.json @@ -0,0 +1,201 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-offset": [ 4, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-padding/expected.png b/test/integration/render-tests/icon-text-fit/both-text-anchor-padding/expected.png new file mode 100644 index 00000000000..ed953be8afb Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/both-text-anchor-padding/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor-padding/style.json b/test/integration/render-tests/icon-text-fit/both-text-anchor-padding/style.json new file mode 100644 index 00000000000..3be058e38f8 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/both-text-anchor-padding/style.json @@ -0,0 +1,201 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor/expected.png b/test/integration/render-tests/icon-text-fit/both-text-anchor/expected.png new file mode 100644 index 00000000000..95ca30121e0 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/both-text-anchor/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/both-text-anchor/style.json b/test/integration/render-tests/icon-text-fit/both-text-anchor/style.json new file mode 100644 index 00000000000..b3a3e0b7772 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/both-text-anchor/style.json @@ -0,0 +1,192 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/both/expected.png b/test/integration/render-tests/icon-text-fit/both/expected.png index 293d3854925..809bdcbd86c 100644 Binary files a/test/integration/render-tests/icon-text-fit/both/expected.png and b/test/integration/render-tests/icon-text-fit/both/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/enlargen-both-padding/expected.png b/test/integration/render-tests/icon-text-fit/enlargen-both-padding/expected.png new file mode 100644 index 00000000000..7541ddfcb74 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/enlargen-both-padding/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/enlargen-both-padding/style.json b/test/integration/render-tests/icon-text-fit/enlargen-both-padding/style.json new file mode 100644 index 00000000000..2114e648b4f --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/enlargen-both-padding/style.json @@ -0,0 +1,42 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 150, + "height": 64, + "allowed": 0.005 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "text-field": "ABCD efgh", + "text-size": 24, + "text-font": [ + "Open Sans Semibold", + "Arial Unicode MS Bold" + ], + "icon-image": "small-box", + "icon-text-fit": "both", + "icon-text-fit-padding": [ 12, 8, 4, 2 ] + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/enlargen-both/expected.png b/test/integration/render-tests/icon-text-fit/enlargen-both/expected.png new file mode 100644 index 00000000000..26e70320f9e Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/enlargen-both/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/enlargen-both/style.json b/test/integration/render-tests/icon-text-fit/enlargen-both/style.json new file mode 100644 index 00000000000..7c76c51f153 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/enlargen-both/style.json @@ -0,0 +1,41 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 128, + "height": 64, + "allowed": 0.004 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "text-field": "ABCD efgh", + "text-size": 24, + "text-font": [ + "Open Sans Semibold", + "Arial Unicode MS Bold" + ], + "icon-image": "small-box", + "icon-text-fit": "both" + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/enlargen-height/expected.png b/test/integration/render-tests/icon-text-fit/enlargen-height/expected.png new file mode 100644 index 00000000000..e4950716277 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/enlargen-height/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/enlargen-height/style.json b/test/integration/render-tests/icon-text-fit/enlargen-height/style.json new file mode 100644 index 00000000000..2cf205f0b6d --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/enlargen-height/style.json @@ -0,0 +1,40 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 128, + "height": 64 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "text-field": "ABCD efgh", + "text-size": 24, + "text-font": [ + "Open Sans Semibold", + "Arial Unicode MS Bold" + ], + "icon-image": "small-box", + "icon-text-fit": "height" + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/enlargen-width/expected.png b/test/integration/render-tests/icon-text-fit/enlargen-width/expected.png new file mode 100644 index 00000000000..ad9c5ca6e6f Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/enlargen-width/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/enlargen-width/style.json b/test/integration/render-tests/icon-text-fit/enlargen-width/style.json new file mode 100644 index 00000000000..00f0e293488 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/enlargen-width/style.json @@ -0,0 +1,41 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 128, + "height": 64, + "allowed": 0.002 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "text-field": "ABCD efgh", + "text-size": 24, + "text-font": [ + "Open Sans Semibold", + "Arial Unicode MS Bold" + ], + "icon-image": "small-box", + "icon-text-fit": "width" + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/height-padding/expected.png b/test/integration/render-tests/icon-text-fit/height-padding/expected.png index 1cc77cba5c2..ac07d82e7ca 100644 Binary files a/test/integration/render-tests/icon-text-fit/height-padding/expected.png and b/test/integration/render-tests/icon-text-fit/height-padding/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/height-padding/style.json b/test/integration/render-tests/icon-text-fit/height-padding/style.json index fe1d98bf618..377ef31c01c 100644 --- a/test/integration/render-tests/icon-text-fit/height-padding/style.json +++ b/test/integration/render-tests/icon-text-fit/height-padding/style.json @@ -2,7 +2,7 @@ "version": 8, "metadata": { "test": { - "width": 64, + "width": 96, "height": 64 } }, diff --git a/test/integration/render-tests/icon-text-fit/height-text-anchor-padding/expected.png b/test/integration/render-tests/icon-text-fit/height-text-anchor-padding/expected.png new file mode 100644 index 00000000000..301592014d9 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/height-text-anchor-padding/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/height-text-anchor-padding/style.json b/test/integration/render-tests/icon-text-fit/height-text-anchor-padding/style.json new file mode 100644 index 00000000000..253b546ff42 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/height-text-anchor-padding/style.json @@ -0,0 +1,201 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/height-text-anchor/expected.png b/test/integration/render-tests/icon-text-fit/height-text-anchor/expected.png new file mode 100644 index 00000000000..2b6e781e52d Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/height-text-anchor/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/height-text-anchor/style.json b/test/integration/render-tests/icon-text-fit/height-text-anchor/style.json new file mode 100644 index 00000000000..582d02aab07 --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/height-text-anchor/style.json @@ -0,0 +1,192 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "height", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/height/expected.png b/test/integration/render-tests/icon-text-fit/height/expected.png index 678eade07cd..5c743d5773c 100644 Binary files a/test/integration/render-tests/icon-text-fit/height/expected.png and b/test/integration/render-tests/icon-text-fit/height/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/height/style.json b/test/integration/render-tests/icon-text-fit/height/style.json index 238fd32ea89..58263210f9f 100644 --- a/test/integration/render-tests/icon-text-fit/height/style.json +++ b/test/integration/render-tests/icon-text-fit/height/style.json @@ -2,7 +2,7 @@ "version": 8, "metadata": { "test": { - "width": 64, + "width": 96, "height": 64 } }, diff --git a/test/integration/render-tests/icon-text-fit/none/expected.png b/test/integration/render-tests/icon-text-fit/none/expected.png index e0d0152e778..cb6040cdd9d 100644 Binary files a/test/integration/render-tests/icon-text-fit/none/expected.png and b/test/integration/render-tests/icon-text-fit/none/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/none/style.json b/test/integration/render-tests/icon-text-fit/none/style.json index fa87941aaa4..d5a1ea09179 100644 --- a/test/integration/render-tests/icon-text-fit/none/style.json +++ b/test/integration/render-tests/icon-text-fit/none/style.json @@ -2,7 +2,7 @@ "version": 8, "metadata": { "test": { - "width": 64, + "width": 96, "height": 64 } }, diff --git a/test/integration/render-tests/icon-text-fit/placement-line/expected.png b/test/integration/render-tests/icon-text-fit/placement-line/expected.png index 8c0f2ba16f1..0de83fd974a 100644 Binary files a/test/integration/render-tests/icon-text-fit/placement-line/expected.png and b/test/integration/render-tests/icon-text-fit/placement-line/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/text-variable-anchor-overlap/expected.png b/test/integration/render-tests/icon-text-fit/text-variable-anchor-overlap/expected.png index f161f2259eb..abc7219feb3 100644 Binary files a/test/integration/render-tests/icon-text-fit/text-variable-anchor-overlap/expected.png and b/test/integration/render-tests/icon-text-fit/text-variable-anchor-overlap/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/text-variable-anchor/expected.png b/test/integration/render-tests/icon-text-fit/text-variable-anchor/expected.png index 93b68ba6490..1b0ecb25ce6 100644 Binary files a/test/integration/render-tests/icon-text-fit/text-variable-anchor/expected.png and b/test/integration/render-tests/icon-text-fit/text-variable-anchor/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/width-padding/expected.png b/test/integration/render-tests/icon-text-fit/width-padding/expected.png index 24d57024d2c..0e00bbbcae1 100644 Binary files a/test/integration/render-tests/icon-text-fit/width-padding/expected.png and b/test/integration/render-tests/icon-text-fit/width-padding/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/width-text-anchor-padding/expected.png b/test/integration/render-tests/icon-text-fit/width-text-anchor-padding/expected.png new file mode 100644 index 00000000000..770743fd738 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/width-text-anchor-padding/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/width-text-anchor-padding/style.json b/test/integration/render-tests/icon-text-fit/width-text-anchor-padding/style.json new file mode 100644 index 00000000000..0bfc7214cdb --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/width-text-anchor-padding/style.json @@ -0,0 +1,201 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-text-fit-padding": [ 2, 4, 6, 8 ], + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/width-text-anchor/expected.png b/test/integration/render-tests/icon-text-fit/width-text-anchor/expected.png new file mode 100644 index 00000000000..f5f29a8cd95 Binary files /dev/null and b/test/integration/render-tests/icon-text-fit/width-text-anchor/expected.png differ diff --git a/test/integration/render-tests/icon-text-fit/width-text-anchor/style.json b/test/integration/render-tests/icon-text-fit/width-text-anchor/style.json new file mode 100644 index 00000000000..783b19cdd0d --- /dev/null +++ b/test/integration/render-tests/icon-text-fit/width-text-anchor/style.json @@ -0,0 +1,192 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 200, + "height": 150 + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": "local://geojson/anchors.json" + } + }, + "sprite": "local://sprites/icon-text-fit", + "glyphs": "local://glyphs/{fontstack}/{range}.pbf", + "layers": [ + { + "id": "anchor-center", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "center"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "center", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-top-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "top-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "top-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-left", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-left"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-left", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchor-bottom-right", + "type": "symbol", + "source": "geojson", + "filter": ["==", "anchor", "bottom-right"], + "layout": { + "text-field": "Ügt", + "text-size": 20, + "text-anchor": "bottom-right", + "text-font": [ "Open Sans Semibold", "Arial Unicode MS Bold" ], + "text-allow-overlap": true, + "text-ignore-placement": true, + "icon-image": "small-box", + "icon-text-fit": "width", + "icon-allow-overlap": true, + "icon-ignore-placement": true + } + }, + { + "id": "anchors", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 2, + "circle-color": "green", + "circle-stroke-color": "white", + "circle-stroke-width": 1 + } + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/icon-text-fit/width/expected.png b/test/integration/render-tests/icon-text-fit/width/expected.png index cd08e53a6d6..cab1f66b207 100644 Binary files a/test/integration/render-tests/icon-text-fit/width/expected.png and b/test/integration/render-tests/icon-text-fit/width/expected.png differ diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#5631/expected.png b/test/integration/render-tests/regressions/mapbox-gl-js#5631/expected.png index 54f96ca198f..eb535e2022f 100644 Binary files a/test/integration/render-tests/regressions/mapbox-gl-js#5631/expected.png and b/test/integration/render-tests/regressions/mapbox-gl-js#5631/expected.png differ diff --git a/test/integration/render-tests/text-variable-anchor/all-anchors-icon-text-fit/expected.png b/test/integration/render-tests/text-variable-anchor/all-anchors-icon-text-fit/expected.png index 9ea2fb269d1..a5fecd1d97b 100644 Binary files a/test/integration/render-tests/text-variable-anchor/all-anchors-icon-text-fit/expected.png and b/test/integration/render-tests/text-variable-anchor/all-anchors-icon-text-fit/expected.png differ diff --git a/test/integration/render-tests/text-variable-anchor/icon-text-fit-collision-box/expected.png b/test/integration/render-tests/text-variable-anchor/icon-text-fit-collision-box/expected.png index 8e76c3e2536..deb6c2b27ba 100644 Binary files a/test/integration/render-tests/text-variable-anchor/icon-text-fit-collision-box/expected.png and b/test/integration/render-tests/text-variable-anchor/icon-text-fit-collision-box/expected.png differ diff --git a/test/integration/render-tests/text-variable-anchor/icon-text-fit-collision-box/style.json b/test/integration/render-tests/text-variable-anchor/icon-text-fit-collision-box/style.json index 08b27c445ce..7b9b16d09c8 100644 --- a/test/integration/render-tests/text-variable-anchor/icon-text-fit-collision-box/style.json +++ b/test/integration/render-tests/text-variable-anchor/icon-text-fit-collision-box/style.json @@ -4,6 +4,7 @@ "test": { "height": 128, "width": 128, + "allowed": 0.0075, "collisionDebug": true } }, diff --git a/test/integration/render-tests/text-writing-mode/point_label/cjk-variable-anchors-vertical-horizontal-mode-icon-text-fit/expected.png b/test/integration/render-tests/text-writing-mode/point_label/cjk-variable-anchors-vertical-horizontal-mode-icon-text-fit/expected.png index 46897a3970a..3e3ce112ba2 100644 Binary files a/test/integration/render-tests/text-writing-mode/point_label/cjk-variable-anchors-vertical-horizontal-mode-icon-text-fit/expected.png and b/test/integration/render-tests/text-writing-mode/point_label/cjk-variable-anchors-vertical-horizontal-mode-icon-text-fit/expected.png differ diff --git a/test/integration/render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit/expected.png b/test/integration/render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit/expected.png index e043607d2aa..374bd2ad0a8 100644 Binary files a/test/integration/render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit/expected.png and b/test/integration/render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit/expected.png differ diff --git a/test/integration/render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit/style.json b/test/integration/render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit/style.json index 6721685d90e..b1ac643172f 100644 --- a/test/integration/render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit/style.json +++ b/test/integration/render-tests/text-writing-mode/point_label/mixed-multiline-vertical-horizontal-mode-icon-text-fit/style.json @@ -3,7 +3,8 @@ "metadata": { "test": { "height": 128, - "width": 128 + "width": 128, + "allowed": 0.0005 } }, "center": [ 0, 0 ], diff --git a/test/integration/sprites/icon-text-fit-1x@2x.json b/test/integration/sprites/icon-text-fit-1x@2x.json new file mode 120000 index 00000000000..db5790782a6 --- /dev/null +++ b/test/integration/sprites/icon-text-fit-1x@2x.json @@ -0,0 +1 @@ +icon-text-fit.json \ No newline at end of file diff --git a/test/integration/sprites/icon-text-fit-1x@2x.png b/test/integration/sprites/icon-text-fit-1x@2x.png new file mode 120000 index 00000000000..061acc5577a --- /dev/null +++ b/test/integration/sprites/icon-text-fit-1x@2x.png @@ -0,0 +1 @@ +icon-text-fit.png \ No newline at end of file diff --git a/test/integration/sprites/icon-text-fit-2x.json b/test/integration/sprites/icon-text-fit-2x.json new file mode 120000 index 00000000000..718350fa8a0 --- /dev/null +++ b/test/integration/sprites/icon-text-fit-2x.json @@ -0,0 +1 @@ +icon-text-fit@2x.json \ No newline at end of file diff --git a/test/integration/sprites/icon-text-fit-2x.png b/test/integration/sprites/icon-text-fit-2x.png new file mode 120000 index 00000000000..d551ece5d84 --- /dev/null +++ b/test/integration/sprites/icon-text-fit-2x.png @@ -0,0 +1 @@ +icon-text-fit@2x.png \ No newline at end of file diff --git a/test/integration/sprites/icon-text-fit.json b/test/integration/sprites/icon-text-fit.json index 70f1102ee8e..4668f96c82a 100644 --- a/test/integration/sprites/icon-text-fit.json +++ b/test/integration/sprites/icon-text-fit.json @@ -2,8 +2,24 @@ "label": { "x": 0, "y": 0, - "width": 240, - "height": 60, + "width": 76, + "height": 38, + "pixelRatio": 1, + "sdf": false + }, + "small-box": { + "x": 76, + "y": 0, + "width": 18, + "height": 10, + "pixelRatio": 1, + "sdf": false + }, + "tall-box": { + "x": 76, + "y": 10, + "width": 18, + "height": 28, "pixelRatio": 1, "sdf": false } diff --git a/test/integration/sprites/icon-text-fit.png b/test/integration/sprites/icon-text-fit.png index 167aa2086cf..1d77af78428 100644 Binary files a/test/integration/sprites/icon-text-fit.png and b/test/integration/sprites/icon-text-fit.png differ diff --git a/test/integration/sprites/icon-text-fit.svg b/test/integration/sprites/icon-text-fit.svg index 20f3a90967e..88f78c6cebc 100644 --- a/test/integration/sprites/icon-text-fit.svg +++ b/test/integration/sprites/icon-text-fit.svg @@ -1,14 +1,9 @@ - - - - - - image/svg+xml - - - - - - + + + + + + + diff --git a/test/integration/sprites/icon-text-fit@2x.json b/test/integration/sprites/icon-text-fit@2x.json new file mode 100644 index 00000000000..fb63fa138c9 --- /dev/null +++ b/test/integration/sprites/icon-text-fit@2x.json @@ -0,0 +1,26 @@ +{ + "label": { + "x": 0, + "y": 0, + "width": 152, + "height": 76, + "pixelRatio": 2, + "sdf": false + }, + "small-box": { + "x": 152, + "y": 0, + "width": 36, + "height": 20, + "pixelRatio": 2, + "sdf": false + }, + "tall-box": { + "x": 152, + "y": 20, + "width": 36, + "height": 56, + "pixelRatio": 2, + "sdf": false + } +} diff --git a/test/integration/sprites/icon-text-fit@2x.png b/test/integration/sprites/icon-text-fit@2x.png new file mode 100644 index 00000000000..52bc078f35e Binary files /dev/null and b/test/integration/sprites/icon-text-fit@2x.png differ diff --git a/test/unit/symbol/quads.test.js b/test/unit/symbol/quads.test.js index 380e5f12df0..68dea30b067 100644 --- a/test/unit/symbol/quads.test.js +++ b/test/unit/symbol/quads.test.js @@ -1,283 +1,103 @@ import {test} from '../../util/test'; import {getIconQuads} from '../../../src/symbol/quads'; -import Anchor from '../../../src/symbol/anchor'; -import SymbolStyleLayer from '../../../src/style/style_layer/symbol_style_layer'; - -function createLayer(layer) { - const result = new SymbolStyleLayer(layer); - result.recalculate({zoom: 0, zoomHistory: {}}); - return result; -} - -function createShapedIcon() { - return { - top: -5, - bottom: 6, - left: -7, - right: 8, - image: { - pixelRatio: 1, - paddedRect: {x: 0, y: 0, w: 17, h: 13} - } - }; -} test('getIconQuads', (t) => { - - t.test('point', (t) => { - const anchor = new Anchor(2, 3, 0, undefined); - const layer = createLayer({ - layout: {'icon-rotate': 0} - }); - t.deepEqual(getIconQuads(anchor, createShapedIcon(), layer, false), [ - { - tl: {x: -8, y: -6}, - tr: {x: 9, y: -6}, - bl: {x: -8, y: 7}, - br: {x: 9, y: 7}, - tex: {x: 0, y: 0, w: 17, h: 13}, - writingMode: null, - glyphOffset: [0, 0], - sectionIndex: 0 - }]); - t.end(); - }); - - t.test('line', (t) => { - const anchor = new Anchor(2, 3, 0, 0); - const layer = createLayer({ - layout: {'icon-rotate': 0} - }); - t.deepEqual(getIconQuads(anchor, createShapedIcon(), layer, false), [ - { - tl: {x: -8, y: -6}, - tr: {x: 9, y: -6}, - bl: {x: -8, y: 7}, - br: {x: 9, y: 7}, - tex: {x: 0, y: 0, w: 17, h: 13}, - writingMode: null, - glyphOffset: [0, 0], - sectionIndex: 0 - }]); - t.end(); - }); - t.end(); -}); - -test('getIconQuads text-fit', (t) => { - const anchor = new Anchor(0, 0, 0, undefined); - function createShapedIcon() { - return { - top: -10, - bottom: 10, - left: -10, - right: 10, - image: { - pixelRatio: 1, - paddedRect: {x: 0, y: 0, w: 22, h: 22} - } - }; - } - - function createshapedText() { - return { - top: -10, - bottom: 30, - left: -60, - right: 20 - }; - } - - t.test('icon-text-fit: none', (t) => { - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'icon-text-fit': 'none' - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -11, y: -11}); - t.deepEqual(quads[0].tr, {x: 11, y: -11}); - t.deepEqual(quads[0].bl, {x: -11, y: 11}); - t.deepEqual(quads[0].br, {x: 11, y: 11}); - - t.deepEqual(quads, getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'icon-text-fit': 'none', - 'icon-text-fit-padding': [10, 10] - } - }), false, createshapedText()), 'ignores padding'); - - t.end(); - }); - - t.test('icon-text-fit: width', (t) => { - // - Uses text width - // - Preserves icon height, centers vertically - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 24, - 'icon-text-fit': 'width', - 'icon-text-fit-padding': [ 0, 0, 0, 0 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -60, y: -1}); - t.deepEqual(quads[0].tr, {x: 20, y: -1}); - t.deepEqual(quads[0].bl, {x: -60, y: 21}); - t.deepEqual(quads[0].br, {x: 20, y: 21}); - t.end(); - }); - - t.test('icon-text-fit: width, x textSize', (t) => { - // - Uses text width (adjusted for textSize) - // - Preserves icon height, centers vertically - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 12, - 'icon-text-fit': 'width', - 'icon-text-fit-padding': [ 0, 0, 0, 0 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -30, y: -6}); - t.deepEqual(quads[0].tr, {x: 10, y: -6}); - t.deepEqual(quads[0].bl, {x: -30, y: 16}); - t.deepEqual(quads[0].br, {x: 10, y: 16}); - t.end(); - }); - - t.test('icon-text-fit: width, x textSize, + padding', (t) => { - // - Uses text width (adjusted for textSize) - // - Preserves icon height, centers vertically - // - Applies padding x, padding y - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 12, - 'icon-text-fit': 'width', - 'icon-text-fit-padding': [ 5, 10, 5, 10 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -40, y: -11}); - t.deepEqual(quads[0].tr, {x: 20, y: -11}); - t.deepEqual(quads[0].bl, {x: -40, y: 21}); - t.deepEqual(quads[0].br, {x: 20, y: 21}); - t.end(); - }); - - t.test('icon-text-fit: height', (t) => { - // - Uses text height - // - Preserves icon width, centers horizontally - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 24, - 'icon-text-fit': 'height', - 'icon-text-fit-padding': [ 0, 0, 0, 0 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -31, y: -10}); - t.deepEqual(quads[0].tr, {x: -9, y: -10}); - t.deepEqual(quads[0].bl, {x: -31, y: 30}); - t.deepEqual(quads[0].br, {x: -9, y: 30}); - t.end(); - }); - - t.test('icon-text-fit: height, x textSize', (t) => { - // - Uses text height (adjusted for textSize) - // - Preserves icon width, centers horizontally - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 12, - 'icon-text-fit': 'height', - 'icon-text-fit-padding': [ 0, 0, 0, 0 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -21, y: -5}); - t.deepEqual(quads[0].tr, {x: 1, y: -5}); - t.deepEqual(quads[0].bl, {x: -21, y: 15}); - t.deepEqual(quads[0].br, {x: 1, y: 15}); - t.end(); + const image = Object.freeze({ + pixelRatio: 1, + displaySize: Object.freeze([ 15, 11 ]), + paddedRect: Object.freeze({x: 0, y: 0, w: 17, h: 13}) }); - t.test('icon-text-fit: height, x textSize, + padding', (t) => { - // - Uses text height (adjusted for textSize) - // - Preserves icon width, centers horizontally - // - Applies padding x, padding y - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 12, - 'icon-text-fit': 'height', - 'icon-text-fit-padding': [ 5, 10, 5, 10 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -31, y: -10}); - t.deepEqual(quads[0].tr, {x: 11, y: -10}); - t.deepEqual(quads[0].bl, {x: -31, y: 20}); - t.deepEqual(quads[0].br, {x: 11, y: 20}); - t.end(); - }); - - t.test('icon-text-fit: both', (t) => { - // - Uses text width + height - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 24, - 'icon-text-fit': 'both', - 'icon-text-fit-padding': [ 0, 0, 0, 0 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -60, y: -10}); - t.deepEqual(quads[0].tr, {x: 20, y: -10}); - t.deepEqual(quads[0].bl, {x: -60, y: 30}); - t.deepEqual(quads[0].br, {x: 20, y: 30}); - t.end(); - }); - - t.test('icon-text-fit: both, x textSize', (t) => { - // - Uses text width + height (adjusted for textSize) - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 12, - 'icon-text-fit': 'both', - 'icon-text-fit-padding': [ 0, 0, 0, 0 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -30, y: -5}); - t.deepEqual(quads[0].tr, {x: 10, y: -5}); - t.deepEqual(quads[0].bl, {x: -30, y: 15}); - t.deepEqual(quads[0].br, {x: 10, y: 15}); - t.end(); - }); + t.test('point', (t) => { + t.deepEqual(getIconQuads({ + top: -5.5, + right: 7.5, + bottom: 5.5, + left: -7.5, + image + }, 0), [{ + tl: {x: -8.5, y: -6.5}, + tr: {x: 8.5, y: -6.5}, + bl: {x: -8.5, y: 6.5}, + br: {x: 8.5, y: 6.5}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: null, + glyphOffset: [0, 0], + sectionIndex: 0 + }], 'icon-anchor: center'); + + t.deepEqual(getIconQuads({ + top: -11, + right: 15, + bottom: 11, + left: -15, + image + }, 0), [{ + tl: {x: -17, y: -13}, + tr: {x: 17, y: -13}, + bl: {x: -17, y: 13}, + br: {x: 17, y: 13}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: null, + glyphOffset: [0, 0], + sectionIndex: 0 + }], 'icon-anchor: center icon, icon-scale: 2'); + + t.deepEqual(getIconQuads({ + top: 0, + right: 0, + bottom: 11, + left: -15, + image + }, 0), [{ + tl: {x: -16, y: -1}, + tr: {x: 1, y: -1}, + bl: {x: -16, y: 12}, + br: {x: 1, y: 12}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: null, + glyphOffset: [0, 0], + sectionIndex: 0 + }], 'icon-anchor: top-right'); + + t.deepEqual(getIconQuads({ + top: -5.5, + right: 30, + bottom: 5.5, + left: -30, + image + }, 0), [{ + tl: {x: -34, y: -6.5}, + tr: {x: 34, y: -6.5}, + bl: {x: -34, y: 6.5}, + br: {x: 34, y: 6.5}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: null, + glyphOffset: [0, 0], + sectionIndex: 0 + }], 'icon-text-fit: both'); - t.test('icon-text-fit: both, x textSize, + padding', (t) => { - // - Uses text width + height (adjusted for textSize) - // - Applies padding x, padding y - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 12, - 'icon-text-fit': 'both', - 'icon-text-fit-padding': [ 5, 10, 5, 10 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -40, y: -10}); - t.deepEqual(quads[0].tr, {x: 20, y: -10}); - t.deepEqual(quads[0].bl, {x: -40, y: 20}); - t.deepEqual(quads[0].br, {x: 20, y: 20}); t.end(); }); - t.test('icon-text-fit: both, padding t/r/b/l', (t) => { - // - Uses text width + height (adjusted for textSize) - // - Applies padding t/r/b/l - const quads = getIconQuads(anchor, createShapedIcon(), createLayer({ - layout: { - 'text-size': 12, - 'icon-text-fit': 'both', - 'icon-text-fit-padding': [ 0, 5, 10, 15 ] - } - }), false, createshapedText()); - t.deepEqual(quads[0].tl, {x: -45, y: -5}); - t.deepEqual(quads[0].tr, {x: 15, y: -5}); - t.deepEqual(quads[0].bl, {x: -45, y: 25}); - t.deepEqual(quads[0].br, {x: 15, y: 25}); + t.test('line', (t) => { + t.deepEqual(getIconQuads({ + top: -5.5, + right: 7.5, + bottom: 5.5, + left: -7.5, + image + }, 0), [{ + tl: {x: -8.5, y: -6.5}, + tr: {x: 8.5, y: -6.5}, + bl: {x: -8.5, y: 6.5}, + br: {x: 8.5, y: 6.5}, + tex: {x: 0, y: 0, w: 17, h: 13}, + writingMode: null, + glyphOffset: [0, 0], + sectionIndex: 0 + }]); t.end(); }); - t.end(); }); diff --git a/test/unit/symbol/shaping.test.js b/test/unit/symbol/shaping.test.js index 74ae76791b4..b4dd8ebed10 100644 --- a/test/unit/symbol/shaping.test.js +++ b/test/unit/symbol/shaping.test.js @@ -3,6 +3,7 @@ import fs from 'fs'; import path from 'path'; import * as shaping from '../../../src/symbol/shaping'; import Formatted from '../../../src/style-spec/expression/types/formatted'; +import {ImagePosition} from '../../../src/render/image_atlas'; const WritingMode = shaping.WritingMode; let UPDATE = false; @@ -77,3 +78,213 @@ test('shaping', (t) => { t.end(); }); + +test('shapeIcon', (t) => { + const imagePosition = new ImagePosition({x: 0, y: 0, w: 22, h: 22}, {pixelRatio: 1, version: 1}); + const image = Object.freeze({ + paddedRect: Object.freeze({x: 0, y: 0, w: 22, h: 22}), + pixelRatio: 1, + version: 1 + }); + + t.test('text-anchor: center', (t) => { + t.deepEqual(shaping.shapeIcon(imagePosition, [ 0, 0 ], 'center'), { + top: -10, + bottom: 10, + left: -10, + right: 10, + image + }, 'no offset'); + + t.deepEqual(shaping.shapeIcon(imagePosition, [ 4, 7 ], 'center'), { + top: -3, + bottom: 17, + left: -6, + right: 14, + image + }, 'with offset'); + t.end(); + }); + + t.test('text-anchor: left', (t) => { + t.deepEqual(shaping.shapeIcon(imagePosition, [ 0, 0 ], 'left'), { + top: -10, + bottom: 10, + left: 0, + right: 20, + image + }, 'no offset'); + + t.deepEqual(shaping.shapeIcon(imagePosition, [ 4, 7 ], 'left'), { + top: -3, + bottom: 17, + left: 4, + right: 24, + image + }, 'with offset'); + t.end(); + }); + + t.test('text-anchor: bottom-right', (t) => { + t.deepEqual(shaping.shapeIcon(imagePosition, [ 0, 0 ], 'bottom-right'), { + top: -20, + bottom: 0, + left: -20, + right: 0, + image + }, 'no offset'); + + t.deepEqual(shaping.shapeIcon(imagePosition, [ 4, 7 ], 'bottom-right'), { + top: -13, + bottom: 7, + left: -16, + right: 4, + image + }, 'with offset'); + t.end(); + }); + + t.end(); +}); + +test('fitIconToText', (t) => { + const glyphSize = 24; + const shapedIcon = Object.freeze({ + top: -10, + bottom: 10, + left: -10, + right: 10, + image: Object.freeze({ + pixelRatio: 1, + displaySize: [ 20, 20 ], + paddedRect: Object.freeze({x: 0, y: 0, w: 22, h: 22}) + }) + }); + + const shapedText = Object.freeze({ + top: -10, + bottom: 30, + left: -60, + right: 20 + }); + + t.test('icon-text-fit: width', (t) => { + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [0, 0], 24 / glyphSize), { + image: shapedIcon.image, + top: 0, + right: 20, + bottom: 20, + left: -60 + }, 'preserves icon height, centers vertically'); + + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [3, 7], 24 / glyphSize), { + image: shapedIcon.image, + top: 7, + right: 23, + bottom: 27, + left: -57 + }, 'preserves icon height, centers vertically, applies offset'); + + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [0, 0], 12 / glyphSize), { + image: shapedIcon.image, + top: -5, + right: 10, + bottom: 15, + left: -30 + }, 'preserves icon height, centers vertically, adjusts for textSize'); + + // Ignores padding for top/bottom, since the icon is only stretched to the text's width but not height + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'width', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize), { + image: shapedIcon.image, + top: -5, + right: 20, + bottom: 15, + left: -40 + }, 'preserves icon height, centers vertically, adjusts for textSize, includes padding'); + + t.end(); + }); + + t.test('icon-text-fit: height', (t) => { + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [0, 0], 24 / glyphSize), { + image: shapedIcon.image, + top: -10, + right: -10, + bottom: 30, + left: -30 + }, 'preserves icon width, centers horizontally'); + + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [3, 7], 24 / glyphSize), { + image: shapedIcon.image, + top: -3, + right: -7, + bottom: 37, + left: -27 + }, 'preserves icon width, centers horizontally, applies offset'); + + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [0, 0], 12 / glyphSize), { + image: shapedIcon.image, + top: -5, + right: 0, + bottom: 15, + left: -20 + }, 'preserves icon width, centers horizontally, adjusts for textSize'); + + // Ignores padding for left/right, since the icon is only stretched to the text's height but not width + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'height', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize), { + image: shapedIcon.image, + top: -10, + right: 0, + bottom: 20, + left: -20 + }, 'preserves icon width, centers horizontally, adjusts for textSize, includes padding'); + + t.end(); + }); + + t.test('icon-text-fit: both', (t) => { + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [0, 0], 24 / glyphSize), { + image: shapedIcon.image, + top: -10, + right: 20, + bottom: 30, + left: -60 + }, 'stretches icon to text width and height'); + + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [3, 7], 24 / glyphSize), { + image: shapedIcon.image, + top: -3, + right: 23, + bottom: 37, + left: -57 + }, 'stretches icon to text width and height, applies offset'); + + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [0, 0], 12 / glyphSize), { + image: shapedIcon.image, + top: -5, + right: 10, + bottom: 15, + left: -30 + }, 'stretches icon to text width and height, adjusts for textSize'); + + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize), { + image: shapedIcon.image, + top: -10, + right: 20, + bottom: 20, + left: -40 + }, 'stretches icon to text width and height, adjusts for textSize, includes padding'); + + t.deepEqual(shaping.fitIconToText(shapedIcon, shapedText, 'both', [ 0, 5, 10, 15 ], [0, 0], 12 / glyphSize), { + image: shapedIcon.image, + top: -5, + right: 15, + bottom: 25, + left: -45 + }, 'stretches icon to text width and height, adjusts for textSize, includes padding t/r/b/l'); + + t.end(); + }); + + t.end(); +});