soimy / msdf-bmfont-xml

Generate BMFont texture and spec XML using msdfgen

Home Page:https://soimy.github.io/msdf-bmfont-xml/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Run from electron

Apidcloud opened this issue · comments

Good evening!

I have no problems using this package from node, but I wonder if there a good way to make this run from electron?

The following error is raised when I attempt to do so:
Uncaught Error: A dynamic link library (DLL) initialization routine failed.

Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\D:\Workspace\GitHub\_Scarlett\scarlett-editor\node_modules\canvas-prebuilt\canvas\build\Release\canvas.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\Workspace\GitHub\_Scarlett\scarlett-editor\node_modules\canvas-prebuilt\canvas\lib\bindings.js:3:18)
    at Object.<anonymous> (D:\Workspace\GitHub\_Scarlett\scarlett-editor\node_modules\canvas-prebuilt\canvas\lib\bindings.js:5:3)

I tried to run electron-rebuild on it, but it still happens.
I wonder if I would need a specific build from canvas-prebuilt.
Any ideas?

Also opened an issue on canvas-prebuilt itself: node-gfx/node-canvas-prebuilt#30

I'll try to build it targeting node 7.9 and use it in this package.

Edit: no luck thus far.

Haven't tried this on electron yet. Maybe it relates to path canvas-prebuild loading local dynamic libraries. Why not search a solution in electron community?

msdf-bmfont-xml is designed as a back-end program. If you decide to use it as front-end, it's better to substitute node-canvas to DOM canvas or WebGL framework like Pixi.js. They are used to render glyphs to final atlas, nothing more.

I think it’s because electron uses a different node version within (1.7.11 uses 7.9), so node canvas has to be built targeting that version instead. I’ve opened an issue in that repository as well, to check whether that’s possible. I’ll keep you updated :) thanks!

Good news! It does seem to work under electron when targeting it (e.g., 1.7.11). See node-gfx/node-canvas-prebuilt#30 for the discussion.

If the author is able to release a version with said target, could you do the same?

For now, I rebuilt node-canvas-prebuilt inside a clone of this package (in its node_modules), and then linked it to a project that consumes it under electron.

Thanks! 💯

Good to hear that! Let me know the news from canvas-prebuilt and I'll update accordingly.

BTW: I'm planning to replace node-canvas and opentype.js to some more light-weighted dependencies in the near future.

Thanks!

Still got no news from canvas-prebuilt, but I'm curious about replacing those libraries. Anything in mind yet?

Edit: I know https://github.com/nascherman/opentype-bmfont (see nascherman/opentype-bmfont#4 though) but it still uses opentype.js under the hood. The generation is accomplished through text-to-svg and svg-to-image.

Haven't got time on this yet, but my plan is replace node-canvas with node-pngjs on back-end, or pixi.js on front-end. opentype.js to more light-weight typr.js on runtime-parser or fontkit maybe.

Still no answer from canvas-prebuilt. Can we release an electron version ourselves for the time being?

@Apidcloud Recent update replaced canvas-prebuilt with jimp, let me know if this update has any luck solving your problem.

Meanwhile I got it working by publishing my own builds of canvas.

But using jimp seems simpler. I will try to test it soon!

Edit:
Seems to work 💯 I had no problems with the new version!

It showed the following, though (I guess it makes sense):
Use font-face as filename : arialbd
Generating 0%|░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░| (0/95) 0s
Warning: no bitmap for character ' ' (32), adding to font as empty
Generation complete!

Ah. Still regarding that message, the bar doesn't really go further (from 0% to 100%) despite actually working.

Ah, that's absolutely normal. space does not have any glyph so a blank bitmap warning is given. The progress bar just shows that the warning is triggered at 0/95. Just ignore it.

Fixed the progress bar info above warning message via fa5e9a9
Since it's minor fix, will merge to master in next release.