Skip to content

Commit 3782670

Browse files
Font scaling fix for high resolution screen
2 parents 8886366 + e26a001 commit 3782670

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ target/classes/mdlaf/
99
target/
1010

1111
material-ui-swing.iml
12+
/.project
13+
/.settings/
14+
/.classpath

src/main/java/mdlaf/utils/MaterialFontFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,12 @@ public FontUIResource getFont(String typeFont){
117117
*/
118118
private Font loadFont(String fontPath) {
119119
if (fontSettings.isEmpty()) {
120-
fontSettings.put (TextAttribute.SIZE, new Float( 11 * Toolkit.getDefaultToolkit().getScreenResolution() / 72.0));
121-
//fontSettings.put (TextAttribute.SIZE, new Float( 14f));
120+
//fontSettings.put (TextAttribute.SIZE, new Float( 11 * Toolkit.getDefaultToolkit().getScreenResolution() / 72.0));
121+
//fontSettings.put (TextAttribute.SIZE, new Float( 11 * Toolkit.getDefaultToolkit().getScreenResolution() / 72.0));
122+
// The min function is used to keep this number to reasonable bounds in cases of high DPI displays
123+
// Known to cause issues with Windows 10 Display Scaling
124+
int resolution=Math.min(Toolkit.getDefaultToolkit().getScreenResolution(),96);
125+
fontSettings.put (TextAttribute.SIZE, 11.0f*resolution/72.0f);
122126
fontSettings.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
123127
}
124128

0 commit comments

Comments
 (0)