Skip to content

textFont(); not working in p5.js v2 #4292

Open

Description

@isasasasa

p5.js version

2.3.2

What is your operating system?

Mac OS

Web browser and version

151.0.7922.174

Actual Behavior

textFont(); does not work.

When switch to p5.js version 1 it works perfectly but in 2 is doesn't

Expected Behavior

Image

Steps to reproduce

Steps:

Snippet:

// Paste your code here :)

Activity

  1. doradocodes commented on Sep 13, 2026

    @doradocodes
    Collaborator

    Hi @isasasasa! I'm trying to reproduce this issue on my end, but haven't been able to so far. If you see my sketch: https://editor.p5js.org/doradocodes/sketches/nmK9yJaRo I have uploaded a font the same way you did, and it is working as expected. My current p5 version is 2.3.2.

    Please share your sketch here, and we can do some further debugging!

  2. ANUBHAVSINGH30 commented on Sep 14, 2026

    @ANUBHAVSINGH30

    Was able to reproduce this — but only when using a custom loaded font, not a font-family string. With textFont('Georgia') (string), no error. But with:

    js
    async function preload() {
    customFont = await loadFont('adamina.ttf');
    }
    function setup() {
    textFont(customFont);
    }

    I get:

    [p5.js, line 102426] Cannot read property of undefined.
    Error at line 102426 in fn._handleMotion()
    Called from line 102413 in fn._ondeviceorientation()

    So the failure seems triggered by a device orientation/motion event handler, not the font loading itself — possibly an unrelated event listener throwing when textFont() with a custom font is in the call stack. p5.js 2.3.2, macOS, Chrome. @isasasasa — were you also using a custom loaded font, or a font-family string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting Maintainer ApprovalNeeds review from a maintainer before moving forwardBugError or unexpected behaviors

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions