jaywcjlove / svgtofont

Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font.
https://jaywcjlove.github.io/svgtofont
MIT License
520 stars 82 forks source link

Wrong absolute paths #168

Closed mmjvox closed 1 year ago

mmjvox commented 2 years ago

Im using cmake to generate font in build steps, cmake fills the input and output directories. There is no problem with cmake commands, This program (svgtofont) goes wrong with absolute paths.

cmake definitions:

set(SVG_ICONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources/svgFont/svg)
set(FONTICONS_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated_font)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/svgFont/package.json.in ${CMAKE_CURRENT_BINARY_DIR}/package.json)

package.json.in file:

//  /home/.../project/fonts/package.json.in
"scripts": {
    "font": "svgtofont --sources @SVG_ICONS_DIR@ --output @FONTICONS_OUTPUT_DIR@"
  }

generated package.json file:

//   /home/.../project_build/fonts/package.json
"scripts": {
    "font": "svgtofont --sources  /home/.../project/fonts/svg --output  /home/.../project_build/generated_font"
  }

error:

The directory does not exist! /home/.../project_build/home/.../project/fonts/svg

It appends input path to running path ( the result is someting like this /home/.../project_build/home/.../project/fonts/svg)

A real example:

[user1@fedora GUI]$ npm run font

> font
> svgtofont --sources /home/user1/projects/MainApp/plugins/GUI/resources/svgFont/svg --output /home/user1/builds/build-MainApp-Desktop_Qt_5_15_2_GCC_64bit-Debug/plugins/GUI/generated_font

The directory does not exist! /home/user1/builds/build-MainApp-Desktop_Qt_5_15_2_GCC_64bit-Debug/plugins/GUI/home/user1/projects/MainApp/plugins/GUI/resources/svgFont/svg

I even tested it without cmake and it still had this problem.

jaywcjlove commented 2 years ago

@mmjvox The directory does not exist!

mmjvox commented 2 years ago

Of course, it is clear that this directory does not exist. 😁😀 Both of --sources and --output directories are exists. But it is not clear why looks for the wrong path that does not exist

I updated my description.

jaywcjlove commented 2 years ago

I have no way of knowing the reason for your error. @mmjvox

exil commented 1 year ago

I am also running into this issue. I want to supply an absolute path to `--sources``, but when I do, it appends the path to the current working directory.

The code is here: https://github.com/jaywcjlove/svgtofont/blob/51fd8c5b4b3aa1da211e612b36837b31f2bdc19a/src/cli.ts#L28

Here the --sources value is appended to the current directory, which means that it is not possible to give an absolute path to --sources and --output. Is there perhaps a workaround for this?

jaywcjlove commented 1 year ago

@exil Thank you for your explanation, I get it. I fixed it

Upgrade v3.20.0