Skip to content

Fix locationBase handling #94

Open
punchcutter wants to merge 1 commit intofontra:mainfrom
punchcutter:buildfix
Open

Fix locationBase handling #94
punchcutter wants to merge 1 commit intofontra:mainfrom
punchcutter:buildfix

Conversation

@punchcutter
Copy link
Copy Markdown

@punchcutter punchcutter commented Mar 18, 2026

This makes it possible to build a VARC font from the sources used in fontra/fontra-glyphs#134

This fixes #76.

@punchcutter
Copy link
Copy Markdown
Author

Actually, the test updates are unrelated to this. They were failing before I made any change. So maybe those should be updated separately?

@justvanrossum
Copy link
Copy Markdown
Member

  1. I would be nice if you could set up pre-commit: that prevents committing formatting/linting errors (https://github.com/fontra/fontra?tab=readme-ov-file#testing)
  2. For me, the test data as committed here make the tests fail, and the previous versions don't (even with the changes to builder.py)

normalizeLocation({**defaultLocation, **source.location}, axisDict)
for source in glyphSources
]
def prepareLocations(glyphSources, defaultLocation, axisDict, fontSources=None):
Copy link
Copy Markdown
Member

@justvanrossum justvanrossum Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def prepareLocations(glyphSources, defaultLocation, axisDict, fontSources=None):
def prepareLocations(glyphSources, defaultLocation, axisDict, fontSources):

This function isn't likely being used elsewhere, so I'm fine with not making this backwards compatible.

# stores axes that differ from that master's position (e.g. a brace
# layer adds one extra axis value). Merge the master's full location
# first so the glyph source's explicit values can override it.
if source.locationBase and fontSources and source.locationBase in fontSources:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to add a helper function (untested):

def getGlyphSourceLocation(glyphSource, fontSources):
    return (
        glyphSource.location
        if glyphSource.locationBase is None
        or glyphSource.locationBase not in fontSources
        else {**fontSources[glyphSource.locationBase].location, **glyphSource.location}
    )

Then the main for source in glyphSources loop can become a list comprehension again.

@punchcutter
Copy link
Copy Markdown
Author

  1. I would be nice if you could set up pre-commit: that prevents committing formatting/linting errors (https://github.com/fontra/fontra?tab=readme-ov-file#testing)
  2. For me, the test data as committed here make the tests fail, and the previous versions don't (even with the changes to builder.py)

Sorry, I totally forgot to setup pre-commit first.
If I checkout the clean repo, set up a new clean venv, and pip install all the requirements then tests fail. That's with Python 3.13.11. Not sure what's up with that.

@justvanrossum
Copy link
Copy Markdown
Member

Ah ok, I made a fresh venv, and I indeed see the failures. I'll try to see which dependency caused this.

@justvanrossum
Copy link
Copy Markdown
Member

It's booleanOperations: it's a slight difference in remove overlap in the G glyph. Yeah, ideally this would be a separate fix. I can do that tomorrow.

@justvanrossum
Copy link
Copy Markdown
Member

It's booleanOperations: it's a slight difference in remove overlap in the G glyph. Yeah, ideally this would be a separate fix. I can do that tomorrow.

Done in #95.

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

Successfully merging this pull request may close these issues.

Make fontra-compile aware of glyphSource.locationBase

2 participants