Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load assets relative to executable path #141

Closed
bryphe opened this issue Dec 22, 2018 · 0 comments
Closed

Load assets relative to executable path #141

bryphe opened this issue Dec 22, 2018 · 0 comments

Comments

@bryphe
Copy link
Member

bryphe commented Dec 22, 2018

REPRO:

  • Run esy x Bin.exe

Expected: App should launch.
Actual: Fatal error: exception Fontkit.FontKitLoadFaceException("[ERROR]: Unable to load font at FT_New_Face\n")

The issue is that when we load fonts, or assets like images, we load them from the current working directory. This is problematic, because the user should be able to launch the executable from anywhere.

Because of this limitation - we have to include this awkward instruction in our README.md:

After you build, the executables will be available in the _build\install\default\bin folder.

NOTE: Currently the executables must be run from install\default\bin, since the assets are there.

However, the user should just be able to run via esy x Bin.exe to try out the example app.

Streamlining this would make the first-run experience much smoother, and also unblock #136 .

Some things we need to do:

let getExecutingDirectory = () => {
    Filename.dirname(Sys.argv[0]);
};
  • Update our font loading and asset loading path to use the executingDirectory instead of the current working directory. We'd probably want to handle this in our TextNode and ImageNode classes, or we could handle it lower in the stack (ImageRenderer, FontCache). Append the executing directory + requested asset.

Considerations:

  • We need to make sure this works fine in the JS strategy, too! I think all the logic should be the same if getExecutingDirectory simply returns / (the root) in the JSOO environment.

In the future, we might want to make our asset loading more flexible - some scenarios we'll potentially need to address:

  • Looking for font files in the system font directory
  • Allow custom paths (perhaps an app wants to put all its assets in a different place)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant