From c911e684f7e58f6a2987878e49edfce8ee1359c0 Mon Sep 17 00:00:00 2001 From: neocarto Date: Mon, 31 Jan 2022 10:51:03 +0100 Subject: [PATCH] fix: text pos in text.js --- README.md | 2 -- src/text.js | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index d912886..ce4a115 100644 --- a/README.md +++ b/README.md @@ -677,7 +677,6 @@ bertin.draw({ text: "This is my text", position: "bottomright", fontSize: 20, - baseline: "middle", frame_stroke: "red", margin: 4 } @@ -698,7 +697,6 @@ bertin.draw({ - fontStyle: font style. "normal", "italic", "oblique" (default: "normal") - margin: margin around the text (default: 0) - anchor: text anchor. start, middle, end (default: "start") -- baseline: alignment baseline. "baseline", "middle", "hanging" (default:"hanging") - fill: text color (default: "#474342") - stroke: stroke color (default: "none") - frame_fill: frame background color (default:"none") diff --git a/src/text.js b/src/text.js index 066404c..995032f 100644 --- a/src/text.js +++ b/src/text.js @@ -160,8 +160,7 @@ export function addtext(selection, width, height, options = {}){ .data(txt) .join("text") .attr("x", x + margin_x) - //.attr("y", y - +delta + margin_y) // better but don't work with Forefox - .attr("y", y - +delta + margin_y + (fontSize * 3) / 4) // because alignment-baseline not implemented on Firefox + .attr("y", y - margin - delta + margin_y + fontsize) .attr("font-size", `${fontSize}px`) .attr("font-style", fontStyle) .attr("text-decoration", textDecoration) @@ -169,7 +168,6 @@ export function addtext(selection, width, height, options = {}){ .attr("font-family", fontFamily) .attr("dy", (d, i) => i * fontSize) .attr("text-anchor", anchor) - //.attr("alignment-baseline", "hanging") // better but don't work with Forefox .attr("fill", fill) .attr("stroke", stroke) .text((d) => d);