引入插件
<script src="/fontfaceobserver-master/fontfaceobserver.js"></script>
css引入字体
<style>
@font-face {
font-family:博洋草体二;
src:url('/fonts/art/bycte.ttf') format("truetype");
}
</style>
映入js
function loadFont(font){
//canvas.getActiveObject().set("fontFamily","方正小篆体");
var myfont = new FontFaceObserver(font);
myfont.load()
.then(function() {
// when font is loaded, use it.
canvas.getActiveObject().set("fontFamily", font);
canvas.requestRenderAll();
}).catch(function(e) {
console.log(e);
});
}