W3C home > Mailing lists > Public > www-style@w3.org > January 2015

Re: multiple values for FONT similar to font-family

From: Marat Tanalin <mtanalin@yandex.ru>
Date: Fri, 23 Jan 2015 01:54:23 +0300
To: Tab Atkins Jr. <jackalmage@gmail.com>
Cc: Onur TOPAL <o_topal@yahoo.com>, "www-style@w3.org" <www-style@w3.org>
Message-Id: <3967271421967263@web17g.yandex.ru>
23.01.2015, 01:20, "Tab Atkins Jr." <jackalmage@gmail.com>:
> On Thu, Jan 22, 2015 at 2:17 PM, Marat Tanalin <mtanalin@yandex.ru> wrote:
>> 23.01.2015, 01:02, "Tab Atkins Jr." <jackalmage@gmail.com>:
>>> On Thu, Jan 22, 2015 at 11:40 AM, Marat Tanalin <mtanalin@yandex.ru> wrote:
>>>> What would probably be a real solution is to have in CSS something like Font Loading API in JS:
>>>>
>>>> http://www.w3.org/TR/css-font-loading/
>>> That's called "the @font-face rule".
>> So how exactly the @font-face rule allows to apply different styles depending on what exact font is available and applied?
>
> It doesn't. But @font-face is the CSS version of the Font Loading
> API, *because the Font Loading API is the JS version of @font-face*.

Homo Logicus detected?

In a constructive way, with the Font Loading API in JS, we can do something like this [1]:

    document.fonts.load('1em open_sansregular')
        .then(function() {
            document.documentElement.className += ' open-sans-loaded';
        });

and only apply font-dependent styles if the font is really available.

We can't do that via pure CSS for now.

To achieve a similar goal via pure CSS, we could have a media query like this:

    @media (font-family: open_sansregular) {
        /* Styles applied if `open_sansregular`
           font-family is available. */
    }


[1] https://dev.opera.com/articles/better-font-face/
Received on Thursday, 22 January 2015 22:55:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:51:56 UTC