Community
Participate
Working Groups
Build Identifier: Font scaling calculation is incorrect in the Web Page Editor for some GTK/Linux environments Running these OS commands from the terminal window shows what the environment is reporting as the DPI for the display and the DPI for the fonts. xdpyinfo | grep dimension dimensions: 1920x1080 pixels (212x159 millimeters) xdpyinfo | grep resolution resolution: 230x173 dots per inch xrdb -query |grep dpi Xft.dpi: 96 ..Now, the CSSFontManager class from the jst.pagedesigner plugin is calculating the FONT_SCALE like this: // the scale to convert the px to pt. private final static double FONT_SCALE = ((double) Display.getCurrent() .getDPI().x) / 72; Unfortunately, the value returned by the Display.getCurrent().getDPI().x call appears to be the DPI for the screen (230), not the DPI for the font (96). This results in the fonts being scaled down way too much, less than half of the expected size in this case and text becomes unreadable. The font size looks correct if I manually change the DPI to 96 in the debugger. Is there some way to get the font DPI from SWT to calculate the right scaling factor? Or can we have a system property that can be manually set to force a specific value for the font DPI in this calculation? Reproducible: Always Steps to Reproduce: 1.In an ubuntu 10 environment, create a project and add an html file. 2.Open the html file in the 'Web Page Editor' editor 3.Add some text to the body of the html file 4.See that the font size in the design panel is really small 5.Switch to the 'Preview' tab of the editor and see the font with a more reasonable font size.
Created attachment 209327 [details] Screenshot that shows the font size in the design tab
Created attachment 209328 [details] Screenshot that shows the font size in the preview tab
The following code change to CSSFontManager seems to work for me, but maybe there is a better way to do it: // the scale to convert the px to pt. private final static double FONT_SCALE = fontDpi() / 72; //get the font DPI from the display or a system property static double fontDpi() { double fontDpi = -1; if ("gtk".equals(SWT.getPlatform())) { //check if AWT has a value for the gnome font DPI Object value = Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/DPI"); if (value instanceof Integer) { fontDpi = (double)(((Integer)value).intValue() / 1024); if (fontDpi == -1) { fontDpi = 96; } if (fontDpi < 50) { fontDpi = 50; } } } if (fontDpi == -1) { //fallback to the DPI reported by the display fontDpi = (double)Display.getCurrent().getDPI().x; } return fontDpi; }
We will review. Thanks for providing a possible fix.
Is there any chance of getting a fix for this issue? The WTP html editor is not usable in the current state.
We will review for M7.
Relevant discussion: https://www.java.net//node/672090
Fixed and committed: http://git.eclipse.org/c/jsf/webtools.jsf.git/commit/?id=5db5a4437a44464107a96de7684930213a481d9e