From f069ef5968de0073f7f3d95627c30f42c912859e Mon Sep 17 00:00:00 2001 From: Fred Brennan Date: Tue, 16 Aug 2022 05:46:04 -0400 Subject: [PATCH] Passthrough `lxml.etree.CDATA` elements (closes #2745) Unblocks MFEK/sfdLib.py#15. --- Lib/fontTools/ufoLib/glifLib.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/fontTools/ufoLib/glifLib.py b/Lib/fontTools/ufoLib/glifLib.py index 7d28eaf734f..a986ce7a99e 100755 --- a/Lib/fontTools/ufoLib/glifLib.py +++ b/Lib/fontTools/ufoLib/glifLib.py @@ -849,10 +849,11 @@ def _writeUnicodes(glyphObject, element, validate): def _writeNote(glyphObject, element, validate): note = getattr(glyphObject, "note", None) - if validate and not isinstance(note, str): - raise GlifLibError("note attribute must be str") - note = note.strip() - note = "\n" + note + "\n" + if (note.__class__.__name__, note.__class__.__module__) != ("CDATA", "lxml.etree"): + if validate and not isinstance(note, str): + raise GlifLibError("note attribute must be str") + note = note.strip() + note = "\n" + note + "\n" etree.SubElement(element, "note").text = note def _writeImage(glyphObject, element, validate):