adobe-type-tools / afdko

Adobe Font Development Kit for OpenType
https://adobe-type-tools.github.io/afdko/
Other
1.03k stars 168 forks source link

otfautohint - keep the existing hints #1687

Open paratype-andrei opened 4 years ago

paratype-andrei commented 4 years ago

Is it possible to autohint only when vstem or hstem command is not already present?

frankrolf commented 4 years ago

It is possible to supply a glyph list to the psautohint command via the -g option, as well as excluding glyphs with the -x option, which might be step one toward a workaround. makeotf -r lists unhinted glyphs in a font, which could help creating the glyph list required above.

This is not the most elegant approach, but probably helps for the moment.

paratype-andrei commented 4 years ago

Our actual issue is in that in certain cases our font mastering team has to manually correct/adjust hints after running autohint. So, having two additional options would be very useful:

miguelsousa commented 4 years ago

In the second option, how will the tool be able to determine which hints it should or shouldn't add?

paratype-andrei commented 4 years ago

For a given character, the tools sees horizontal hints already present (there at least one hstem command) and the vertical ones missing (no vstem commands). In this case, the tool keeps the horizontal hints and adds the verticals. If both horizontal and vertical hints are present, don't touch this character.

miguelsousa commented 4 years ago

I think it would be better to make the option explicit. Something like add only vertical hints. Any existing vertical hints would be discarded and new ones would be added.

paratype-andrei commented 4 years ago

"add only vertical hints" is definitely a very useful option (together with the horizontal counterpart). Unfortunately, it will not fully cover our use case. We often do not know upfront (specifically, when adding new third party fonts to our Web store) which hints were and which were not added by the original font manufacturer. We use hints on certain characters to classify fonts. Cap Height of "H" divided by its vertical stem width is a measure of Weight, horizontal stem divided by Cap Height - contrast, etc. So, when a font does have both vertical and horizontal hints for "H", we use them for the classification. If one or both of hint types is missing we want to temporarily run psautohint to calculate hints for "H" and use the results for the classification.

iterumllc commented 3 years ago

"do-not-override-existing-hints" The second option differs from the first one because in some cases the horizontal hints are already there (and we don't want to replace them), but the vertical hints have to be added for chars that do not have them already.

This is probably doable but its a bit more complicated than it may first appear because of hint masks. There are two options:

  1. Take the existing stem values as a given but recalculate the masks. This is tricky because it requires doing something like the opposite of the existing algorithm: start with the stems and build one's way to the associated path elements rather than the other way around.
  2. Treat the masks in the existing dimension as a given. This seems easier and will probably have a good result when the masks have been calculated only for that dimension (rather than, say, being calculated for both horizontal and vertical hints with one dimension stripped out later). Basically whenever you reach an existing mask the placement process in the other dimension resets. Still, this option runs a risk of having more masks than one would otherwise and increasing the size of the font.

"Don't hint glyphs with existng hints" is of course a much simpler problem.