textAlign(CENTER, CENTER) does not seem to work when used with user loaded fonts.
Here is a demonstration I made in p5.js:
Here’s the same code run with q5.js showing how the text is supposed to be displayed in the center of the canvas.
I think the problem is caused by the use of OpenType instead of the native canvas text drawing. Text quality is also noticeably worse than native canvas rendering at lower resolutions as shown in the demonstrations.
Hi, it seems both are centered to me (on mobile Safari). What is your os and browser? Can you attach screenshots? If this is a bug, it is also helpful to report in GitHub issues as well: Issues · processing/p5.js · GitHub
The problem does exist on iOS safari as well. You just might not be able to notice because the console blocks part of the canvas. I will make the size of the canvas smaller so you can see the full canvas.
Also here are screenshots from macOS using Chrome:
it seems if you translate bbox.y + bbox.advance, then it aligns with the result of q5.js. I don’t have energy to look into p5.js code because it is doing a lot of things under the hood
In q5.js, it is simply setting context.textBaseline
I’m sure, in p5.js, they designed it with some intension (otherwise they can just set textBaseline), but I don’t know why. Perhaps it’s better opening an issue on p5.js to start a discussion instead of doing a detective work here, or just live with it and correct the height as I did in my example.
Is there a reason why you can’t open an issue? If there’s a strong reason, for example, you can’t make an account on github, then I could. But normally I won’t do it on other’s behalf because everyone should learn how to open an issue so next time you can do it on your own, and furthermore you can let others know how to do it. There is a step by step guide if you go to the issue page: https://github.com/processing/p5.js/issues/new/choose
In this case I’d choose Found a Bug. Then the area is typography, and you can copy your message from this topic and also add a link to this topic. If you have any questions, you can post it here so others can help!
Sorry about this. I checked some of the issues you opened by I don’t see any problem there. Do you mind sharing which was the problem, or is it already deleted? I didn’t even know you are the creator of p5.play.