简体   繁体   中英

Custom font not working in canvas

I am using Bootstrap 3. I added this to my custom css:

@font-face {
    font-family: 'My font';
    src: url('../fonts/myfont.ttf') format('ttf');
}

myfont.tff is a custom font.

Then I try to use this font in a canvas:

context.font = '40pt My font';

But another font is displayed. What am I doing wrong?

src: url('../fonts/myfont.ttf')  format('truetype');

Usage:

body {
font-family: 'MyFontFamily', myfont;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM