Hi,
I’m using Phaser3 with WebPack and I’m trying write with custom font with this.add.text().
- Add CSS style @font-face for loading custom font
@font-face {
font-family: "Pixel Operator 8";
src:
url("fonts/pixel-operator-8.woff2") format("woff2"),
url("fonts/pixel-operator-8.woff") format("woff"),
url("fonts/pixel-operator-8.ttf") format("truetype");
font-weight: bold;
font-style: normal;
}
-
Import CSS from JS with
import "./assets/styles.css"
(with css-loader & style-loader with webpack). -
Try write in Phaser3:
[...]
create() {
this.make.text({
x: 40,
y: 440,
text: "This is a example",
style: {
font: "18px 'Pixel Operator 8'",
color: "#ffffff"
}
});
}
If I write a <span></span>
with text in my index.html, appears correctly (I understand that custom font is loaded OK), but in Phaser3 appears with normal font.
Some help?