[TASK] Add canvas font fallback and ensure applied font

This commit is contained in:
Xaver Maierhofer 2016-05-31 00:38:29 +02:00
parent 55fed6538a
commit 743e8cdd7e
2 changed files with 3 additions and 2 deletions

View File

@ -701,11 +701,12 @@ define(["d3", "helper"], function (d3, helper) {
var buffer = document.createElement("canvas");
var r = window.devicePixelRatio;
var bctx = buffer.getContext("2d");
bctx.font = "11px Roboto";
bctx.font = "11px Roboto, sans-serif";
var width = bctx.measureText(name).width;
var scale = zoomBehavior.scaleExtent()[1] * r;
buffer.width = (width + 2 * lineWidth) * scale;
buffer.height = (16 + 2 * lineWidth) * scale;
bctx.font = "11px Roboto, sans-serif";
bctx.scale(scale, scale);
bctx.textBaseline = "middle";
bctx.textAlign = "center";

View File

@ -11,7 +11,7 @@ define(["leaflet", "rbush"],
["center", "ideographic", 2 / 8],
["right", "ideographic", 3 / 8]];
var fontFamily = "Roboto";
var fontFamily = "Roboto, sans-serif";
var nodeRadius = 4;
var ctx = document.createElement("canvas").getContext("2d");