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

Suggestion: Ship polyfill that can already be used #54

Open
Awendel opened this issue Jul 21, 2022 · 0 comments
Open

Suggestion: Ship polyfill that can already be used #54

Awendel opened this issue Jul 21, 2022 · 0 comments

Comments

@Awendel
Copy link

Awendel commented Jul 21, 2022

As far as I understand the following thing would be very tricky to implement with the existing canvas API:

  • have a very long text that one wants to render at a fixed with 300px
  • if doing so in plain HTML, the browser automatically break the lines based on font information & CSS
  • now wanting to render the paragraph identical in canvas without manually specifying the line breaks would be pretty much impossible with existing APIs

All it currently exposes if one was to parse the original paragraph is all the boundingClientRects for each line, but there is not way of telling which character / word belong to which line.

The proposed API would pretty much solve the problem, yet will probably take quite a long time before it's adopted by all major browsers.

Perhaps if possible, one could already ship a polyfill for the library that would allow to use its functionality before shipped natively in browsers, especially with the focus on that line breaking behaves identicaly to how the browser determines it.

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

No branches or pull requests

1 participant