font-patcher: Really set SubFamily to what we want #690
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
[why]
The most convenient way to set something in the SFNT table is by using
Fontforge's
appendSFNTName()
. When we try to set the SubFamily, thiswill succeed in many instances, but not in all. Sometimes the function
seems to be ignored.
This is for example the case for
VictorMono-Medium.ttf
where we want toset the SubFamily
"Regular"
, but the final patched file has theSubFamily
"Medium"
.[how]
The reason for the unexpected behavior of Fontforge is as follows. It
almost seems like a bug, but then it is coded explicitely in this way.
Maybe noone ever stumbled about it, or it has only been designed only
with creating new fonts in mind.
Fontforge lets you set any value, unless it is the default value. If it
is the default value it does not set anything. It also does not remove
a previously existing non-default value. Why it is done this way is
unclear:
Then is the question: What is the default? It is taken from the
currently set
fontname
(??!). Thefontname
is parsed and everythingbehind the dash is the default SubFamily:
To stick to the example above, the
fontname
is there"VictorMonoNerdFontM-Medium"
. Afterwards we want to set the SubFamily to"Medium"
- which is the 'default' and Fontforge decides that nothing hasto be done. Albeigth the current SubFamily is
"Regular"
(from the sourcefont load).
Well.
To fix this without touching Fontforge we need to set the SubFamily
directly in the SFNT table, which is a little bit unhandy but possible.
Now in the generated files the SubFamily is again as expected the same
es the
fontname
's last part.Requirements / Checklist
./font-patcher Inconsolata.otf --fontawesome --octicons --pomicons
./gotta-patch-em-all-font-patcher\!.sh Hermit
What does this Pull Request (PR) do?
How should this be manually tested?
Any background context you can provide?
What are the relevant tickets (if any)?
In progress of fixing issue #663
Screenshots (if appropriate or helpful)
font-patcher
run with debug stuff enabled, see https://gist.github.com/Finii/a496cff7eb38933b169110be3e4e8af2