From 743e8cdd7e088a71af03ac8293d4ff48ef5b25d6 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Tue, 31 May 2016 00:38:29 +0200 Subject: [PATCH] [TASK] Add canvas font fallback and ensure applied font --- lib/forcegraph.js | 3 ++- lib/map/labelslayer.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/forcegraph.js b/lib/forcegraph.js index ff94495..cb9d05e 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -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"; diff --git a/lib/map/labelslayer.js b/lib/map/labelslayer.js index d54c4af..e525d65 100644 --- a/lib/map/labelslayer.js +++ b/lib/map/labelslayer.js @@ -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");