Open kontur opened 4 years ago
(That is to stay: Output the best stylespace that can possibly be inferred, and for more than 1 axis of course the instance
names are no longer useful, e.g. locations might be generated, but their names can no longer be inferred)
A generate-stylespace-based-on-guessing-from-the-designspace? Mh, maybe.
Another thing I was contemplating is providing a template Stylespace (internally or externally). The names for weight and width axes plus their locations are detailed by the specification and there should be little reason for a designer to change them. This would probably solve the usual cases.
if you can solve the "usual cases" and your solution is better than the STAT table varLib auto-generates, wouldn't it be best to add that logic to varLib itself?
Afaik varLib just puts the axes in there without any instances at all (for MS compilance?). Even if to some degree this could be automated in varLib, the added benefit of using statmake is to refine and expand STAT beyond the obvious. E.g. defining instance ranges, localized names, what style name can be omitted, and if they are linked to other names. I just found myself essentially copying and reformatting a designspace document to get a stylespace document and that didn't seem very DRY, plus it is manual work.
@kontur you can start with https://github.com/daltonmaag/statmake/blob/master/tests/data/Test.stylespace
Handling the common case in varLib is probably a good idea.
Yep, the example file is very helpful, thank you!
I refactored the sample script I posted above into a scaffolding script that writes stylespace definitions from a designspace file (since that is anyway to be assumed required with statmake). It does 90% of the work, just not naming the actual locations or setting any flags.
extract_stylespace_from_designspace.py
python extract_stylespace_from_designspace.py path/to/family.designspace --round --range
will write path/to/family.stylespace
with all axes and locations defined, but unnamed locations. Maybe it's helpful for someone else. For a single axis font it could be expanded to simply write the instance style name as location name, I suppose.
A reasonable STAT for a 1-axis font can almost always be autogenerated.
Looking at how to automate writing a STAT table I came across this sample script used to extract a rudimentary stylespace on the fly.
While more precise control over the different formats will certainly be needed for many cases, an option to a) use or b) output a basic stylespace based off a designspace file on the fly would certainly be very useful for many basic cases to output at least some STAT information, or to get started with customizing.
E.g. an a
statmake -m … --generate
that would use axes and instances from the designspace and use that for compilation of the STAT table, and an optional--output path/to/generated.stylespace
to store such a basic stylespace for further manual editing.Would this be something that could go into this library directly?