-
Notifications
You must be signed in to change notification settings - Fork 480
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
Fixed metadata that enables fonts to be recognised as a family #606
Conversation
I've found out that a few fields that might be passed to opentype.js were not being used while producing the font. I have been able to pinpoint those fields and where they should be applied to produce fonts that are recognised as a family. Tested only with a couple of fonts but changes were regonised by Windows and other apps. An issue regarding the fields hhea.caretSlopeRise and hhea.caretSlopeRun for italic and oblique fonts is still pending review but does not prevent font usage or recognition as a family (caret slope had a weird inclination while testing on Word but not on Affinity Designer). These same changes were applied to the copy of the library used by Glyphr Studio (v2) where the tests were conducted.
Having a set of font files be recognized as a family is a perennial ask we get at Glyphr Studio. Before @Lmpessoa we had no answer. Within Glyphr Studio we have implemented this fix... but it would probably be very appreciated by anyone using opentype.js who is trying to make multiple styles of a type family. |
seems like the tests needs an update.
|
I haven't found the time yet to look into this more thoroughly, but if the tests break, it's probably a breaking change. Or the new code can be adapted to prevent the error breaking the code. Looks like something that could be fixed using optional chaining. |
Hi @Lmpessoa, could you please have a look at the failing tests? |
(I am not very skilled at Git workflows, so bear with me...) I looked at @Lmpessoa 's changes and ran the tests. It looked like to me we needed to provide a default for Now all tests are passing. But, I'm not sure where to check it in. I think I forked @Lmpessoa 's checkin and pushed it, but I don't know where it 'went' (my inexperience showing). Anyway, my change is just to
Apologies again for my inexperience, let me know if there is a way I can help out. Update I tried to add this change as a commit to this fork... but it wasn't letting me, saying I didn't have the right permissions. |
@mattlag, here might be the issue between my fix and the tests being run. Pushing The part about panose = Array.isArray(options.panose) ? option.panose : [];
while (panose.length < 9) {
panose.push(0);
} Perhaps would be interesting if someone else, more experienced with JavaScript and the lib itself, could take a look at it too. |
The tests being run come down to this object which is passed to the test, and it effects both sub-issues:
beforeEach(function() {
font = new Font({
familyName: 'MyFont',
styleName: 'Medium',
unitsPerEm: 1000,
ascender: 800,
descender: 0,
fsSelection: 42,
tables: {os2: {achVendID: 'TEST'}},
glyphs: glyphs
});
}); The easier issue is the The issue with
it('tables definition can override defaults values', function() {
assert.equal(font.tables.os2.fsSelection, 42);
}); My idea was that we cover two cases: one, if the user does not specify |
If this can be determined reliably, I think that's the way to go! |
@Lmpessoa could add you as a contributor to their fork, or if they're no longer interested in being involved, you could fork it yourself, which would result in a new PR and this one being closed. |
I created a new pull request that include the changes that allow |
superseded by #630 |
I've found out that a few fields that might be passed to opentype.js were not being used while producing the font. I have been able to pinpoint those fields and where they should be applied to produce fonts that are recognised as a family. Tested only with a couple of fonts but changes were regonised by Windows and other apps.
An issue regarding the fields hhea.caretSlopeRise and hhea.caretSlopeRun for italic and oblique fonts is still pending review but does not prevent font usage or recognition as a family (caret slope had a weird inclination while testing on Word but not on Affinity Designer).
These same changes were applied to the copy of the library used by Glyphr Studio (v2) where the tests were conducted.
Description
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
npm run test
and all tests passed green (including code styling checks).