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 WebAssembly example #310

Merged
merged 2 commits into from
Apr 6, 2021
Merged

Add WebAssembly example #310

merged 2 commits into from
Apr 6, 2021

Conversation

mgeisler
Copy link
Owner

@mgeisler mgeisler commented Apr 5, 2021

This example shows how one can use Textwrap to wrap text outside of the console. In this case, the text is shown on a HTML canvas. The user can switch the font family between monospace, serif, and sans-serif and we accurately use the actual width as measured by the browser to wrap the text.

The code is manually deployed to https://mgeisler.github.io/textwrap/, I'll work on some automation for this next.

This example shows how one can use Textwrap to wrap text outside of
the console. In this case, the text is shown on a HTML canvas.
@mainrs
Copy link

mainrs commented Apr 5, 2021

Not sure if you are aware of it, but the example doesn't work in Firefox. Not a huge deal, but might be good to add a notice somewhere:
image

@mgeisler
Copy link
Owner Author

mgeisler commented Apr 6, 2021

Hi @sirwindfield, thanks for testing it! I would love to make it work in Firefox too and you're right, it should be noted somewhere what I've tested it with.

@mgeisler
Copy link
Owner Author

mgeisler commented Apr 6, 2021

Hi @sirwindfield,

I tested it some more and found the problem — I was using some methods which aren't yet supported by Firefox. A new version has been deployed in 9aaa7c5.

It turns out that Firefox doesn’t implement the fontBoundingBoxAscent
and fontBoundingBoxDescent methods on the TextMetrics object returned
by measureText.

We can work around this by measuring a suitably tall character such as
the box drawing vertical pipe character.
@mgeisler mgeisler merged commit 3b77e9c into master Apr 6, 2021
@mgeisler mgeisler deleted the wasm-demo branch April 6, 2021 15:26
This was referenced May 30, 2021
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.

2 participants