GUI: improved gui scale support (part of #969, #6887):

- added GUI scale support for dialog titles;
- added GUI scale support for hints tool;
- fixed broken font in chat and game logs on settings change;
- fixed wrong size of pick choice dialog in some use cases;
This commit is contained in:
Oleg Agafonov 2024-07-28 11:47:12 +04:00
parent 1578ab7946
commit 8186b35dfb
9 changed files with 56 additions and 26 deletions

View file

@ -17,7 +17,10 @@ import mage.view.PlaneView;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.text.html.CSS;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -52,6 +55,19 @@ public class MageEditorPane extends JEditorPane {
// improved style: browser's url style with underline on mouse over and hand cursor
kit.getStyleSheet().addRule(" a { text-decoration: none; } ");
changeGUISize(this.getFont());
}
public void changeGUISize(Font font) {
this.setFont(font);
// workaround to change editor's font at runtime
String bodyRule = "body { "
+ " font-family: " + font.getFamily() + "; "
+ " font-size: " + font.getSize() + "pt; "
+ "}";
kit.getStyleSheet().addRule(bodyRule);
}
/**
@ -264,6 +280,4 @@ public class MageEditorPane extends JEditorPane {
hyperlinkEnabled = true;
addHyperlinkHandlers();
}
}