Skip to content

Strictly unable to use textToCountours() #7945

Open
@romain-granai

Description

@romain-granai

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

2.0.3

Web browser and version

Firefox 139.0.4 - Chrome 137.0.7151.122 (Official Build) (arm64) - Safari 18.5 (20621.2.5.11.8)

Operating system

MacOs Sequoia 15.5

Steps to reproduce this

  1. Open the https://beta.p5js.org/reference/p5.font/texttocontours/
  2. Click on the play button
  3. Nothing seem to work

or

  1. made my own version on Codepen using the demo code (https://beta.p5js.org/reference/p5.font/texttocontours/), a strict copy/past
  2. Changed the font url to a .otf Codepen hosted font
  3. Nothing seems to work

let font;

async function setup() {
createCanvas(100, 100);
font = await loadFont('https://assets.codepen.io/225413/Spezia-VF-Upright.otf');
}

function draw() {
background(200);
textAlign(CENTER, CENTER);
textSize(30);

// Get the point array.
let contours = font.textToContours('p5*js', width/2, height/2, { sampleFactor: 0.5 });

beginShape();
for (const pts of contours) {
beginContour();
for (const pt of pts) {
vertex(pt.x + 5sin(pt.y0.1 + millis()*0.01), pt.y);
}
endContour(CLOSE);
}
endShape();

describe('The text p5*js wobbling over time');
}

In both versions (on the beta P5 website AND on my Codepen example), I have that error :

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://assets/inconsolata.otf. (Reason: CORS request did not succeed). Status code: (null).

Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource.

Is that supposed to do something? Is there some kind of working demo somewhere?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions