We use SWT browser in our java app to render HTML content. The problems arise when the environment has a very high resolution (4K). When the content has a such html:
<html> <head> <style> .test { font-size: 35px;font-family: Arial;} </style> </head><body><div class='test'>TEST</div></body></html>
And the used java source is:
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class SWTTest {
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("SWT test");
createContents(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
private void createContents(Shell shell) {
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.NONE);
browser.setText("<html> \r\n" +
"<head> <style> .test { font-size: 85px;font-family: Arial;} </style> </head>\r\n" +
"<body>\r\n" +
"<div class=\"test\">TEST</div>\r\n" +
"</body>\r\n" +
"</html>");
}
public static void main(String[] args) {
new SWTTest().run();
}
}
On regular environments with 1920x1080 and resolution is 96, the rendered content and the viewed content in the Internet Explorer are same (We save the example text html as a file and open with IE)
On some laptops where we have a resolution more than 128 and 4K dimensions, the rendered content has the elements (TEST div) with 35px font size very small compared to IE.
As we know SWT uses the underlying IE, but I think IE makes some post process operations to fine tune the content and fixes the element sizes depending on the screen properties (resolution etc), which is not done when called from SWT.
Any solution without modifying the html content?
System properties: OS: Windows 10 (updated) IE: 11 Java 1.8.161 (32bits) SWT: 4.3