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

**URL:** <https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668>\
**Category:** Beginners\
**Created:** [November 11, 2022, 10:01am UTC](https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668 "2022-11-11T10:01:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [November 11, 2022, 10:01am UTC](https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668/1 "2022-11-11T10:01:26Z")

</div>

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

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

2. Example source code:

```auto
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.

```auto
String[] fontList = PFont.list();
printArray(fontList);

```

1. In conclusion, is there a way to search or find the default font in ‘Processing-P5’?

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 11, 2022, 11:16am UTC](https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668/2 "2022-11-11T11:16:04Z")

</div>

Hi @GWAK,

In the documentation page of [`textFont()`](https://p5js.org/reference/#/p5/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:

```javascript
console.log(textFont());

// => sans-serif

```

You can also look in the source code where they set the default font for the [canvas drawing context](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/font):

> <https://github.com/processing/p5.js/blob/main/src/core/p5.Renderer2D.js#L29>

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [November 12, 2022, 12:24pm UTC](https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668/3 "2022-11-12T12:24:17Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 12, 2022, 9:53pm UTC](https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668/4 "2022-11-12T21:53:31Z")

</div>

> [@GWAK](#):
>
> So, I wonder if there is a default font provided by ‘WEB’ or ‘P5’ without loading a file like ‘JAVA Mode’.

Oh my bad I understand what you mean now!

You might want to look at [Web safe fonts](https://www.w3schools.com/cssref/css_websafe_fonts.php) which are fonts that are commonly accessible on most operating systems without having to load them.

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [November 13, 2022, 3:40am UTC](https://discourse.processing.org/t/p5-is-there-a-default-font-provided-by-web/39668/5 "2022-11-13T03:40:53Z")

</div>

@josephh

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