[p5.js 2.0 Bug Report]: textToContours() results are browser dependent
Open
Nobody has claimed this yet.
Area:Typography
Help Wanted
p5.js 2.0+
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.0.5
Web browser and version
Chrome, Firefox
Operating system
Windows
Steps to reproduce this
Steps:
- use textToContours at Chrome and Firefox.
- Centering is successful in Chrome.
- Centering is failure in Firefox.
Snippet:
async function setup() {
createCanvas(400, 400);
font = await loadFont('https://inaridarkfox4231.github.io/assets/KosugiMaru-Regular.ttf');
textAlign(CENTER,CENTER);
textSize(280);
const contours = font.textToContours('海', width/2, height/2, { sampleFactor: 0.5 });
background(220);
const ctx = drawingContext;
ctx.fillStyle = "blue";
drawContours(contours, ctx);
}
function drawContours(contours, ctx){
ctx.beginPath();
for(const contour of contours){
for(let k=0; k<contour.length; k++){
if(k===0){
ctx.moveTo(contour[0].x, contour[0].y);
}else{
ctx.lineTo(contour[k].x, contour[k].y);
}
}
ctx.lineTo(contour[0].x, contour[0].y);
}
ctx.closePath();
ctx.fill();
}
Microsoft Edge
Firefox
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the textToContours() call and the linked OpenProcessing reproduction, then compare its contour and centering results in Chrome and Firefox using the supplied font and snippet. Done means the same centered contour rendering is produced in both browsers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100