P
P
Pavel Antonov2017-02-07 17:28:59
JavaScript
Pavel Antonov, 2017-02-07 17:28:59

Is it possible to get font name from ttf file using javascript?

For example, the font Exo2-Regular is connected on the page

@font-face { 
    font-family: 'Exo2-Regular';
    src: url('fonts/Exo2-Regular/Exo2-Regular.eot');
    src: url('fonts/Exo2-Regular/Exo2-Regular.eot') format('embedded-opentype'),
         url('fonts/Exo2-Regular/Exo2-Regular.woff') format('woff'),
         url('fonts/Exo2-Regular/Exo2-Regular.woff2') format('woff2'),
         url('fonts/Exo2-Regular/Exo2-Regular.ttf') format('truetype'); 
    font-weight: normal;
    font-style: normal;
}

Is there any library with which we can display the name of the font connected to the page?
At first there was an idea to take the name of the font from the name of the file, but the file can be called anything, I need to display the real name of the font. Is it even possible? Maybe not js but php can do it? This will not work, because you can also write anything in font-family, it is the ability to snatch the name directly from the included files that interests you.
var fontFamily = $(this).css('font-family');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tsimur_S, 2017-02-07
@freislot

opentype.js.org/font-inspector.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question