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

#414: slow StyledTextRenderer for unicode and unprintable control characters #1425

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2854,6 +2854,13 @@ public boolean isDisposed () {
return device == null;
}

private char replaceBelowSpaceCharacters(char chr) {
return chr >= ' '
? chr
//: (char)(0x2400 + chr);
: ' ';
}

/*
* Itemize the receiver text
*/
Expand Down Expand Up @@ -2895,8 +2902,11 @@ StyleItem[] itemize () {
*/
for (int i = 0, latestNeutralIndex = -2, latestUnicodeIndex = -2; i < length; i++) {
char c = chars[i];
if (c < ' ') {
c = replaceBelowSpaceCharacters(c);
}

if (c >= ' ' && c <= '~' && !Character.isAlphabetic(c)) {
if (c <= '~' && !Character.isAlphabetic(c)) {
latestNeutralIndex = i;
} else if (c > 255) {
latestUnicodeIndex = i;
Expand Down Expand Up @@ -3740,6 +3750,9 @@ void shape (GC gc, final long hdc, final StyleItem run) {
final int[] buffer = new int[1];
final char[] chars = new char[run.length];
segmentsText.getChars(run.start, run.start + run.length, chars, 0);
for (int i = 0; i < chars.length; i++) {
chars[i] = replaceBelowSpaceCharacters(chars[i]);
}

final int maxGlyphs = (chars.length * 3 / 2) + 16;
long hHeap = OS.GetProcessHeap();
Expand Down
Loading