Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
jeremiele committed Nov 29, 2011
1 parent 70c89ab commit d1fd154
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Expand Up @@ -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_,
Expand All @@ -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
Expand Down
Expand Up @@ -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.
Expand All @@ -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",
Expand Down Expand Up @@ -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_);
Expand Down
2 changes: 1 addition & 1 deletion src/modules.yml
Expand Up @@ -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
Expand All @@ -18,6 +17,7 @@ ascender:
- ascender/ascender_script.js

google:
- google/lastresortwebkitfontwatchrunner.js
- google/fontapiurlbuilder.js
- google/fontapiparser.js
- google/googlefontapi.js
Expand Down

0 comments on commit d1fd154

Please sign in to comment.