JRE-616 [linux] notify when dpi correction factor is applied to fonts

(cherry picked from commit f57d41f3118bfd773c99ce32d58cfae16931be6a)
(cherry picked from commit 6246abc72f)
This commit is contained in:
Anton Tarasov
2017-12-28 17:39:18 +03:00
committed by alexey.ushakov@jetbrains.com
parent e216912bfa
commit 43690295e3
3 changed files with 15 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ import java.awt.geom.AffineTransform;
import javax.swing.plaf.FontUIResource;
import java.util.StringTokenizer;
import sun.awt.AWTAccessor;
import sun.font.FontConfigManager;
import sun.font.FontUtilities;
@@ -161,8 +162,8 @@ class PangoFonts {
*/
double dsize = size;
int dpi = 96;
Object value =
Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/DPI");
Object xftDPI = Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/DPI");
Object value = xftDPI;
if (!(value instanceof Integer)) {
value = GTKEngine.INSTANCE.getSetting(GTKEngine.Settings.GTK_XFT_DPI);
@@ -179,6 +180,12 @@ class PangoFonts {
* 72 dpi, so we need to adjust for that.
*/
dsize = ((double)(dpi * size)/ 72.0);
if (xftDPI == null) {
// [tav] used to indicate the 96/72 scale correction to the client app
AWTAccessor.getToolkitAccessor().setDesktopProperty(
Toolkit.getDefaultToolkit(), "gnome.Xft/DPI", value);
}
} else {
/* If there's no property, GTK scales for the resolution
* reported by the Xserver using the formula listed above.

View File

@@ -1397,6 +1397,11 @@ public abstract class Toolkit {
public void setPlatformResources(ResourceBundle bundle) {
Toolkit.setPlatformResources(bundle);
}
@Override
public void setDesktopProperty(Toolkit tk, String prop, Object value) {
tk.setDesktopProperty(prop, value);
}
});
java.security.AccessController.doPrivileged(

View File

@@ -767,6 +767,7 @@ public final class AWTAccessor {
*/
public interface ToolkitAccessor {
void setPlatformResources(ResourceBundle bundle);
void setDesktopProperty(Toolkit tk, String prop, Object value);
}
/*