data.stringPtr = ptr;
int setString(String string, int flags) {	if (string == data.string && (flags & ~SWT.DRAW_TRANSPARENT) == (data.drawFlags & ~SWT.DRAW_TRANSPARENT)) {		return data.stringLength;	}	if (data.stringPtr != 0) OS.DisposePtr(data.stringPtr);	data.stringPtr = 0;	int layout = data.layout;	int length = string.length();	char[] chars = new char[length];	string.getChars(0, length, chars, 0);	int breaks[] = null;	if ((flags & (SWT.DRAW_MNEMONIC | SWT.DRAW_DELIMITER)) != 0) {		int i=0, j=0;		while (i < chars.length) {			char c = chars [j++] = chars [i++];			if (c == '&' && (flags & SWT.DRAW_MNEMONIC) != 0) {				if (i == chars.length) {continue;}				if (chars [i] == '&') {i++; continue;}				j--;			} else if (c == '\n' && (flags & SWT.DRAW_DELIMITER) != 0) {				j--;				if (breaks == null) {					breaks = new int[1];				} else {					int[] newBreaks = new int[breaks.length + 1];					System.arraycopy(breaks, 0, newBreaks, 0, breaks.length);					breaks = newBreaks;				}				breaks[breaks.length - 1] = j;			}					}		length = j;	}	if ((flags & SWT.DRAW_TAB) != 0) {		if (data.tabs == 0) createTabs ();		OS.ATSUSetTabArray(layout, data.tabs, TAB_COUNT);	} else {		OS.ATSUSetTabArray(layout, 0, 0);	}	int ptr = OS.NewPtr(length * 2);	OS.memcpy(ptr, chars, length * 2);	OS.ATSUSetTextPointerLocation(layout, ptr, 0, length, length);	if ((flags & SWT.DRAW_DELIMITER) != 0 && breaks != null) {		for (int i=0; i<breaks.length; i++) {			OS.ATSUSetSoftLineBreak(layout, breaks[i]);		}	}	Font font = data.font;	int atsuiStyle = font.atsuiStyle != 0 ? font.atsuiStyle : data.atsuiStyle;	OS.ATSUSetRunStyle(layout, atsuiStyle, 0, length);	OS.ATSUSetTransientFontMatching(layout, true);	data.string = string;	data.stringLength = length;	data.drawFlags = flags;	data.stringPtr = ptr;	return length;}