- From: Mike Bremford via GitHub <sysbot+gh@w3.org>
- Date: Thu, 27 Sep 2018 09:15:15 +0000
- To: public-css-archive@w3.org
For what it's worth, we've implemented this locally (with a prefix, naturally) and it's working well. Referencing the steps for font matching outlined at https://drafts.csswg.org/css-fonts/#font-style-matching, we have effectively added a step before 5a which is "sort the remaining fonts first by how well they match the element's language, based on BCP47, and secondly on the order they're defined in CSS". So for example: you have three matching fonts with languages of "zh-hant", "zh" and no language. If the font is requested by an element with a language of "zh-hans", it will match "zh". If the element language is "en", all of the fonts have equal priority based on the language match so are prioritised by the order they're defined in CSS, exactly as they are in the current spec. This approach is backwards compatible: with no languages on the @font-face rule, the matching algorithm runs as it is now. And, if a language is defined, it won't prevent it from matching an element with a different language: it will only change the priority they're matched on. I have one more argument in favour of this. In the PDF world where we're coming from, every font has to be embedded. So as well as time taken to download the font and better language-specific shapes for the glyphs, we need this to reduce the size of the final document. For example: ``` @font-face { font-family: Noto; src: url(NotoSerifCJKzh-Regular.otf); lang: "zh" } @font-face { font-family: Noto; src: url(NotoSerifCJKjp-Regular.otf); lang: "ja" } <p lang="ja">日本の字</p> ``` Without language matching (and presuming Noto Chinese has no hiragana glyphs for the sake of example), we'd embed two fonts: the first two glyphs would match the Chinese fonts as it has a higher priority, with the third matching the Japanese font. -- GitHub Notification of comment by faceless2 Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1744#issuecomment-425019436 using your GitHub account
Received on Thursday, 27 September 2018 09:15:22 UTC