문제

I have a problem with setting a font with a css.

Currently I have:

@font-face {
    font-family: 'myfont';
    font-weight: bold;
    src: url('_layouts/Fonts/myfont.otf') format("opentype");
}

And it does not apply my font to style, but if i change that to:

@font-face {
    font-family: 'myfont';
    font-weight: bold;
    src: url('_layouts/Fonts/testfont.ttf') format("opentype");
}

(even if I left opentype as format), it does work.

Of course in a style i have added:

font-family: 'myfont';

Does anybody know this problem?

도움이 되었습니까?

해결책

you need four versions of the same font (eot, ttf, otf and woff) loading for crossbrowsing optimization. you probably don't see the .otf one because your browser doesn't support it (that's why you need 4).

i suggest you use google fonts, it's easy, quick and it just works: https://www.google.com/fonts

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top