Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipping to multiline text only works with the final line #7108

Closed
1 of 17 tasks
davepagurek opened this issue Jun 28, 2024 · 0 comments · Fixed by #7109
Closed
1 of 17 tasks

Clipping to multiline text only works with the final line #7108

davepagurek opened this issue Jun 28, 2024 · 0 comments · Fixed by #7109

Comments

@davepagurek
Copy link
Contributor

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

1.9.4

Web browser and version

Firefox

Operating system

MacOS

Steps to reproduce this

Steps:

  1. Load a font
  2. Clip to text that contains newlines
  3. Draw clipped content

It should clip to the full text, but it only clips to the last line.

Snippet:

let font

function preload() {
    font = loadFont('https://fonts.gstatic.com/s/prompt/v10/-W_6XJnvUD7dzB2KZeKka2MrUZEtdzow.ttf')
}

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  clip(() => {
    textAlign(CENTER, CENTER)
    textSize(50)
    textFont(font)
    text('Line 1\nLine2', width/2, height/2)
  })
  background(0)
}

Live: https://editor.p5js.org/davepagurek/sketches/70aNKJIEz

image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant