pixijs / node

Run PixiJS but in Node.js environments, no browser required!
https://pixijs.com
MIT License
36 stars 5 forks source link

[Bug] Cannot load font from HTTP URL using `Assets.load` #5

Open UlyssesZh opened 1 year ago

UlyssesZh commented 1 year ago
npm i @pixi/node
node -e "require('@pixi/node').Assets.load('https://fastly.jsdelivr.net/gh/dictcp/wangfonts/TrueType/wt071.ttf')"
/home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/loader/Loader.js:93
          throw new Error(`[Loader.load] Failed to load ${url}.
                ^

Error: [Loader.load] Failed to load https://fastly.jsdelivr.net/gh/dictcp/wangfonts/TrueType/wt071.ttf.
Error: ENOENT: no such file or directory, lstat '/home/ulysses/temp/pixi-node-test/https:'
    at /home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/loader/Loader.js:93:17
    at async Promise.all (index 0)
    at async Loader.load (/home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/loader/Loader.js:98:5)
    at async AssetsClass._mapLoadToResolve (/home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/Assets.js:170:26)
    at async AssetsClass.load (/home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/Assets.js:95:17)

Node.js v18.16.0

However, loading from local files is fine:

npm i @pixi/node
wget https://fastly.jsdelivr.net/gh/dictcp/wangfonts/TrueType/wt071.ttf
node -e "require('@pixi/node').Assets.load('wt071.ttf')"

The cause of the bug is because registerFont() can only accept local file paths instead of any HTTP URL.