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

Wrong measure text field width in BitmapFontTextRenderer #1676

Open
Yaniko opened this issue Dec 30, 2017 · 6 comments
Open

Wrong measure text field width in BitmapFontTextRenderer #1676

Yaniko opened this issue Dec 30, 2017 · 6 comments
Labels

Comments

@Yaniko
Copy link

Yaniko commented Dec 30, 2017

There is an error in measuring white space after a symbol. Current code is like (previousCharData.xAdvance - previousCharData.width) * scale;
Lines
https://github.com/BowlerHatLLC/feathers/blob/master/source/feathers/controls/text/BitmapFontTextRenderer.as#L806
https://github.com/BowlerHatLLC/feathers/blob/master/source/feathers/controls/text/BitmapFontTextRenderer.as#L833
and others.
metrics

The right formulae is xAdvance - width - xOffset, because char.width doesn't contain xOffset.
xAdvance = xOffset + width + someSpaceAfter
Because of that issue some chars (like colon) get cropped from the right in a textfield with TextAlign.RIGHT

@joshtynjala
Copy link
Member

Thanks, I'll take a look soon!

@joshtynjala joshtynjala added the bug label Jan 2, 2018
@joshtynjala joshtynjala added this to the 3.5 milestone Jan 2, 2018
joshtynjala added a commit that referenced this issue Mar 27, 2018
…t off on the end of the line because measurement didn't account for removing xOffset from whitespace after the final letter (closes #1676)"

This reverts commit 12609c3.
@joshtynjala joshtynjala reopened this Mar 27, 2018
@joshtynjala
Copy link
Member

Switching to xAdvance - width - xOffset doesn't seem to work in some cases. According to another user who has tried the new code, this change causes BitmapFontTextRenderer to begin truncating text where it hadn't previously. Since that's not good at all, I have reverted this commit for now.

Unfortunately, the bitmap fonts that I've tested with cannot reproduce your issue, and I could not reproduce the new issue either. I guess it depends on the exact bitmap font that you use.

@joshtynjala joshtynjala removed this from the 3.5 milestone Mar 27, 2018
@Yaniko
Copy link
Author

Yaniko commented Mar 28, 2018

We use fonts with shadows generated in literra.
Extra truncating means text size become wider. And that means xOffset is negative? Really strange.

@Yaniko
Copy link
Author

Yaniko commented Mar 28, 2018

Sorry, I was wrong in my last message.
Of course strings become wider, because we subtract some positive value from whitespace. It makes sense.
Have you tried textalign.Right?

@joshtynjala
Copy link
Member

No, I have not been able to reproduce with text aligned to the right either.

@divlaine
Copy link

divlaine commented May 22, 2018

a few days ago i tried textalign.Right on a label with backgroundskin and saw the text was out from label's borders. i can try to reproduce it and make screenshots if you want

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

No branches or pull requests

3 participants