Using textToPoints() with an already loaded font

Hi, I am using the textToPoints() function in a project, but since textToPoints() is part of the prototype of p5.Font I need to use it with a font loaded with loadFont().
But I can’t find a way to get a reference to an already loaded font (default or loaded in the html file) to use textToPoints().
The goal would be to load the font only once in the html file (for displaying the website) then get a reference to it in the p5 script (if that makes sense, I am still new to html/js).
Thank you

1 Like

Property p5.Font::font is a Font object from library “opentype.js”: Opentype.js.org




And it seems like that dependency library can only load a font from a file.
I don’t think it can use an already loaded font though.
But you can ask them about it to be sure.

2 Likes

Thank you for your reply !
The reason I did not want to load the font in the p5 sketch was to avoid the “Loading…” message on a white background when loading the font in preload().
Since this is just for a tiny personal project (and I do not have much experience with p5 and javasript in general) this is probably not worth for me to dig deeper, but thank you for pointing me to opentype.js.
To work around this I changed the background in the html file to match the sketch so that the transition is smoother when loading.

1 Like
3 Likes