[Feature request] `gftools flatten-components`
Hi @m4rc1e & @simoncozens
I'm wondering if this maybe a useful sub-tool to have to manipulate binaries.
There are times when binaries in older projects may have nested components which maybe causing issues with printed output, among other things. However, regenerating those fonts to fix the nested components may not be an option because producing new binaries through an improved build process may add regressions. In this case it maybe useful to run something like gftools flatten-components to modify the glyf table to change the glyphindex value to the original, outline glyph.
Could we use the same method as implemented in fontbakery's 'nested_components' check to modify the glyf table?
Thanks in advance!
it's doable but bear in mind that flattening the depth of a component tree also involves computing the effective transformation matrix at the leaves (by multiplying all the transforms along the chain of nested components), not simply remapping the component glyph index.
E.g. for reference see https://github.com/googlefonts/ufo2ft/blob/main/Lib/ufo2ft/filters/flattenComponents.py