diff --git a/resources/testdata/empty-vendorid.ufo/fontinfo.plist b/resources/testdata/empty-vendorid.ufo/fontinfo.plist
new file mode 100644
index 000000000..11511ef57
--- /dev/null
+++ b/resources/testdata/empty-vendorid.ufo/fontinfo.plist
@@ -0,0 +1,75 @@
+
+
+
+
+ unitsPerEm
+ 1000
+ familyName
+ Duck Duck
+ styleName
+ Regular
+ openTypeOS2VendorID
+
+ ascender
+ 737
+ capHeight
+ 702
+ descender
+ -42
+ xHeight
+ 501
+ openTypeOS2TypoAscender
+ 1193
+ openTypeOS2TypoDescender
+ -289
+ openTypeOS2TypoLineGap
+ 42
+ openTypeOS2WinAscent
+ 1325
+ openTypeOS2WinDescent
+ 377
+ openTypeHheaAscender
+ 1194
+ openTypeHheaDescender
+ -290
+ openTypeHheaLineGap
+ 43
+ openTypeOS2WeightClass
+ 800
+ openTypeOS2WidthClass
+ 8
+ openTypeHeadFlags
+
+ 0
+ 3
+
+ openTypeOS2FamilyClass
+
+ 1
+ 2
+
+ openTypeGaspRangeRecords
+
+
+ rangeGaspBehavior
+
+ 1
+ 3
+
+ rangeMaxPPEM
+ 7
+
+
+ rangeGaspBehavior
+
+ 0
+ 1
+ 2
+ 3
+
+ rangeMaxPPEM
+ 65535
+
+
+
+
diff --git a/resources/testdata/empty-vendorid.ufo/glyphs/contents.plist b/resources/testdata/empty-vendorid.ufo/glyphs/contents.plist
new file mode 100644
index 000000000..1607a9e33
--- /dev/null
+++ b/resources/testdata/empty-vendorid.ufo/glyphs/contents.plist
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/resources/testdata/empty-vendorid.ufo/layercontents.plist b/resources/testdata/empty-vendorid.ufo/layercontents.plist
new file mode 100644
index 000000000..b9c1a4f27
--- /dev/null
+++ b/resources/testdata/empty-vendorid.ufo/layercontents.plist
@@ -0,0 +1,10 @@
+
+
+
+
+
+ public.default
+ glyphs
+
+
+
diff --git a/resources/testdata/empty-vendorid.ufo/lib.plist b/resources/testdata/empty-vendorid.ufo/lib.plist
new file mode 100644
index 000000000..dedc4537c
--- /dev/null
+++ b/resources/testdata/empty-vendorid.ufo/lib.plist
@@ -0,0 +1,9 @@
+
+
+
+
+ public.glyphOrder
+
+
+
+
diff --git a/resources/testdata/empty-vendorid.ufo/metainfo.plist b/resources/testdata/empty-vendorid.ufo/metainfo.plist
new file mode 100644
index 000000000..7b8b34ac6
--- /dev/null
+++ b/resources/testdata/empty-vendorid.ufo/metainfo.plist
@@ -0,0 +1,10 @@
+
+
+
+
+ creator
+ com.github.fonttools.ufoLib
+ formatVersion
+ 3
+
+
diff --git a/ufo2fontir/src/source.rs b/ufo2fontir/src/source.rs
index 02c8e9ccd..dbcf667fa 100644
--- a/ufo2fontir/src/source.rs
+++ b/ufo2fontir/src/source.rs
@@ -812,7 +812,13 @@ impl Work for StaticMetadataWork {
)
.map_err(Error::VariationModelError)?;
static_metadata.misc.selection_flags = selection_flags;
- if let Some(vendor_id) = &font_info_at_default.open_type_os2_vendor_id {
+ if let Some(vendor_id) = font_info_at_default
+ .open_type_os2_vendor_id
+ .as_ref()
+ // treat " " (four spaces) as equivalent to no value; it means
+ // 'null', per the spec
+ .filter(|id| *id != " ")
+ {
static_metadata.misc.vendor_id =
Tag::from_str(vendor_id).map_err(|cause| Error::InvalidTag {
raw_tag: vendor_id.to_owned(),
@@ -2317,6 +2323,16 @@ mod tests {
static_metadata.misc.is_fixed_pitch
}
+ #[test]
+ fn allow_four_spaces_for_vendor_id() {
+ let (_, context) = build_static_metadata("empty-vendorid.ufo", default_test_flags());
+ let static_meta = context.static_metadata.get();
+ assert_eq!(
+ static_meta.misc.vendor_id.as_ref(),
+ fontir::ir::DEFAULT_VENDOR_ID.as_bytes()
+ )
+ }
+
#[test]
fn fixed_pitch_on() {
assert_eq!(Some(true), fixed_pitch_of("FixedPitch.designspace"));