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

Allow insertion markers for autogenerated features #352

Closed
wants to merge 7 commits into from

Conversation

madig
Copy link
Collaborator

@madig madig commented Nov 21, 2019

Tackle #351.

@moyogo moyogo force-pushed the features-insert-markers branch from 56ce482 to b129f52 Compare January 12, 2021 13:42
@google-cla
Copy link

google-cla bot commented Jan 12, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@madig
Copy link
Collaborator Author

madig commented Jan 12, 2021

@googlebot I consent.

@google-cla
Copy link

google-cla bot commented Jan 12, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@madig
Copy link
Collaborator Author

madig commented Jan 13, 2021

@moyogo can't review this until tests pass

@google-cla
Copy link

google-cla bot commented Jan 13, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@moyogo moyogo force-pushed the features-insert-markers branch from 3edd970 to 3952f5f Compare January 13, 2021 22:27
@google-cla
Copy link

google-cla bot commented Jan 13, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@anthrotype
Copy link
Member

@moyogo I think googlebot wants you to say "I consent."

image

@moyogo
Copy link
Collaborator

moyogo commented Jan 14, 2021

@googlebot I consent.

@madig madig marked this pull request as ready for review January 18, 2021 17:25
@madig
Copy link
Collaborator Author

madig commented Jan 18, 2021

LGTM I think 🤔

@anthrotype
Copy link
Member

hold on the merge, i'd like to take a look (tomorrow hopefully)

for _, feature in sorted(features.items()):
feaFile.statements.append(feature)

insertion_tag2index = ufo2ft.featureWriters.findFeatureInsertionMarkers(feaFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only supports "### INSERT ... ###" comments for the MarkFeatureWriter. What about KernFeatureWriter (or future feature writers that we haven't written yet)?
Shouldn't this parsing be done once before all automatic features are generated, instead of at the level of the singular feature writer?
Or maybe even better, instead of the current finding all insertion markers and building a mapping of tag:index, we could move this logic to a method of BaseFeatureWriter which gets called just before compilation from within BaseFeatureWriter.setContext method, and it will store the index of the insertion comment in the self.context namespace for that writer; so no need for a mapping, as the link between the statement index and the feature tag is implicit by the association with the current writer's context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, each feature writer can write multiple feature tags (e.g. "mark", "mkmk", or "kern" and "dist"), so we'd still need to store a mapping from tag to index in the writer's self.context. But each different writer should in theory only be interested in the insertion tags that pertains to it, not all of them. Unless... the placement of class definitions poses a problem (see the other comment https://github.com/googlefonts/ufo2ft/pull/352/files#r560061188)


if insertion_tag2index:
# Write the class definitions at the first feature insertion point,
# no matter what it is.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm I forgot why we need to write class definitions "at the first feature insertion point, no matter what it is"?

This makes the finding-insertion-index logic global as opposed to independent for each writer (I would prefer the latter if possible).

Copy link
Collaborator Author

@madig madig Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because there's no guarantee they're written anywhere before that 🤔 I remember stumbling over this.

@moyogo
Copy link
Collaborator

moyogo commented Feb 19, 2021

Replaced by #458

@moyogo moyogo closed this Feb 19, 2021
@moyogo moyogo deleted the features-insert-markers branch March 26, 2021 14:33
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

Successfully merging this pull request may close these issues.

3 participants