Skip to content

[BUG]: measureText not respecting ctx.direction #2508

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

Open
ShaMan123 opened this issue Apr 28, 2025 · 1 comment · May be fixed by #2510
Open

[BUG]: measureText not respecting ctx.direction #2508

ShaMan123 opened this issue Apr 28, 2025 · 1 comment · May be fixed by #2510

Comments

@ShaMan123
Copy link
Contributor

ShaMan123 commented Apr 28, 2025

I have encountered this bug when using ctx.direction = 'rtl' and ctx.textAlign = 'start' | 'end'

It is clear that the code fails to first resolve start/end textAlign and therefore executes as if direction is ltr.

double x_offset;
switch (state->textAlignment) {
case TEXT_ALIGNMENT_CENTER:
x_offset = logical_rect.width / 2.;
break;
case TEXT_ALIGNMENT_END:
case TEXT_ALIGNMENT_RIGHT:
x_offset = logical_rect.width;
break;
case TEXT_ALIGNMENT_START:
case TEXT_ALIGNMENT_LEFT:
default:
x_offset = 0.0;
}

I am willing to PR.

@chearon
Copy link
Collaborator

chearon commented Apr 28, 2025

I would love a PR, thank you.

@ShaMan123 ShaMan123 linked a pull request Apr 30, 2025 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants