K
K
Konstantin2011-12-23 13:34:36
css
Konstantin, 2011-12-23 13:34:36

How to know if font loaded from font-face?

Interested in the question, is there any method to find out if the custom font was loaded from font-face?
I need this in order to set separate css rules for the alternative font.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Marsin, 2020-01-16
@Marsin

document.fonts.ready.then(function() {
  //Пишите условие, которое должно выполниться, после загрузки шрифтов...
  //Например текст opacity: 1 (предварительно указав в стилях opacity: 0)
  //Это предотвратит "скакание" шрифта при загрузке страницы.
});

L
LightKeeper, 2011-12-23
@LightKeeper

Using jQuery, you can find out the current properties of an object:
a = $(".someClass").css("font-family");
Result: "Arial, Helvetica, sans-serif"

L
lashtal, 2011-12-23
@lashtal

isn't it
document.defaultView.getComputedStyle($('.answer')[0], null).fontFamily

A
almazmusic, 2011-12-23
@almazmusic

FF has an extension Font Finder and it can show how the font is rendered.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question