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

Minor corrections regarding of the text function. #5885

Merged
merged 2 commits into from
Dec 5, 2022
Merged

Minor corrections regarding of the text function. #5885

merged 2 commits into from
Dec 5, 2022

Conversation

inaridarkfox4231
Copy link
Contributor

there are two problems:

  1. If you specify CENTER or BOTTOM for the second argument of textAlign without the 4th and 5th arguments of the text function, some lines will disappear.
  2. If CENTER is specified for rectMode, some lines may disappear when box is set by the text function.

These fixes are meant to resolve these issues.

Resolves: #5880

Changes:

sampleCode for problem 1

function setup() {
  createCanvas(400, 400);
  background(0);
  noStroke();
  fill(255);

  textSize(18);
  textAlign(CENTER, TOP);
  text("first\nsecond\nthird", 80, 200);
  textAlign(CENTER, BASELINE);
  text("first\nsecond\nthird", 160, 200);
  textAlign(CENTER, BOTTOM);
  text("first\nsecond\nthird", 240, 200);
  textAlign(CENTER, CENTER);
  text("first\nsecond\nthird", 320, 200);

  textSize(14);
  text("TOP", 80, 120);
  text("BASELINE", 160, 120);
  text("BOTTOM", 240, 120);
  text("CENTER", 320, 120);
  stroke(255);
  line(0,200,400,200);
}

left: before change. right: after change.
Screenshots of the change:
screenShot1

sampleCode for problem 2

function setup() {
  createCanvas(400, 400);
  background(0);
  noStroke();
  fill(255);
  rectMode(CENTER);

  textSize(24);
  textAlign(CENTER, BASELINE);
  text("first\nsecond\nthird\nfourth", 50, 200, 100, 400);
  textAlign(CENTER, TOP);
  text("first\nsecond\nthird\nfourth", 150, 200, 100, 400);
  textAlign(CENTER, CENTER);
  text("first\nsecond\nthird\nfourth", 250, 200, 100, 400);
  textAlign(CENTER, BOTTOM);
  text("first\nsecond\nthird\nfourth", 350, 200, 100, 400);

  noFill();
  stroke(255);
  rect(50, 200, 100, 400);
  rect(150, 200, 100, 400);
  rect(250, 200, 100, 400);
  rect(350, 200, 100, 400);
}

left: before change. right: after change.
Screenshots of the change:
screenShot2

PR Checklist

  • TypoGraphy

there are two problems:
1. If you specify CENTER or BOTTOM for the second argument of textAlign without the 4th and 5th arguments of the text function, some lines will disappear.
2. If CENTER is specified for rectMode, some lines may disappear when box is set by the text function.
These fixes are meant to resolve these issues.
@welcome
Copy link

welcome bot commented Dec 5, 2022

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!

@dhowe dhowe self-requested a review December 5, 2022 11:21
Copy link
Contributor

@dhowe dhowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good to me. A bit unusual perhaps to put 2 statements on one line (as in 270), but it seems to pass the linter, so all good

@dhowe
Copy link
Contributor

dhowe commented Dec 5, 2022

@raclim looks good to merge - 2 fixes to live bugs with text-alignment

@inaridarkfox4231
Copy link
Contributor Author

I'm sorry, it would have been better to split it into two lines...is it okay to leave it as is?

@dhowe
Copy link
Contributor

dhowe commented Dec 5, 2022

Perhaps update the PR -- just for practice :)

two statements on line 270 split to two lines.
Copy link
Contributor

@dhowe dhowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great

@inaridarkfox4231
Copy link
Contributor Author

thank you very much for advice! ('ω')

@dhowe
Copy link
Contributor

dhowe commented Dec 5, 2022

thank you very much for advice! ('ω')

thanks for the fix!

@Qianqianye Qianqianye merged commit c070566 into processing:main Dec 5, 2022
@Qianqianye
Copy link
Contributor

Thank you @inaridarkfox4231 and @dhowe ✨!

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

Successfully merging this pull request may close these issues.

vertical textAlign center broken in 1.5.0 when printing multiple lines
4 participants