-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement anchor extraction from OpenType files #68
Implement anchor extraction from OpenType files #68
Conversation
9126a76
to
124a25b
Compare
124a25b
to
34c79e0
Compare
Hmmm, I just noticed that my code failed to extract two anchor groups (is this the correct term to use?) from a TTF I'm working on. I have twelve of them in the font, but only the first ten (0-9) got extracted. Weird. |
False alarm. It appears the TTF fonts I'm working on use incorrect feature tags for the last two lookups ( So, will this PR be accepted or do I need to do something more? |
Lib/extractor/formats/opentype.py
Outdated
try: | ||
anchor = Anchor(destination[base], {"x": baseAnchors[base]["x"], "y": baseAnchors[base]["y"], "name": f"Anchor-{groupIndex}"}) | ||
destination[base].appendAnchor(anchor) | ||
except: | ||
continue | ||
for mark in markAnchors.keys(): | ||
try: | ||
anchor = Anchor(destination[mark], {"x": markAnchors[mark]["x"], "y": markAnchors[mark]["y"], "name": f"_Anchor-{groupIndex}"}) | ||
destination[mark].appendAnchor(anchor) | ||
except: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can rewrite this without using the defcon.Anchor object and thus get rid of the defcon dependency:
for base in baseAnchors.keys():
try:
anchor = {
"x": baseAnchors[base]["x"],
"y": baseAnchors[base]["y"],
"name": f"Anchor-{groupIndex}",
}
destination[base].appendAnchor(anchor)
except:
continue
for mark in markAnchors.keys():
try:
anchor = {
"x": markAnchors[mark]["x"],
"y": markAnchors[mark]["y"],
"name": f"_Anchor-{groupIndex}",
}
destination[mark].appendAnchor(anchor)
except:
continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder about the try...except
statements here. In what case could it go wrong, and would we want to know about it instead of silently ignoring the anchors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you're right. I didn't want my additions to potentially break the code, but I suppose it's better to fix it properly if something breaks instead of pretending like nothing happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can rewrite this without using the defcon.Anchor object and thus get rid of the defcon dependency:
Done. Also rebased on the current master and force-pushed everything in a single commit.
IIRC those are unofficial feature tags used by MS VOLT to store its "source code". |
Ah, I see. Indeed, all the anchors were added to these fonts using MS VOLT. Apparently, the original designer created the two lookups in question, but did not reference them from the |
572a4de
to
52b706c
Compare
This looks good to me. Thanks for the nudge and the update. |
Fixes #67
Disclaimer: I'm not really a Python developer, so it's possible that I didn't do some things the right way. Fell free to help me improve this code. :)