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

Consider transition to harfbuzz subsetter for static instantiation #22

Open
chrissimpkins opened this issue Mar 30, 2021 · 2 comments
Open

Comments

@chrissimpkins
Copy link
Member

The harfbuzz subsetter is a compiled C++ lib that supports variable to static font instantiation. This appears to be exposed through the uharfbuzz Python bindings and it should be significantly faster.

https://github.com/harfbuzz/uharfbuzz/blob/da2e6d5a2c4607276378c84f0ba1fd3bf362beed/src/uharfbuzz/_harfbuzz.pyx#L387

so, I think that we could do something along the lines of the following:

import uharfbuzz

with open(fontpath, "rb") as fontbin:
        hb_face = uharfbuzz.Face(fontbin.read())

hb_font = uharfbuzz.Font(hb_face)

variation_axis_defs = {
    "opsz": "10",
    "wght": "700",
    "GRAD": "-25",
}

hb_font.set_variations(variation_axis_defs)

# TODO
# how do you write binary back to disk? 

It isn't clear to me based on a quick read through of the hb source what level of feature support it has relative to the pure Python varLib.mutator and varLib.instancer libs.

Questions

@chrissimpkins
Copy link
Member Author

Per Cosimo, instancing is not yet supported fonttools/fonttools#2248 (reply in thread)

But it is planned. Something to keep an eye on. Will leave this open.

@chrissimpkins
Copy link
Member Author

D/W Behdad and his feedback was that it is best to continue to base this application on fontTools for now. The support in harfbuzz is not mature at the moment and the fonttools implementation is likely to remain the default in the near - mid term. Will leave this open and follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant