u/Hamurapa

▲ 14 r/phaser

Phaser 3 has no global font setting — and other things I only learned by shipping

Been building a card duel game in Phaser 3.80 + TypeScript (esbuild, no tsc in the build), and the two things that cost me the most evenings were both Text. Phaser hardcodes 'Courier' as the default font and exposes no game-level config for it, so the only sane seam is patching TextStyle.prototype.setStyle to inject fontFamily when a call site doesn't pass one — plus awaiting the woff2 before boot, since Phaser bakes a label into a canvas texture once and anything drawn early stays in the fallback face forever (looks fine on your machine, broken on a cold cache). And Text.letterSpacing is quietly broken for stroked text: it strokes the whole line in one call, then fills letter by letter at spaced offsets, so the outline drifts further behind with every character — and it split('')s, tearing surrogate-pair emoji in half. Setting the canvas 2D context's native letterSpacing instead fixes both, but it has to ride syncFont, not updateText — a label that grows assigns canvas.width, which resets the whole context.

The other decision I'd make earlier next time: keep all the game rules Phaser-free — pure modules over one plain state object, no GameObject anywhere near them. That got me a headless balance sim (5000 AI-vs-AI matches through the real rules, printing a report) and lockstep netcode where only moves cross the wire, both for basically free. If you're thinking about multiplayer later, that split is the thing to do now.

Browser build if anyone wants to poke at it: https://valeriitsarov.github.io/solitaire-duelist-2d/ — happy to go into detail on any of it.

u/Hamurapa — 10 days ago