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 a lineGap configuration option to the Font object #681

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

Conversation

sammyfeng0530
Copy link

Add a 'lineGap' configuration option to the Font object.

Description

Add a 'lineGap' configuration option to the Font object, so that the generated font file when calling toArrayBuffer includes the 'lineGap' property.

Motivation and Context

I need the 'lineGap' property to calculate the automatic height of text. Currently, the generated font file does not include this property, which causes inaccuracies in my text's automatic height calculation.

How Has This Been Tested?

const font = new Font({
    familyName: 'MyFont',
    styleName: 'Medium',
    unitsPerEm: 1000,
    ascender: 800,
    descender: 0,
    fsSelection: 42,
    lineGap: 500,
    tables: {os2: {achVendID: 'TEST'}},
    glyphs: glyphs
});
// It will be 500
console.log('font.lineGap :>> ', font.lineGap)

const buffer = font.toArrayBuffer()
const f = opentype.parse(buffer)
// It will be 500
console.log('f.lineGap :>> ', f.lineGap)
// It will be 500
console.log('f.tables.hhea.lineGap :>> ', f.tables.hhea.lineGap)

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.

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

1 participant