-
Notifications
You must be signed in to change notification settings - Fork 94
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
How to have mark/m2mk features from Glyphs source? #682
Comments
This is for kerning, same also works for mark feature: |
Thank you. I'd prefer to use it from the command line. Would this be the correct way to write both Another question, as you seem to have done this before ;): In the feature code produced by |
I can only answer the second one. It works for me without any special setup except I have a script that I use to propagate anchors in composites from thei base glyphs. Have you checked that in your feature file, the glyphs are being decomposed in |
@yanone the feature is on automatically, you don't have to pass any
you said your "GDEF table correctly defines the marks in question" -- is that shadda_fatha-ar glyph also classified as a mark in your GDEF? If a GDEF table definition is present in the UFO features.fea, ufo2ft markFeatureWriter will use that to classify bases/marks/ligatures. When compiling from .glyphs source, the GDEF table classes of the master UFOs are autogenerated using the GlyphInfo.xml database that glyphsLib comes with. Sometimes (e.g. if using custom glyph names not present in GlyphInfo.xml) you may have to set category and sub-category yourself for specific glyphs from within Glyphs.app (CMD+CTRL+I shortcut to view Glyph Info panel for selected glyph). |
Yes, So my only guess is that because it doesn’t have its own anchors, but is composed of two components only is is custom in Glyphs.app, that Writing a script that propagates anchors will work, but is a crutch. This feels worth looking into. I'll look into the code and report what I find. |
Yes, it might be the different way glyphsLib and Glyhps.app do the anchor propagation. Georg sent me a snippet of code regartding that but have to find time to integrate that into glyphsLib. I found out that Glyphs.app Python scripting API has a method to traverse all the anchors for a composite glyph, you can use that to propagate the anchors: for glyph in Glyphs.font.glyphs:
for layer in layers:
if not layer.components:
continue
layer.anchors = list(layer.anchorsTraversingComponents()) Let me know if that fixes the problem, thanks. |
The snippet works fine, but I really don't want to do that. The whole point is to not have to have anchors in component glyphs. It kind of breaks the source imo, as anchors can move and then knowledge of these propagated anchors needs to exist to not make mistakes.
If you feel like it, I could do it; I already found So I would be happy to implement it. |
thanks for the offer. that's my literal python port: |
Ideallly this should not be done in the markFeatureWriter itself, but in glyphsLib -- or perhpas in the propagateAnchors filter in ufo2ft so UFO-based workflow could take advantate of it as well (if we deem it not too Glyphs-app specific) |
related issues: |
I know this is not what we discussed, but I've gotten the intended results by having def _getAnchorLists(self):
gdefClasses = self.context.gdefClasses
if gdefClasses.base is not None:
# only include the glyphs listed in the GDEF.GlyphClassDef groups
include = gdefClasses.base | gdefClasses.ligature | gdefClasses.mark
else:
# no GDEF table defined in feature file, include all glyphs
include = None
result = OrderedDict()
_orderedGlyphSet = self.getOrderedGlyphSet()
propagateAnchors = PropagateAnchorsFilter()
propagateAnchors.set_context(self.context.font, _orderedGlyphSet)
for glyphName, glyph in _orderedGlyphSet.items():
if include is not None and glyphName not in include:
continue
anchorDict = OrderedDict()
if glyph.components and not glyph.anchors:
propagateAnchors.filter(glyph)
for anchor in glyph.anchors:
anchorName = anchor.name
if not anchorName:
self.log.warning(
"unnamed anchor discarded in glyph '%s'", glyphName
)
continue
if anchorName in anchorDict:
self.log.warning(
"duplicate anchor '%s' in glyph '%s'", anchorName, glyphName
)
a = self.NamedAnchor(name=anchorName, x=anchor.x, y=anchor.y)
anchorDict[anchorName] = a
if anchorDict:
result[glyphName] = list(anchorDict.values())
return result I know that the way I create the filter, or rather set the context, is quirky, because I don't fully understand |
Okay, it's not that simple: I found a case where the anchors are propagated incorrectly by I’ll look into it further now by actually trying to make Georg’s code work. |
Done: googlefonts/glyphsLib#617 This PR is addressing two separate issues of anchor propagation: A) marks that are in turn composed of other marks (e.g. The solution to A) was already developed in The solution to B) is to check for marks attached to named anchors (stored in Please note that while the solution to A) is now in sync between |
(Note that we are sitting on the original Glyphs anchor propagation code Georg gave us and I think @anthrotype even implemented something in Python, but there was something I can't remember stopping us from integrating it) |
Yes, I forgot to mention. Cosimo posted the code above in this thread, and I got it running, but it didn’t yield the expected result. Instead of adjusting Instead I looked at the code already present in So this is an incremental improvement that produces correct mark placement for Arabic, which I find critical, and doesn’t implement the |
@schriftgestalt do you confirm? |
I’m not sure what version of the code you have. I have worked on this some time ago. |
Another related problem: in Glyphs you can say
to use both Glyphs-generated code and also your own custom code for a feature. fontmake's mark/mkmk generation doesn't support this case. |
@simoncozens see googlefonts/ufo2ft#351 and googlefonts/ufo2ft#352 |
I have seen mentioned in the issues that mark/m2mk feature can be auto-generated by fontmake, but I couldn't figure out how. It’s for Arabic.
I already confirmed that GDEF table correctly defines the marks in question, so the font seems to have all prerequisites.
Could you please point me in the right direction? Sorry if the question seems trivial. Thanks
The text was updated successfully, but these errors were encountered: