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

feat: ex.FontSource resource type #2934

Merged
merged 4 commits into from
Feb 17, 2024

Conversation

mattjennings
Copy link
Contributor

@mattjennings mattjennings commented Feb 17, 2024

===:clipboard: PR Checklist :clipboard:===

  • 📌 issue exists in github for these changes
  • 🔬 existing tests still pass
  • 🙈 code conforms to the style guide
  • 📐 new tests written and passing / old tests updated with new scenario(s)
  • 📄 changelog entry added (or not needed)

==================

Closes #

Changes:

  • Added ex.FontSource resource type

    const fontSource = new ex.FontSource('/my-font.ttf', 'My Font')
    loader.addResource(fontSource)
    
    game.start(loader).then(() => {
      const font = fontSource.toFont() // returns ex.Font
    })

    Font options can be defined either at the source or at the toFont() call. If defined in both, toFont(options) will
    override the options in the FontSource.

    const fontSource = new ex.FontSource('/my-font.ttf', 'My Font', { 
      filtering: ex.ImageFiltering.Pixel,
      size: 16, // set a default size
    })
    const font = fontSource.toFont({
      // override just the size
      size: 20,
    })
  • adds "dom.iterable" to lib in tsconfig.json as it was needed to get the correct types for document.fonts

@eonarheim
Copy link
Member

@mattjennings Looks perfect! Only lint is failing

@mattjennings
Copy link
Contributor Author

oops! for some reason my IDE wasn't showing anything. Just pushed a fix.

@eonarheim
Copy link
Member

Awesome, will merge on green 😎

@eonarheim eonarheim merged commit a981c5d into excaliburjs:main Feb 17, 2024
4 checks passed
@eonarheim
Copy link
Member

Thanks again @mattjennings!

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

2 participants