-
Notifications
You must be signed in to change notification settings - Fork 669
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
glyphs without decimals #1397
glyphs without decimals #1397
Conversation
Sorry for the dumb question. Does this affect anything in the final output? I don't think we should be rounding to integer if the original OTF specifies a decimal point. We should keep the paths and font outlines as true to the original OTF files as possible, and scale at the last possible moment. |
No visual differences. This is only rounding internal bounding box calculations.
See #1395 (comment) for more details |
@ronyeh OTF are binary files, they are stored as uint 8 or 16: https://docs.microsoft.com/en-us/typography/opentype/spec/glyf The coordinates are x/y within a box, the size of which is determined in the font file. So rounding only happens when we scale them. I have not been following this too closely, but I think there's been some optimization in this area lately by @tommadams. |
@rvilarl The bounding boxes are used for placement though, and it's not clear if this will make a difference at higher zoom levels. I agree that the digits after the decimal are too many, but how about pruning to 3 digits instead of removing them completely? |
@0xfe well I do not understand why we remove them completely for the path and not for the bounding box. function fix(f, invert = false) {
return Math.round((f / pointSize) * scale) * (invert ? -1 : 1);
} Why should the bounding box treated more strictly than the pah? And there is no visual difference. And as Aaron said "So rounding only happens when we scale them." |
Oh, I didn't realize that it applied to paths too -- is that during runtime? Do we only call |
@0xfe fix is used by fontgen_smufl.js in the offline conversion of OTF to JavaScript for all the numbers in the paths. |
Thanks for the discussion. I looked into this, and it seems like we have been rounding path points to the nearest integer since SMuFL fonts were introduced. Here is the 3.0.9 version of font gen: https://github.com/0xfe/vexflow/blob/3.0.9/tools/smufl/smufl_fontgen.js You see that the However, the bounding boxes are not rounded. Here are our options:
Long term, I think the truly correct solution would be to:
In my investigation into this (September 2021), I found that the final scale factor would be around 4% of the original 1000pt font size for the glyphs. See: #1158 (comment)
|
I think my recommendation would be to leave it as is (i.e., close this PR without merge), since this is just a cosmetic change to the glyph files' bounding box fields, with no detectable visual change in the output. I understand Mohit's desire to keep VexFlow pure, without having a runtime dependency on the opentype.js library. Perhaps someday we can extract the pure OTF paths and scale them only at the last possible moment (at runtime). Or maybe the FontFace API will have wide enough support that we can drop the glyphs files and use the OTFs directly. It seems like browser support is pretty good for FontFace: Safari iOS / Mac might be the only ones with incomplete support. I think this would be a good goal for a future version of VexFlow (e.g., VexFlow 5):
|
Removal from decimals in glyphs separated in a new PR.