From 8c46f6d1f02220a113c17f1ec0e35785dd53bbfa Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Fri, 20 Oct 2017 01:22:45 +0200 Subject: [PATCH] Workaround for a Safari issue --- src/ol/render/canvas.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ol/render/canvas.js b/src/ol/render/canvas.js index 33b39c2db1..724630d83e 100644 --- a/src/ol/render/canvas.js +++ b/src/ol/render/canvas.js @@ -108,7 +108,7 @@ ol.render.canvas.checkFont = (function() { function isAvailable(fontFamily) { if (!context) { - context = ol.dom.createCanvasContext2D(); + context = ol.dom.createCanvasContext2D(1, 1); context.font = '32px monospace'; referenceWidth = context.measureText(text).width; } @@ -120,6 +120,10 @@ ol.render.canvas.checkFont = (function() { // fallback was used instead of the font we wanted, so the font is not // available. available = width != referenceWidth; + // Setting the font back to a different one works around an issue in + // Safari where subsequent `context.font` assignments with the same font + // will not re-attempt to use a font that is currently loading. + context.font = '32px monospace'; } return available; }