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

Crash: pasting 💁👌🎍😍 in a textbox crashes #446

Closed
NinthDesertDude opened this issue Dec 27, 2023 · 5 comments
Closed

Crash: pasting 💁👌🎍😍 in a textbox crashes #446

NinthDesertDude opened this issue Dec 27, 2023 · 5 comments

Comments

@NinthDesertDude
Copy link

NinthDesertDude commented Dec 27, 2023

Repro using this string: 💁👌🎍😍

In TextChunk.cs, this is the problematic function:

public TextChunkGlyph? GetGlyphInfoByIndex(int index)
{
	if (string.IsNullOrEmpty(Text) || index < 0 || index >= Text.Length)
	{
		return null;
	}
	return Glyphs[index];

We have index = 7 because each emoji is composed of 2 characters due to being Unicode. Text.Length is 8. Glyphs is an array of size 4, because it's from FontStashSharp and they know we only have 4 characters here. We're trying to access index 7 in Glyphs, so we get
System.ArgumentOutOfRangeException: 'Index was out of range.'

@rds1983
Copy link
Owner

rds1983 commented Dec 27, 2023

wondering, would it work in Label?

@NinthDesertDude
Copy link
Author

@rds1983 It's blank, it doesn't display the text but it does not crash.

@rds1983
Copy link
Owner

rds1983 commented Dec 27, 2023

yeah, probably default font ttf simply doesnt have glyphs for it

@NinthDesertDude
Copy link
Author

Updated with the exact issue in source code. Hopefully FontStashSharp has a way to read the number of characters that're in a codepoint, because all navigation in the textbox would have to start doing that to deal with this scenario...alternatively, handle this crash by rejecting typed or pasted content that would result in Text.Length not matching the Glyphs array size (basically forcing glyph to be only one character long) until generic Unicode support can be done.

@rds1983
Copy link
Owner

rds1983 commented Dec 28, 2023

Should be fixed after updating to FSS 1.3.5

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

No branches or pull requests

2 participants