From 62ec914625efed83a3cce3ea198d9ec4e0f734fe Mon Sep 17 00:00:00 2001 From: Dick Marinus Date: Mon, 19 Jun 2017 15:29:02 +0200 Subject: [PATCH] check if the font is fully loaded in safari (and not using question mark boxes) --- src/core/fontwatchrunner.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/fontwatchrunner.js b/src/core/fontwatchrunner.js index 62e91e92..90e3f412 100644 --- a/src/core/fontwatchrunner.js +++ b/src/core/fontwatchrunner.js @@ -170,6 +170,19 @@ goog.scope(function () { this.widthMatches_(b, FontWatchRunner.LastResortFonts.SANS_SERIF); }; + /** + * Returns true if both fonts don't match the Safari invalid font (question mark blocks) width + * + * @private + * @param {number} a + * @param {number} b + * @return {boolean} + */ + FontWatchRunner.prototype.isInvalidFont_ = function (a, b) { + var invalidwidth = 2412; + return invalidwidth == a || invalidwidth == b; + }; + /** * Returns true if the WebKit bug is present and both widths match a last resort font. * @@ -206,7 +219,7 @@ goog.scope(function () { var widthA = this.fontRulerA_.getWidth(); var widthB = this.fontRulerB_.getWidth(); - if (this.isFallbackFont_(widthA, widthB) || this.isLastResortFont_(widthA, widthB)) { + if (this.isFallbackFont_(widthA, widthB) || this.isLastResortFont_(widthA, widthB) || this.isInvalidFont_(widthA, widthB)) { if (this.hasTimedOut_()) { if (this.isLastResortFont_(widthA, widthB) && this.isMetricCompatibleFont_()) { this.finish_(this.activeCallback_);