mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Fix for some font rendering problems on linux
This commit is contained in:
parent
3928b6a04f
commit
08ad60032f
@ -35,6 +35,8 @@ import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Map;
|
||||
|
||||
import processing.app.Theme;
|
||||
|
||||
public class SplashScreenHelper {
|
||||
|
||||
private static final int X_OFFSET = 0;
|
||||
@ -96,7 +98,7 @@ public class SplashScreenHelper {
|
||||
private void prepareTextAreaAndGraphics() {
|
||||
splashTextArea = new Rectangle2D.Double(X_OFFSET, Y_OFFSET, TEXTAREA_WIDTH, TEXTAREA_HEIGHT);
|
||||
|
||||
splashGraphics = splash.createGraphics();
|
||||
splashGraphics = Theme.setupGraphics2D(splash.createGraphics());
|
||||
|
||||
if (desktopHints != null) {
|
||||
splashGraphics.addRenderingHints(desktopHints);
|
||||
|
@ -1745,13 +1745,10 @@ public class Base {
|
||||
final Image image = Theme.getLibImage("about", activeEditor,
|
||||
Theme.scale(475), Theme.scale(300));
|
||||
final Window window = new Window(activeEditor) {
|
||||
public void paint(Graphics g) {
|
||||
public void paint(Graphics graphics) {
|
||||
Graphics2D g = Theme.setupGraphics2D(graphics);
|
||||
g.drawImage(image, 0, 0, null);
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
||||
|
||||
Font f = new Font("SansSerif", Font.PLAIN, Theme.scale(11));
|
||||
g.setFont(f);
|
||||
g.setColor(Color.white);
|
||||
|
@ -222,18 +222,13 @@ public class EditorHeader extends JComponent {
|
||||
offscreen = createImage(imageW, imageH);
|
||||
}
|
||||
|
||||
Graphics g = offscreen.getGraphics();
|
||||
Graphics2D g = Theme.setupGraphics2D(offscreen.getGraphics());
|
||||
if (font == null) {
|
||||
font = Theme.getFont("header.text.font");
|
||||
}
|
||||
g.setFont(font); // need to set this each time through
|
||||
metrics = g.getFontMetrics();
|
||||
fontAscent = metrics.getAscent();
|
||||
//}
|
||||
|
||||
//Graphics2D g2 = (Graphics2D) g;
|
||||
//g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
// RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
|
||||
// set the background for the offscreen
|
||||
g.setColor(backgroundColor);
|
||||
@ -255,10 +250,8 @@ public class EditorHeader extends JComponent {
|
||||
// if modified, add the li'l glyph next to the name
|
||||
String text = " " + codeName + (code.isModified() ? " \u00A7" : " ");
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
|
||||
int textWidth = (int)
|
||||
font.getStringBounds(text, g2.getFontRenderContext()).getWidth();
|
||||
font.getStringBounds(text, g.getFontRenderContext()).getWidth();
|
||||
|
||||
int pieceCount = 2 + (textWidth / PIECE_WIDTH);
|
||||
int pieceWidth = pieceCount * PIECE_WIDTH;
|
||||
|
@ -89,7 +89,8 @@ public class EditorLineStatus extends JComponent {
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
public void paintComponent(Graphics graphics) {
|
||||
Graphics2D g = Theme.setupGraphics2D(graphics);
|
||||
if (name == "" && serialport == "") {
|
||||
PreferencesMap boardPreferences = BaseNoGui.getBoardPreferences();
|
||||
if (boardPreferences != null)
|
||||
|
@ -218,15 +218,15 @@ public class EditorStatus extends JPanel {
|
||||
offscreen = createImage(imageW, imageH);
|
||||
}
|
||||
|
||||
Graphics graphics = offscreen.getGraphics();
|
||||
graphics.setColor(BGCOLOR[mode]);
|
||||
graphics.fillRect(0, 0, imageW, imageH);
|
||||
graphics.setColor(FGCOLOR[mode]);
|
||||
Graphics2D g = Theme.setupGraphics2D(offscreen.getGraphics());
|
||||
g.setColor(BGCOLOR[mode]);
|
||||
g.fillRect(0, 0, imageW, imageH);
|
||||
g.setColor(FGCOLOR[mode]);
|
||||
|
||||
graphics.setFont(font); // needs to be set each time on osx
|
||||
int ascent = graphics.getFontMetrics().getAscent();
|
||||
g.setFont(font); // needs to be set each time on osx
|
||||
int ascent = g.getFontMetrics().getAscent();
|
||||
assert message != null;
|
||||
graphics.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2);
|
||||
g.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2);
|
||||
|
||||
screen.drawImage(offscreen, 0, 0, null);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
|
||||
x1[SERIAL] = width - BUTTON_WIDTH - 14;
|
||||
x2[SERIAL] = width - 14;
|
||||
}
|
||||
Graphics g = offscreen.getGraphics();
|
||||
Graphics2D g = Theme.setupGraphics2D(offscreen.getGraphics());
|
||||
g.setColor(bgcolor); //getBackground());
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
|
@ -26,6 +26,8 @@ import static processing.app.I18n.tr;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.MediaTracker;
|
||||
import java.awt.RenderingHints;
|
||||
@ -287,4 +289,13 @@ public class Theme {
|
||||
return Toolkit.getDefaultToolkit().createImage(imgData);
|
||||
}
|
||||
|
||||
static public Graphics2D setupGraphics2D(Graphics graphics) {
|
||||
Graphics2D g = (Graphics2D) graphics;
|
||||
if (PreferencesData.getBoolean("editor.antialias")) {
|
||||
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user