Community
Participate
Working Groups
Created attachment 173992 [details] Test_project_swt3.6 Windows: I don't use StyledText to draw strikeout or underline text, but using LOGFONT in fontdata instead. try { Class logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$ Object logFont = FontData.class.getField("data").get(fontdata); //$NON-NLS-1$ if (logFont != null && logFontClass != null) { logFontClass.getField("lfStrikeOut").set(logFont, new Byte((byte)1)); //$NON-NLS-1$ } } catch (Throwable ex) { System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + ex); //$NON-NLS-1$ //$NON-NLS-2$ } I remembered that my code runs well in swt 3.5, but after moving to swt 3.6, strikeout or underline text is disappeared. I found that strikeout or underline text only shows when advance mode is OFF. Is it a bug? Or, you prevent using LOGFONT directly in swt 3.6? I attached my test project for your reference.
You are using reflection to access internal data. This is not supported, I will have to close this bug as wont fix. Why don't you use TextLayout to draw underlined/strikeout text ?
I wanna keep all info in FontData, using gc.drawText() is enough to me. If swt does not support it, why I can draw strikeout or underline text with that way? And, it works well in swt 3.5 too. Please consider it again. Thanks.
(In reply to comment #2) > I wanna keep all info in FontData, using gc.drawText() is enough to me. > If swt does not support it, why I can draw strikeout or underline text with > that way? You are using win32 internals directly, I can't guarantee it will always work. In advance mode we use GdiFont instead of LOGFONT. In windows 7 we plan on using Direct2D in the future (again, LOGFONT won't be used). Even on GDI, setting lfStrikeOut only works when logical font supports it natively. Why can you use TextLayout ? gc.drawText() is not enough for you, it does not have underline that you need.
Ok, I see, thanks for your explanation.