【发布时间】:2013-09-30 22:09:03
【问题描述】:
我尝试将自定义字体加载到 Pixi.js(2D WebGL 框架)中。
他们有一个使用 .woff google 字体的例子:
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;
}
它显示在我的 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;
...
【问题讨论】:
-
会不会是你的行中没有列出来源?喜欢
.woff? -
在 GoodBoy 示例中,他们正在预加载字体,不确定您是否遇到 css 种族问题。尝试设置
{font: "160px HU_Adrien, arial" ...,看看你是否至少得到了文字。
标签: javascript webgl pixi.js