Repository: unified-font-object/ufoNormalizer

Issue:
xmlConvertFloat() converts 0.99999999999 to "0"
Found in https://github.com/LucasFonts/vfbLib/issues/94

```python
def xmlConvertFloat(value):
    if FLOAT_FORMAT is None:
        string = repr(value)
        if "e" in string:
            string = "%.16f" % value
    else:
        string = FLOAT_FORMAT % value
    if "." in string:
        string = string.rstrip("0")
        if string[-1] == ".":
            return xmlConvertInt(int(value))
    return string
```

The string formatting has rounded the value to `1.0000000000`, then the trailing zeros are stripped, then the last char is "." and then the *int* is taken from the original value, which is still 0.99999999999, so the result is "0".

Discussion:
madig: Random finding: This particular case leaves `xScale="1" yScale="1"` in the files. Separate PR...

Patch:
diff --git a/src/ufonormalizer/__init__.py b/src/ufonormalizer/__init__.py
index ea19087..2c8b5c5 100644
--- a/src/ufonormalizer/__init__.py
+++ b/src/ufonormalizer/__init__.py
@@ -1417,7 +1417,7 @@ def xmlConvertFloat(value):
     if "." in string:
         string = string.rstrip("0")
         if string[-1] == ".":
-            return xmlConvertInt(int(value))
+            return xmlConvertInt(int(string[:-1]))
     return string
 
 


Test patch:
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index bebf1ab..a6d30a9 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -17,7 +17,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        python-version: ['3.6', '3.7', '3.8', '3.9']
+        python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
 
     steps:
     - name: Log reason (manual run only)
diff --git a/tests/test_ufonormalizer.py b/tests/test_ufonormalizer.py
index f242409..b256e9f 100644
--- a/tests/test_ufonormalizer.py
+++ b/tests/test_ufonormalizer.py
@@ -1813,6 +1813,7 @@ class XMLWriterTest(unittest.TestCase):
         self.assertEqual(xmlConvertFloat(1.0000000001), '1.0000000001')
         self.assertEqual(xmlConvertFloat(1.00000000001), '1')
         self.assertEqual(xmlConvertFloat(1.00000000009), '1.0000000001')
+        self.assertEqual(xmlConvertFloat(0.9999999999999999), '1')
 
     def test_xmlConvertFloat_no_rounding(self):
         import ufonormalizer