Permalink
Browse files

Moved the LastResortWebKitFontWatchRunner under the google module bec…

…ause

we now have a special case for fonts that we know are metrics compatible
with default system fonts. This is far from being perfect, but should work
until the WebKit bug is fixed.
  • Loading branch information...
1 parent 70c89ab commit d1fd1549da8a147984f50e926494bc78fa9fd380 @jeremiele jeremiele committed Nov 29, 2011
@@ -122,6 +122,8 @@ LastResortWebKitFontWatchRunnerTest.prototype.testLastResortFontActiveWhenSizeMa
var originalSizeCount = 2;
var firstSize = 2;
+ this.fontFamily_ = "Arimo";
+
var fontWatchRunner = new webfont.LastResortWebKitFontWatchRunner(
this.activeCallback_,
this.inactiveCallback_,
@@ -148,7 +150,7 @@ LastResortWebKitFontWatchRunnerTest.prototype.testLastResortFontActiveWhenSizeMa
assertEquals(1, this.fontActiveCalled_);
assertEquals(0, this.fontInactiveCalled_);
- assertEquals(true, this.fontActive_['fontFamily1 n4']);
+ assertEquals(true, this.fontActive_['Arimo n4']);
};
LastResortWebKitFontWatchRunnerTest.prototype.testLastResortFontInactiveWhenSizeNoMatch
@@ -11,6 +11,12 @@ webfont.LastResortWebKitFontWatchRunner = function(activeCallback,
};
webfont.extendsClass(webfont.FontWatchRunner, webfont.LastResortWebKitFontWatchRunner);
+webfont.LastResortWebKitFontWatchRunner.METRICS_COMPATIBLE_FONTS = {
+ "Arimo": true,
+ "Cousine": true,
+ "Tinos": true
+};
+
/**
* While loading a web font webkit applies a last resort fallback font to the
* element on which the web font is applied.
@@ -19,7 +25,8 @@ webfont.extendsClass(webfont.FontWatchRunner, webfont.LastResortWebKitFontWatchR
* the last resort fallback font is different. This code uses the default
* OS/browsers values.
*/
-webfont.FontWatchRunner.prototype.setUpWebKitLastResortFontSizes_ = function() {
+webfont.LastResortWebKitFontWatchRunner.prototype
+ .setUpWebKitLastResortFontSizes_ = function() {
var lastResortFonts = ["Times New Roman",
"Lucida Sans Unicode", "Courier New", "Tahoma", "Arial",
"Microsoft Sans Serif", "Times", "Lucida Console", "Sans", "Serif",
@@ -50,9 +57,12 @@ webfont.LastResortWebKitFontWatchRunner.prototype.check_ = function() {
// In order to handle the fact that a font could be the same size as the
// default browser font on a webkit browser, mark the font as active
- // after 5 seconds if the latest 2 sizes are in webKitLastResortFontSizes_.
+ // after 5 seconds if the latest 2 sizes are in webKitLastResortFontSizes_
+ // and the font name is known to be metrics compatible.
if (this.webKitLastResortFontSizes_[sizeA]
- && this.webKitLastResortFontSizes_[sizeB]) {
+ && this.webKitLastResortFontSizes_[sizeB] &&
+ webfont.LastResortWebKitFontWatchRunner.METRICS_COMPATIBLE_FONTS[
+ this.fontFamily_]) {
this.finish_(this.activeCallback_);
} else {
this.finish_(this.inactiveCallback_);
View
@@ -7,7 +7,6 @@ core:
- core/fontmoduleloader.js
- core/fontwatcher.js
- core/fontwatchrunner.js
- - core/lastresortwebkitfontwatchrunner.js
- core/font.js
- core/cssclassname.js
- core/cssfontfamilyname.js
@@ -18,6 +17,7 @@ ascender:
- ascender/ascender_script.js
google:
+ - google/lastresortwebkitfontwatchrunner.js
- google/fontapiurlbuilder.js
- google/fontapiparser.js
- google/googlefontapi.js

0 comments on commit d1fd154

Please sign in to comment.