versionMinor missing leading zeroes

Hi y’all,

I’m using the DrawBot plugin and am trying to retrieve the version number of the open font.

Let’s say my open font’s version is 0.009. So I run:

open_font = Glyphs.font
font_version = str(open_font.versionMajor) + "." + str(open_font.versionMinor)
print(font_version)

This prints 0.9 when the desired result would be 0.009. Then the next version 0.010 actually reads as 0.10. As you can see, this can become problematic in regards to ordering.

If this is an issue with the Plugin, please let me know and I can file an issue on GitHub instead. Or if I’m writing something wrong, please let me know.

Thanks!

This can be solved with proper string formatting:

open_font = Glyphs.font
versionString = "%i.%03i" % (open_font.versionMajor, open_font.versionMinor)
print(versionString)

Read more about format strings.

1 Like

This is very helpful. Thank you!

1 Like