From ca8a2cec01a133d6328e730ac9fbdb211f20df10 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Thu, 7 Dec 2023 11:53:52 +0100 Subject: [PATCH] Allow a raw int instead of PointType to be unstructured --- src/fontra/core/classes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fontra/core/classes.py b/src/fontra/core/classes.py index 816248a9c..89cad5320 100644 --- a/src/fontra/core/classes.py +++ b/src/fontra/core/classes.py @@ -219,6 +219,10 @@ def _structurePointType(v, tp): return PointType(v) +def _unstructurePointType(v): + return int(v) + + _cattrsConverter = cattrs.Converter() _cattrsConverter.register_structure_hook(Union[PackedPath, Path], _structurePath) @@ -230,6 +234,7 @@ def _structurePointType(v, tp): _cattrsConverter.register_unstructure_hook(Point, _unstructurePoint) _cattrsConverter.register_structure_hook(bool, lambda x, y: x) _cattrsConverter.register_structure_hook(PointType, _structurePointType) +_cattrsConverter.register_unstructure_hook(PointType, _unstructurePointType) def registerOmitDefaultHook(cls):