fix(gui): apply render hints for line numbers
This commit is contained in:
@@ -182,7 +182,7 @@ public class JadxSettingsWindow extends JDialog {
|
||||
int result = fontChooser.showDialog(JadxSettingsWindow.this);
|
||||
if (result == JFontChooser.OK_OPTION) {
|
||||
Font font = fontChooser.getSelectedFont();
|
||||
LOG.info("Selected Font : {}", font);
|
||||
LOG.debug("Selected Font: {}", font);
|
||||
settings.setFont(font);
|
||||
mainWindow.updateFont(font);
|
||||
mainWindow.loadSettings();
|
||||
|
||||
@@ -25,6 +25,7 @@ public class LineNumbers extends JPanel implements CaretListener {
|
||||
private static final long serialVersionUID = -4978268673635308190L;
|
||||
|
||||
private static final int NUM_HEIGHT = Integer.MAX_VALUE - 1000000;
|
||||
private static final Map<?, ?> DESKTOP_HINTS = (Map<?, ?>) Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints");
|
||||
|
||||
private CodeArea codeArea;
|
||||
private boolean useSourceLines = true;
|
||||
@@ -92,6 +93,7 @@ public class LineNumbers extends JPanel implements CaretListener {
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
g.setFont(codeArea.getFont());
|
||||
applyRenderHints(g);
|
||||
|
||||
FontMetrics fontMetrics = codeArea.getFontMetrics(codeArea.getFont());
|
||||
Insets insets = getInsets();
|
||||
@@ -119,6 +121,19 @@ public class LineNumbers extends JPanel implements CaretListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void applyRenderHints(Graphics g) {
|
||||
if (g instanceof Graphics2D) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
if (DESKTOP_HINTS != null) {
|
||||
g2d.setRenderingHints(DESKTOP_HINTS);
|
||||
} else {
|
||||
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCurrentLine(int rowStartOffset) {
|
||||
int caretPosition = codeArea.getCaretPosition();
|
||||
Element root = codeArea.getDocument().getDefaultRootElement();
|
||||
|
||||
Reference in New Issue
Block a user