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

Support wrapping ex.Text graphics #2463

Closed
eonarheim opened this issue Aug 16, 2022 · 3 comments · Fixed by #2472
Closed

Support wrapping ex.Text graphics #2463

eonarheim opened this issue Aug 16, 2022 · 3 comments · Fixed by #2472
Labels
stale This issue or PR has not had any activity recently

Comments

@eonarheim
Copy link
Member

Context

Currently it is not possible to wrap text graphics inside a bounding box without some manual intervention or custom code.

See discussion for more context #2458 (reply in thread)

Proposal

Implement simple text wrapping given a optional maximum width or an optional containing bounding box.

Perhaps ex.Text.maxWidth or ex.Text.textContainer?

const text = new ex.Text({
  ...
  maxWidth: 200 // pixels
});
const text = new ex.Text({
  ...
  textContainer: ex.BoundingBox.fromDimension(200, 200); // 200x200 box
});
@github-actions
Copy link

This issue hasn't had any recent activity lately and is being marked as stale automatically.

@github-actions github-actions bot added the stale This issue or PR has not had any activity recently label Oct 16, 2022
@DaVince
Copy link
Contributor

DaVince commented Oct 26, 2022

+1 for having a textContainer property containing a BoundingBox. Special care would then be given to also respect the text container height so it doesn't render text beyond the given bounding box.

@github-actions github-actions bot removed the stale This issue or PR has not had any activity recently label Oct 27, 2022
@github-actions
Copy link

This issue hasn't had any recent activity lately and is being marked as stale automatically.

@github-actions github-actions bot added the stale This issue or PR has not had any activity recently label Dec 27, 2022
eonarheim pushed a commit that referenced this issue Jan 14, 2023
Closes #2463

## Changes:

- Add ```maxWidth``` TextOption to support word wrapping

Hi, I think I've progressed enough to post a draft PR. 
Currently wrapping works when the ```maxWidth``` option is provided for the ex.Text class.

There is a bug currently where text > 2 lines isn't rendered since I don't update the ```ex.Text``` height properly when we word wrap. 
If there is any other outstanding problems in the code/PR please let me know!

![Screenshot_2022-08-27_15-08-35](https://user-images.githubusercontent.com/6068039/187047307-b3c7561f-8d6e-4537-b470-c5f9a57e9f4b.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This issue or PR has not had any activity recently
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants