- From: Cameron McCormack <cam@mcc.id.au>
- Date: Sun, 30 Aug 2015 21:28:32 +1000
- To: Dan Dascalescu <ddascalescu+w3@gmail.com>
- Cc: www-style@w3.org
Dan Dascalescu: > What is the exact format for the "font" parameter to check()? > > https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-check-font-text-font > is links to itself in trying to document the "font" parameter. It is the value that the font shorthand takes; see https://drafts.csswg.org/css-font-loading/#find-the-matching-font-faces which the check() method algorithm links to. > I tried in Chrome to pass a font name, e.g. "Arial", and got the error > "Could not resolve 'Arial' as a font" in Chrome and "An invalid or illegal > string was specified" in Firefox. To the average developer, > document.fonts.check('Arial') looks like a legitimate syntax, yet fails. > "font" should be documented. > > Also, what are the purpose and format of the "text" parameter? Is it to > check if the font face has been loaded for all characters in the "text" > string? I tried > > document.fonts.check('1em Arial', '😸') > > and got "true", even though that character (U+1F638) was rendered as an > empty square in the browser console. The intent of the check() method, as currently written, is to determine (a) whether any font faces that are in the current font face set which match the font shorthand string and the sample text are all loaded, and (b) that there is at least one such font face that matches the arguments. The text parameter is used only to limit the font faces that are checked to those whose unicode-range intersects with at least one of the characters in the text. This means that individual glyph coverage, which is what you are assuming check() does, is not done. check() is returning true here because Arial is found as a platform font, and platform fonts are considered to be already loaded. I think this demonstrates that the check() method is confusingly named. It should be something like needsLoad(). -- Cameron McCormack ≝ http://mcc.id.au/
Received on Sunday, 30 August 2015 11:29:08 UTC