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

Missing fonts in UFOOperator built programatically. #52

Open
typesupply opened this issue Oct 22, 2023 · 1 comment
Open

Missing fonts in UFOOperator built programatically. #52

typesupply opened this issue Oct 22, 2023 · 1 comment

Comments

@typesupply
Copy link

I'm trying to create a UFOOperator on the fly using fonts that are open in RoboFont. I'm adding sources with addSource with the font object set in the SourceDescriptor. However, getFonts() doesn't return the fonts after the UFOOperator is populated. It looks like self.fonts is only updated in loadFonts and updateFonts with the latter being dependent on the fonts already existing. Should self.fonts update when addSource is called or should self.fonts be updated by the entity that called addSource?

The demo below runs in RoboFont with > 1 one open.


from ufoProcessor.ufoOperator import UFOOperator
from fontTools import designspaceLib

fonts = AllFonts()

axisTag = "cool"
ufoOperator = UFOOperator()
axis = designspaceLib.AxisDescriptor(
    tag=axisTag,
    name="Cool Axis",
    minimum=0,
    maximum=len(fonts)-1,
    default=0
)
ufoOperator.addAxis(axis)
for i, font in enumerate(fonts):
    source = designspaceLib.SourceDescriptor(
        filename=f"source.{i}",
        path=font.path,
        name=f"source.{i}",
        font=font.asDefcon(),
        location={axisTag : i}
    )
    ufoOperator.addSource(source)

print("getFonts():")
print(ufoOperator.getFonts())

print("")

print("iterate through sources:")
for source in ufoOperator.sources:
    print(source.name, source.font)
@typemytype
Copy link
Collaborator

there could be a one way sync: when a script adds a sourceDescriptor operator could check if a font is given. If there is one add it to the operator.fonts dict: https://github.com/LettError/ufoProcessor/blob/master/Lib/ufoProcessor/ufoOperator.py#L286-L290

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