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

Update vhea and share logic with hhea #233

Merged
merged 7 commits into from
May 24, 2018
Merged

Conversation

moyogo
Copy link
Collaborator

@moyogo moyogo commented Mar 14, 2018

  • Use hhea.ascender instead of glyph.height as fallback verticalOrigin (fixes Change default verticalOrigin from glyph height to hhea.ascender? #231)
  • Compile vertical metrics tables iff vhea metrics are defined instead of when verticalOrigin is defined in some glyphs.
  • Update tests that have vhea metrics defined
  • Share logic for setupTable_hhea and setupTable_vhea

Copy link
Contributor

@mashabow mashabow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Denis! LGTM in general.

if isHhea:
reserved = range(4)
else:
reserved = range(5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

table__v_h_e_a.reserved0 is deprecated and now it is an alias for table__v_h_e_a.caretOffset (see
_v_h_e_a.py#L110-L117). So this line should be reserved = range(1, 5).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed! Thanks!

@moyogo moyogo changed the title Vertical Update vhea and share logic with hhea Mar 15, 2018
@moyogo
Copy link
Collaborator Author

moyogo commented Mar 15, 2018

I had lost the pull request title after a browser crash.

"openTypeVheaVertTypoLineGap",
"openTypeVheaCaretSlopeRise",
"openTypeVheaCaretSlopeRun",
"openTypeVheaCaretOffset",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moyogo that all vhea metrics be defined in fontinfo.plist seems a bit too much. Maybe only check if VertTypo* are present and leave the VheaCaret* stuff as optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

else:
boundsAdvance = (bounds.yMax - bounds.yMin)
# equation from the vhea spec for calculating yMaxExtent:
# Max(tsb - (yMax - yMin)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I missed that. Was it correct before this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it may not have been in some cases: https://github.com/googlei18n/ufo2ft/pull/233/files#diff-2e916b2b1efc6fc438bed046c8c37f01L706
I’m looking into why the test hasn’t changed after the fixup commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that "equation" in the OT spec is confusing...
the Apple TTRefMan has this definition for "extent"

The 'hhea' table uses the concept of extent. The extent is the distance from the left side bearing to the right most positions in the glyph outline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, it did follow what Apple TTRefMan vhea says:

This is defined as the value of the minTopSideBearing field added to the result of the value of the yMin field subtracted from the value of the yMax field.

But the OTspec vhea says:

Defined as yMaxExtent = max(tsb - (yMax - yMin)).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, even more confusing. Actually, I think @mashabow himself posted to the OpenType mailing list or the mpeg-OTSpec (or both?) about the yMaxExtent in vhea table recently (I can't find the url).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Originally on the OpenType mailing list, I suggested correcting from:

yMaxExtent = minTopSideBearing + (yMax - yMin)

to:

yMaxExtent = max(tsb + (yMax - yMin))

in September 2017. Then the OpenType spec 1.8.2 was changed to:

yMaxExtent = max(tsb - (yMax - yMin))

...but I've never noticed the minus sign until now.😫 I don't know it is intentional or not.

Copy link
Member

@anthrotype anthrotype Mar 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a typo to me. I just forwarded this question to the OpenType mailing list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Cosimo!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the OT spec, it has already been corrected.

In the erratum of 14 September 2017, a typo was introduced during the change, resulting in an incorrect calculation. The correct calculation should be yMaxExtent = max(tsb + (yMax-yMin)).

https://docs.microsoft.com/en-us/typography/opentype/spec/errata

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mashabow Thank you for following up!
@moyogo could you apply the change?

@anthrotype
Copy link
Member

It would be nice to have this in before the next ufo2ft release. Let me know if anybody is available to pick this up, or I could finish this myself.
It probably also needs to be rebased on master after the latest changes.

moyogo added 7 commits May 24, 2018 10:11
setupTable_Vhea() fails already unless all vhea metrics are defined.

Some glyphs may have verticalOrigin set unwillingly (copy-paste from other font or user error).
vhea minTopSideBearing, minBottomSideBearing are only caclulated with contour glyphs, set to zero when there are no contour glyphs

(same as b5e6710 but for vhea)
When vhea metrics are defined, vertical metrics tables are generated
Copy link
Member

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@moyogo moyogo merged commit 4e79e97 into googlefonts:master May 24, 2018
@moyogo moyogo deleted the vertical branch February 12, 2020 20:23
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.

Change default verticalOrigin from glyph height to hhea.ascender?
3 participants