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

[Issue] Draft.ShapeString generates temp files on Windows #8271

Closed
2 tasks done
WandererFan opened this issue Jan 26, 2023 · 0 comments
Closed
2 tasks done

[Issue] Draft.ShapeString generates temp files on Windows #8271

WandererFan opened this issue Jan 26, 2023 · 0 comments
Labels
Bug This issue or PR is related to a bug OS: Windows

Comments

@WandererFan
Copy link
Contributor

WandererFan commented Jan 26, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Forums discussion

https://www.forum.freecadweb.org/viewtopic.php?f=10&t=75453

Version

0.20 (Release)

Full version info

Applies to all versions.

Subproject(s) affected?

Part

Issue description

If ShapeString is called repeatedly on Windows, temporary font file copies may accumulate in a temporary folder.

The FreeType function FT_New_Face uses fopen internally to read font files. fopen expects ascii c-strings as file names. On Windows, file names are UTF-16. This is currently handled by copying the font file to a temporary file with an ascii file name and passing this file name to FreeType. There is code to delete the temporary files, but the files accumulate in at least some cases.

FreeType's recommendation for dealing with Windows file names is to load the font file into memory and use FT_New_Memory_Face or to write a custom I/O routine and use FT_Open_Face.

From: https://freetype.org/freetype2/docs/reference/ft2-base_interface.html#ft_new_face
"The pathname string should be recognizable as such by a standard fopen call on your system; in particular, this means that pathname must not contain null bytes. If that is not sufficient to address all file name possibilities (for example, to handle wide character file names on Windows in UTF-16 encoding) you might use FT_Open_Face to pass a memory array or a stream object instead."

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
WandererFan added a commit to WandererFan/FreeCAD that referenced this issue Jan 27, 2023
@luzpaz luzpaz added Bug This issue or PR is related to a bug OS: Windows labels Jan 27, 2023
WandererFan added a commit to WandererFan/FreeCAD that referenced this issue Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This issue or PR is related to a bug OS: Windows
Projects
None yet
Development

No branches or pull requests

2 participants