Add ufoz support#407
Conversation
RickyDaMa
left a comment
There was a problem hiding this comment.
I think there are significant improvements that we could implement while everything is in flux. Sorry I don't have the time to offer to help beyond these little reviews 🙏
| #[cfg(feature = "ufoz")] | ||
| if metadata.is_file() { |
There was a problem hiding this comment.
Why are we only checking it's a file, not looking at the extension?
If we were ever to add JSON UFO loading, we're going to clash with this
| impl ZipSource { | ||
| /// Open a zip archive at the given path and load all file entries into memory. | ||
| pub fn open(path: &Path) -> Result<Self, FontLoadError> { |
There was a problem hiding this comment.
Would it be possible to just decompress what we need on the fly, instead of everything at once ahead of time?
If we store the archive in ZipSource instead of the decompressed entries. I guess the issue is that FontSource doesn't let you mutate self currently, but that could be changed or worked around I guess?
| pub(crate) fn detect_zip_root<R: io::Read + io::Seek>( | ||
| archive: &mut zip::ZipArchive<R>, | ||
| ) -> Option<PathBuf> { |
There was a problem hiding this comment.
Alternative impl that doesn't require always traversing the entire archive: pull out the first entry ahead of the loop, get its top-level dir (if it's a fileearly-return None), then run through everything else, immediately returning None if any other path doesn't have that same first component.
5378f30 to
2dee764
Compare
cc1e973 to
5b5ee69
Compare
f4737b9 to
cc6c587
Compare
If passed a file (not a directory) and with the 'ufoz' feature enabled, norad will attempt to treat the file as a zip'd ufo directory.
Add end-to-end integration tests for ufoz loading Verify that loading a UFO from a zip archive via Font::load produces a Font identical to loading the same UFO from a directory, covering the wrapper-dir, __MACOSX, data/images, DataRequest, and error paths.
If passed a file (not a directory) and with the 'ufoz' feature enabled, norad will attempt to treat the file as a zip'd ufo directory.