mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
improves font rendering
This commit is contained in:
committed by
Federico Fissore
parent
725dffa69e
commit
ff49809d77
@ -153,16 +153,16 @@ public class EditorHeader extends JComponent {
|
|||||||
|
|
||||||
Graphics g = offscreen.getGraphics();
|
Graphics g = offscreen.getGraphics();
|
||||||
if (font == null) {
|
if (font == null) {
|
||||||
font = Theme.getFont("header.text.font");
|
font = Theme.getDefaultFont(); // Get optimal font.
|
||||||
|
if(font == null) font = Theme.getFont("header.text.font");
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setFont(font); // need to set this each time through
|
g.setFont(font); // need to set this each time through
|
||||||
metrics = g.getFontMetrics();
|
metrics = g.getFontMetrics();
|
||||||
fontAscent = metrics.getAscent();
|
fontAscent = metrics.getAscent();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
//g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
|
||||||
// RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
|
||||||
|
|
||||||
// set the background for the offscreen
|
// set the background for the offscreen
|
||||||
g.setColor(backgroundColor);
|
g.setColor(backgroundColor);
|
||||||
@ -182,9 +182,8 @@ public class EditorHeader extends JComponent {
|
|||||||
code.getPrettyName() : code.getFileName();
|
code.getPrettyName() : code.getFileName();
|
||||||
|
|
||||||
// if modified, add the li'l glyph next to the name
|
// if modified, add the li'l glyph next to the name
|
||||||
String text = " " + codeName + (code.isModified() ? " \u00A7" : " ");
|
String text = " " + codeName + " ";
|
||||||
|
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
|
||||||
int textWidth = (int)
|
int textWidth = (int)
|
||||||
font.getStringBounds(text, g2.getFontRenderContext()).getWidth();
|
font.getStringBounds(text, g2.getFontRenderContext()).getWidth();
|
||||||
|
|
||||||
@ -207,8 +206,17 @@ public class EditorHeader extends JComponent {
|
|||||||
g.setColor(textColor[state]);
|
g.setColor(textColor[state]);
|
||||||
int baseline = (sizeH + fontAscent) / 2;
|
int baseline = (sizeH + fontAscent) / 2;
|
||||||
//g.drawString(sketch.code[i].name, textLeft, baseline);
|
//g.drawString(sketch.code[i].name, textLeft, baseline);
|
||||||
|
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
|
|
||||||
g.drawString(text, textLeft, baseline);
|
g.drawString(text, textLeft, baseline);
|
||||||
|
|
||||||
|
if(code.isModified()){
|
||||||
|
g.setColor(Color.RED);
|
||||||
|
g.drawString("*", textLeft - 3, baseline);
|
||||||
|
}
|
||||||
|
|
||||||
g.drawImage(pieces[state][RIGHT], x, 0, null);
|
g.drawImage(pieces[state][RIGHT], x, 0, null);
|
||||||
x += PIECE_WIDTH - 1; // overlap by 1 pixel
|
x += PIECE_WIDTH - 1; // overlap by 1 pixel
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user