Skip to content
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

add an option to opt out of USE_TYPO_METRICS #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kseino
Copy link

@kseino kseino commented Nov 19, 2021

Added useTypoMetrics options to set REGULAR to fsSelection.
https://docs.microsoft.com/en-us/typography/opentype/spec/os2#fsselection

Use cases
We use custom icon fonts generated thanks to svg2ttf in Flutter project.
Flutter renders extra ascent when Use Typo Metrics is enabled. useTypoMetrics options will solve this problem.

#95 (comment)

@kseino kseino closed this Dec 13, 2021
@kseino kseino reopened this Jan 18, 2022
@kseino
Copy link
Author

kseino commented Jan 25, 2022

@puzrin
Could you review please 🙏

@puzrin
Copy link
Member

puzrin commented Jan 26, 2022

Could you use fork for a while? I'm still busy with extremely urgent fixes on my project, which made all this stuff possible.

Sorry for unexpected delays.

@kseino
Copy link
Author

kseino commented Mar 23, 2022

related
flutter/flutter#98909

@kseino
Copy link
Author

kseino commented Jun 6, 2022

@puzrin
Could you please review this PR?

We are looking forward to this option!

@velkrissz
Copy link

velkrissz commented Jun 5, 2023

I encountered the same problem when generating an icon font for a Flutter app.

I avoided the issue without changing the Use Typo Metrics flag. (Tested on Android and iOS) Based on some experimenting, the problem disappears if the OS/2 sTypoLineGap is set to 0. Based on my understanding, this won't cause any problem as we use this for icons, not real fonts,
I monkey-patched the Font "class" using the following snippet based on the actual implementation and it seems to be working just fine.

import * as sfnt from "svg2ttf/lib/sfnt.js";
// ...
Object.defineProperty(sfnt.Font.prototype, "int_lineGap", { value: 0 });

This bypasses the built-in 9% of font ascent minus descent calculation.
I suggest adding a lineGap parameter to the options object. (SVG font face does not define a similar param.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants