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

difference in text position with processing 4.3, JAVA2D vs P2D #768

Closed
clankill3r opened this issue Aug 10, 2023 · 1 comment
Closed

difference in text position with processing 4.3, JAVA2D vs P2D #768

clankill3r opened this issue Aug 10, 2023 · 1 comment

Comments

@clankill3r
Copy link

Processing 4.2:

mask_4 2

Processing 4.3:

mask_4 3

Ok, I will skip the part explaining that I'm an idiot.

The above difference comes from the following revision in 4.3:

"Use calculated text height instead of OS ascent for better vertical centering. Note: this may cause some sketches to look slightly different if textAlign(..., CENTER) is being used."
#739

Which is amazing it has been fixed!
Downside is that for OpenGL it's still like the old way.
Looking at the code it seems an easy fix (same as the fix for JAVA2D), which is commenting most code so it's just using super.textAscent();

https://github.com/processing/processing4/blob/c57069fdca888e614bf52caa4cb7999277ae32e0/core/src/processing/opengl/PGraphicsOpenGL.java#L3430C14-L3430C14

If such a fix would be implemented, then one extra thing that could be considered is deprecating the following two functions in PJOGL.java:

 @Override
  protected int getFontAscent(Object font) {
    return getFontMetrics((Font) font).getAscent();
  }


  @Override
  protected int getFontDescent(Object font) {
    return getFontMetrics((Font) font).getDescent();
  }
@benfry benfry closed this as completed in adbcf0f Aug 10, 2023
@benfry
Copy link
Owner

benfry commented Aug 10, 2023

Ok, all set for the next release; probably 4.3.1.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants