我尝试将自定义字体加载到Pixi.js(2D WebGL框架)中.
他们有一个使用.woff谷歌字体的例子:
https://github.com/GoodBoyDigital/pixi.js/tree/master/examples/example%2010%20-%20Text
我将.ttf转换为.woff并添加到css中:
@font-face
{
font-family: "HU_Adrien";
src: local('HU_Adrien'), url('HU_A0046.woff') format('woff');;
}
div.font{
font-family: "HU_Adrien";
color: white;
}
Run Code Online (Sandbox Code Playgroud)
它显示在我的div中但不在我的Pixi阶段.
...
// create a text object with a nice stroke
var spinningText = new PIXI.Text("I'm fun!", {font: "160px HU_Adrien", fill: "#cc00ff", align: "center", stroke: "#FFFFFF", strokeThickness: 6});
// setting the anchor point to 0.5 will center align the text... great for spinning!
spinningText.anchor.x = spinningText.anchor.y = 0.5;
spinningText.position.x = 620 / 2;
spinningText.position.y = 400 / 2;
...
Run Code Online (Sandbox Code Playgroud) 我想在结构文本对象中使用自定义字体,我按照以下链接:http: //fabricjs.com/fabric-intro-part-4/
但它似乎只在node.js中受支持.
有没有办法在画布上的简单布料文本对象上支持它?