Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if the font is fully loaded in safari (and not using question mark boxes) #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/core/fontwatchrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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_);
Expand Down