Skip to content

[p5.js 2.0 Beta Bug Report]: textFont() throws error when a p5.Font is applied #7491

Closed
@davepagurek

Description

@davepagurek

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

2.0 beta 1

Web browser and version

Firefox

Operating system

MacOS

Steps to reproduce this

Steps:

  1. Load a font
  2. Apply it with textFont()
  3. Measure width with textWidth()

When no font is applied this works, but with a p5.Font applied, I get TypeError: this.states.textFont._textWidth is not a function

Snippet:

async function setup() {
  createCanvas(400, 400);
  const font = await loadFont('https://fonts.gstatic.com/s/sniglet/v17/cIf4MaFLtkE3UjaJ_ImHRGEsnIJkWL4.ttf')
  textSize(100)
  textFont(font)
  console.log(textWidth('test'))
}

Live: https://editor.p5js.org/davepagurek/sketches/TuNtJ4gJt

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions