-
Notifications
You must be signed in to change notification settings - Fork 43
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
Support FeatureWriter insert mode #351
Comments
i prefer "insert" mode, it's more general. I know Glyphs.app does something similar. We need to find out what special strings it uses and do the same |
So, Glyphs.app uses a special comment https://forum.glyphsapp.com/t/how-to-insert-a-lookup-feature-after-generated-mark-feature/12891/4 Perhaps also an The special comment needs to be inside the block of the feature where one wants to insert the auto-generated lookups. |
This feature was added in https://glyphsapp.com/blog/glyphs-2-4-2-released The changelog says "either start it with this comment line: I wonder what happens if both End and Start comments are used and there's manual code before and after the automatic one, whether that's supported or not.. |
I just had a look at the code. It seems that the position of the comment is not important. And if you have both, your code will be added twice. I would need to test this more. |
Can we maybe do something like
instead of Start/End? This would represent a singular insertion point for automatic feature code. Think e.g. putting Also, I don't understand how the current system works. Is the above equivalent to
? |
only one of I think in ufo2ft we should support the existing Start/End special comments. We could also add a new one I agree the name "Insert" makes more sense and is more general, as it allows to put manual code before and after. |
There is one thing you need to pay attention. When the automatic and manual code contains several script tags, at least makeOTF doesn't like it. It will fail with a "Script was set before" error. I split up the manual code and insert it with the automatic code to group the script. Later I learned that makeOTF allows duplicate features. That makes it much easier to combine code. |
So, if we were to implement this today, the following:
would translate to: kern {
# genetated stuff
} kern;
# Automatic Code End
kern {
pos A B -50;
} kern; And vice versa? |
That looks good |
FontLab uses |
This should be standardized in some way in FEA syntax. |
I think there is still some expectation that the makeOTF lib would have to support everything that the FEA syntax describes (even though it's actually not the case). We have two more implementations (FontForge and feaLib), and at least one of them could be extended to support more aspects of the syntax, but since the work on the makeOTF compiler has been very slow, adoption of syntax extensions has also stalled. There is https://github.com/adobe-type-tools/afdko/labels/fea%20syntax%20extension and there is https://github.com/silnrsi/pysilfont/blob/master/docs/feaextensions.md We could propose that FEAX (SIL’s FEA extensions) could become the new syntax. This is basically a bit like LaTeX and TeX. And standardize it there first. |
TBH, i don't like either of the two existing syntaxes from Glyphs.app and FontLab, and I prefer the one @madig proposed in #352. This is a single line comment (instead of two) that clearly means "INSERT". It is placed at the top level outside any feature blocks, and bears the tag of the automatic feature it is supposed to be replaced with, so it's very simple to match and replace with the automatic feature statements. A feature writer may need to define standalone lookups and register them under specific scripts and language systems. So it needs to define separate feature blocks, can't reuse the user-defined one. It makes more sense to write these placeholder comments outside the feature blocks. The user could then define her own manual feature blocks before and/or after the automatic one. E.g.:
I think glyphsLib could be modified to convert between the Glyphs.app's notation to the one @madig proposed. From:
To:
|
@twardoch: What we are speaking about here is more a preprocessor functionality. So the feature compiler is not really involved with this. @anthrotype You are right. Two comments are not needed. The handling in Glyphs is slightly different. The code as seen by the use never has the |
I like the start and end comment because you can keep them in the final code, and the end-user always knows that has been inserted. That’s why FontLab 7 has these double indicators. Anything inside those special comments will be replaced, but as the end-user, you see what’s been inserted. And that’s important, because you may want to base your decisions as to what to add manually depending on what the preprocessor has added. |
I'm not sure how much exactly this is part of the same problem, but I have a case where I'd like to add custom mark code that refers to some of the autogenerated markClass'es. Even if I can insert into the mark or kern feature with what you discuss above, this type of code would still not be possible, unless there is syntax to pre-insert the location of the yet to be generate markClass statements as well. Did ufo2ft have an option to explicitly write out the mark and kern code before compile to manually operate on those kinds of additions after the generated markClass statements are added the feature code? |
I thought about this again, and I believe it's better that we don't invent yet another feature insertion method. I propose that ufo2ft use the one from FontLab 7 (see @twardoch's #351 (comment) above). |
this is actually nice, and we should do the same. |
I Glyphs 3 the procedure is much easier: There is only a Depending Where you put the comment, the custom feature will be placed before or after the automatic one. Example 1custom
results in a final .fea file:
Example 2
result:
Putting the code in individual feature blocks makes it much easier to deal with script and language settings. (edited it after @moyogo comment below) |
@schriftgestalt If I'm not mistaken, the result in your example 1 has the wrong order, the automatic code comes first in the result as in the code. That’s what I see when I test Glyphs3. |
Right, of cause. I fix it in the above example. I copied the wrong version of the code. |
How does the comment know whether to insert kern or mkmk or something else? |
The comment and the code is inside a feature object that has the |
Hm. I think we need to be able to insert outside feature blocks as well. |
Do you have an example? |
Fixed by #458 |
I don’t think this is fixed. Glyphs 2 does not support
|
If the feature code is from Glyphs 2 (and contains the |
Split the feature block into two and insert the generated code in the middle. See #351 (comment)
Split the feature block into two and insert the generated code in the middle. See #351 (comment)
Situation: Noto Syriac contains hand-written feature files to define contextual kerning. Ideally, the
mark
andmkmk
features are autogenerated, but they can currently only beappend
ed to the preexisting feature file. The problem: the font requires thatmark
andmkmk
are processed beforekern
, which is currently not possible and means that the feature have to be manually generated and hardcoded into the features. This is a waste of effort.Maybe a FeatureWriter
prepend
mode could look for a human-placed placeholder string in the written feature file to insert the autogenerated features.The text was updated successfully, but these errors were encountered: