Commit 58993b97 authored by Skylot's avatar Skylot

fix(gui): apply render hints for line numbers

parent a3464d71
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment