node icon indicating copy to clipboard operation
node copied to clipboard

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

Open UlyssesZh opened this issue 2 years ago • 0 comments

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.

UlyssesZh avatar Jul 26 '23 22:07 UlyssesZh