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

Decompose components? #6

Open
arrowtype opened this issue Jul 23, 2020 · 1 comment
Open

Decompose components? #6

arrowtype opened this issue Jul 23, 2020 · 1 comment

Comments

@arrowtype
Copy link

First, this is an awesome project, and I’m just coming across it for the first time. It is such a needed tool. Thank you for working on it!

I’m trying to decompose select components, but it’s not quite working how I expect it to. Is this method implemented yet, or am I trying it a little too early?

This is the primary way I expect it to work:

from babelfont import OpenFont

font = OpenFont(RecMono-Casual-1.053.ttf)

for glyph in font:
    print(glyph.name, glyph.width)
    if glyph.width > 600:
        for comp in glyph.components:
            comp.decompose()
Traceback (most recent call last):
  File "src/build-scripts/make-release/dlig2calt.py", line 109, in <module>
    fire.Fire(decomposeCodeLigs)
  File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/fire/core.py", line 471, in _Fire
    target=component.__name__)
  File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/fire/core.py", line 675, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "src/build-scripts/make-release/dlig2calt.py", line 37, in decomposeCodeLigs
    comp.decompose()
  File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/fontParts/base/component.py", line 320, in decompose
    self._decompose()
  File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/babelfont/ttf/component.py", line 66, in _decompose
    glyph = component.glyph
AttributeError: 'GlyphComponent' object has no attribute 'glyph'

I have also tried:

from babelfont import OpenFont

font = OpenFont(RecMono-Casual-1.053.ttf)

for glyph in font:
    print(glyph.name, glyph.width)
    if glyph.width > 600:
        for comp in glyph.components:
            glyph.decomposeComponent(comp)
Traceback (most recent call last):
  File "src/build-scripts/make-release/dlig2calt.py", line 108, in <module>
    fire.Fire(decomposeCodeLigs)
  File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/fire/core.py", line 471, in _Fire
    target=component.__name__)
  File "/Users/stephennixon/type-repos/recursive/venv/lib/python3.7/site-packages/fire/core.py", line 675, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "src/build-scripts/make-release/dlig2calt.py", line 36, in decomposeCodeLigs
    glyph.decomposeComponent(comp)
AttributeError: 'TTGlyph' object has no attribute 'decomposeComponent'

Am I missing something obvious? Thank you for any insights!

@simoncozens
Copy link
Owner

Hmmm, I have to admit I've never tried doing that, and looking at the code it looks like I just copied a few functions from the UFO components module to get something basic working. I am not terribly surprised that decompose doesn't work. :-) Will get it working tomorrow.

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

2 participants