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

[ufowrite] setVersionMajor function does not handle leading zero correctly #1769

Open
tamcy opened this issue Dec 5, 2024 · 0 comments
Open

Comments

@tamcy
Copy link

tamcy commented Dec 5, 2024

The setVersionMajor function in ufowrite.c is supposed to copy the major version number from a version string to a destination string, skipping leading zeros. However, when the major version is zero (e.g. 0.500), nothing will be copied and the destination string (dst) ends up being empty.

I encountered the issue that causes an empty value (nothing) being written to the versionMajor property of fontinfo.plist when exporting to ufo format with tx, which isn't valid:

	<key>versionMajor</key>
	<integer></integer>

I believe it could be fixed by something like this: tamcy@a36fc9e

diff --git "a/c/shared/source/ufowrite/ufowrite.c" "b/c/shared/source/ufowrite/ufowrite.c"
index 64ee9e63..3703837a 100644
--- "a/c/shared/source/ufowrite/ufowrite.c"
+++ "b/c/shared/source/ufowrite/ufowrite.c"
@@ -875,6 +875,8 @@ static void setVersionMajor(char *dst, char *version) {
             seenNonZero = 1;
         }
     }
+    if (!seenNonZero)
+        *dst++ = '0';
     *dst = 0x00;
 }

Indeed this is what is happening in setVersionMinor. I am not familar with this repo good enough to contribute a test case so I'm not submitting a pull request.

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