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

Support vertical fonts (vmtx / vhea table parsing) #728

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

Conversation

opengraphica
Copy link

Fixes #618, #726

Description

This adds parsing for vmtx / vhea tables so the library consumer has the necessary information to draw glyphs vertically.

Motivation and Context

It's part of the spec.

How Has This Been Tested?

Tested through canvas drawing with sample fonts. This PR only adds new variables that the user can read. It does not modify existing logic, and thus has a very low chance of regression.

Screenshots (if appropriate):

Sample vertical text rendering via CSS writing-mode: tb-rl in Firefox (expected behavior):
image

Sample vertical text rendering using opentype.js + canvas (actual behavior).
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I did npm run test and all tests passed green (including code styling checks).
  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the README accordingly.
  • I have read the CONTRIBUTING document.

@Connum
Copy link
Contributor

Connum commented Jul 9, 2024

Thanks! How did you produce the example images? Don't we need to adapt the drawing functions and the demo pages as well in order to implement a toggle for vertical writing?

@opengraphica
Copy link
Author

opengraphica commented Aug 18, 2024

First screenshot is using HTML + CSS in Firefox.
Second screenshot is using opentype.js glyph draw function and offsetting the Y for each glyph by offsetHeight.

I would like to keep the footprint of this PR small. I'm not trying to cater to all vertical writing use cases, just parse these tables and make the data available.

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.

Support for "vrt2" and other vertical writing features
2 participants