Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate UFO source format diffs across commonly used UFO serializers #4

Open
chrissimpkins opened this issue Jul 23, 2021 · 22 comments

Comments

@chrissimpkins
Copy link
Member

No description provided.

@chrissimpkins
Copy link
Member Author

@chrissimpkins
Copy link
Member Author

Norad v0.4.0 chrissimpkins/ufo-format-diff#1

@chrissimpkins
Copy link
Member Author

ufonormalizer v0.5.4 chrissimpkins/ufo-format-diff#3

@chrissimpkins
Copy link
Member Author

ufoLib2 v0.11.1 chrissimpkins/ufo-format-diff#5

@chrissimpkins
Copy link
Member Author

norad v0.4.0 after ufonormalizer v0.5.4 (shows diff between ufofmt/norad and ufonormalizer formatted sources)

chrissimpkins/ufo-format-diff#7

@chrissimpkins
Copy link
Member Author

defcon v0.8.1 chrissimpkins/ufo-format-diff#9

@cmyr
Copy link
Collaborator

cmyr commented Jul 29, 2021

So... funny question. What is the expected behaviour around line endings? Should the tool use the appropriate line ending for the current target platform, or should it (say) always use unix-style line endings?

This has come up because I noticed that one of the test files in norad, sample_period_normalized.glif, has windows-style line endings. I believe this file was created using by @madig, using ufonormalizeron windows.

If this is a convention we are expected to respect, things will be slightly more complicated...

@chrissimpkins
Copy link
Member Author

chrissimpkins commented Jul 29, 2021

Good question. I didn't notice that. IMO it would be best to stick with a single approach that does not introduce a platform-specific diff with norad writes on different platforms. I think that Win and *nix users of Runebender would appreciate that in collaborative projects. This seems to make sense for cross-platform UFO formatting with an autoformatter on sources created by other tools too.

@madig @belluzj @anthrotype do you know if ufonormalizer writes platform-specific line endings? If so, is this intentional/desirable? A bug?

@chrissimpkins
Copy link
Member Author

chrissimpkins commented Jul 29, 2021

It looks like the intent may be to write with unix style newline char everywhere?

https://github.com/unified-font-object/ufoNormalizer/blob/186dbc1f49962c7147ac09fc7d91725734f5ff4b/src/ufonormalizer/__init__.py#L1586-L1589

@cmyr
Copy link
Collaborator

cmyr commented Jul 29, 2021

Okay, there may have been something else going on in that test file, I'm not sure of its full origin story.

@madig
Copy link
Collaborator

madig commented Jul 29, 2021

It does indeed enforce Unix line endings.

@chrissimpkins
Copy link
Member Author

fonttools/fonttools#2383

@cmyr
Copy link
Collaborator

cmyr commented Jul 30, 2021

I am irrationally annoyed about another behaviour of ufonormalizer: it modifies whitespace to in the <note> field, which is a destructive operation; e.g. if you have some valid python code in a note for a glyph, ufonormalizer will helpfully fix it for you.

@cmyr
Copy link
Collaborator

cmyr commented Jul 30, 2021

I've opened an issue there (unified-font-object/ufoNormalizer#84) to see if there's something here that I'm overlooking.

@chrissimpkins
Copy link
Member Author

chrissimpkins commented Jul 30, 2021

Are you explicitly trimming those <note> field strings in norad? Or is this automated by your lib dependencies?

@cmyr
Copy link
Collaborator

cmyr commented Jul 30, 2021

I'm not sure I understand. Norad (currently) serializes the contents of notes directly, and does not modify whitespace at all; we have a commented out test that compares against the output of ufonormalizer, and there I noticed that ufonormalizer was adding whitespace.

@chrissimpkins
Copy link
Member Author

IMO the trimmed format is an improvement in the above example note. But I think that Colin makes a good point that there may be formatting requirements that should be preserved in freeform notes included by designers. I haven't come across any note use in the past to judge what designers put in there. What have you seen that section used to document Niko?

@madig
Copy link
Collaborator

madig commented Jul 30, 2021

I have only ever seen garbage in there or one-line comments.

@cmyr
Copy link
Collaborator

cmyr commented Jul 30, 2021

Yea, I don't think this matters a ton in practice but I just think it's bad form to go about inserting and deleting stuff that has been input by the user. changing leading/trailing whitespace is maybe-annoying-but-mostly-probably-fine, but inserting or removing whitespace in the middle of the text just feels wrong.

@madig
Copy link
Collaborator

madig commented Jul 30, 2021

Yeah, I also don't like changing anything other than trimming start and ending. The XML format is, uh, weird about this, though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants