W3C home > Mailing lists > Public > www-style@w3.org > April 2016

Re: [css-font-loading] load, check and testing for character coverage

From: Arthur Stolyar <nekr.fabula@gmail.com>
Date: Fri, 1 Apr 2016 10:41:54 +0300
Message-ID: <CAPAD5+Cx+SkkJoiEz_ZkgVXzh7sTEWsZmMDx64roRmGwGizTeg@mail.gmail.com>
To: www-style list <www-style@w3.org>, mmaxfield@apple.com, "Tab Atkins Jr." <jackalmage@gmail.com>

While I agree that check() shouldn't throw any errors, I am not sure why it
needs to return true.

Right now, this method is called just `check()` and this is really
confusing what it checks. For me, as web developer, 'check font' always
meant 'check if font is available to use, if not, load from network' and
this is what I expect from this method. But clearly now, it turns out to be
wrong assumption. This is how many web dev would treat this method:

var myFont = '16px MyFont';
var testText = '∂ƒß';

var hasFont = document.fonts.check(myFont);
var hasFontForGivenUnicodeRange = document.fonts.check(myFont, testTest);
// just check agains @font-face's unicode-range

if (!hasFont) {
  var face = new FontFace('MyFont', 'url(latin font)');
  face.load().then(() => document.fonts.add(face));

if (!hasFontForGivenUnicodeRange) {
  var face = new FontFace('MyFont', 'url(special chars font)');
  face.load().then(() => document.fonts.add(face));

So this algorithm is now useless. And yes, it's expected by check() to
return `false` if browser has that font and @font-face's unicode-range
doesn't have those symbols specified in it.

I understand that this could be achieved someway like this:
var face = new FontFace('MyFont', 'url(latin font)');

document.fonts.load(myFont[, testText]);

But this is a bit weird, especially when you need to load few different
files for the same font family.

@nekrtemplar <https://twitter.com/nekrtemplar>
Received on Friday, 1 April 2016 07:42:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:02 UTC