[P5] Is there a default font provided by WEB?

[P5] Is there a default font provided by WEB?

  1. In ‘Processing-P5’, you can load a font with ‘loadFont’.

  2. Example source code:

let myFont;
function preload() {
   myFont = loadFont('assets/inconsolata.otf');
}
  1. However, since the capacity of the font is large, if it is loaded as above, loading will be longer. So, users may feel stuffy.

  2. In ‘JAVA Mode’, you can search for the default font.

String[] fontList = PFont.list();
printArray(fontList);
  1. In conclusion, is there a way to search or find the default font in ‘Processing-P5’?

Hi @GWAK,

In the documentation page of textFont(), they say:

If textFont() is called without any argument, it will return the current font if one has been set already.

So you can try:

console.log(textFont());

// => sans-serif

You can also look in the source code where they set the default font for the canvas drawing context:

3 Likes

@josephh

Thanks for your reply.
Based on your words, you can find out about the current font.

However, the reason I uploaded this is that when the font is loaded, the loading time becomes longer due to the file size.
So, I wonder if there is a default font provided by ‘WEB’ or ‘P5’ without loading a file like ‘JAVA Mode’.
For example, you can use ‘PFont.list();’ without needing to have a font file.
I wonder if there is something like this on the web as well.

Oh my bad I understand what you mean now!

You might want to look at Web safe fonts which are fonts that are commonly accessible on most operating systems without having to load them.

2 Likes

@josephh

Thank you. Thanks for the kind explanation.
What I was wondering about is this.

1 Like