question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

2d text renders badly

See original GitHub issue

My canvas uses WEBGL and i am trying to draw regular debug text on top in 2D.

I am following this WEBGL method https://p5js.org/reference/#/p5/text

function preload() {
  inconsolata = loadFont(
    "https://cdnjs.cloudflare.com/ajax/libs/bwip-js/2.0.6/Inconsolata.otf"
  );
}

function setup() {
  pixelDensity(1); //lower is faster

  var canvas = createCanvas(windowWidth, windowHeight, WEBGL);
  
  textFont(inconsolata);
  textSize(20);
  textAlign(CENTER, CENTER);

Drawing text inside displayHUD() makes it look very glitchy. drawing text inside draw() is glitchy too but in 3D space.

Screen Shot 2022-02-26 at 3 52 25 PM Screen Shot 2022-02-26 at 3 53 15 PM

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stephanschulzcommented, Mar 3, 2022

I just tried your example and also tried adding the lights() suggestion but it did not change anything 😦 Overall it’s not a big problem since i can just tell people to use a specific browser.

0reactions
jwdunn1commented, Mar 3, 2022

One other thing to try. If you are using a lighting model in your draw loop, be sure to turn that off in the HUD, otherwise objects are shaded using that lighting model. This would affect how fonts are shaded too. For example, if the standard lighting model lights() is called in the draw loop, then call noLights() in the HUD code. I’ve updated the sketch so you can try it there first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix poor font-rendering in Chrome on Windows (Example)
After going through a short wizard, this will fix some of the text rendering issues in Chrome. Enable "Disable accelerated 2D Canvas" in ......
Read more >
Canvas text rendering (blurry) - javascript
It works by rendering the text at 3 times the normal width. ... result of webGl rendered content to a 2D canvas is...
Read more >
How to Fix Google Chrome Font Rendering Issues
I've been having a heck of a time with terrible font rendering in Chrome. ... In my case, “GPU Accelerated Canvas 2D” was...
Read more >
Font renders at low resolution to viewport when main ...
Font renders at low resolution to viewport when main window is scaled #65172 ... Use the 2d stretch mode (not viewport ) and...
Read more >
r/opengl - Text Rendering Help
Hey everyone just have a quick question. Been working on a 2D game lately and made a system to easily change the UI...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found