Skip to content

Commit c2d9a1b

Browse files
improves font rendering
1 parent 45c5228 commit c2d9a1b

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

app/src/processing/app/EditorHeader.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ public void paintComponent(Graphics screen) {
153153

154154
Graphics g = offscreen.getGraphics();
155155
if (font == null) {
156-
font = Theme.getFont("header.text.font");
156+
font = Theme.getDefaultFont(); // Get optimal font.
157+
if(font == null) font = Theme.getFont("header.text.font");
157158
}
159+
158160
g.setFont(font); // need to set this each time through
159161
metrics = g.getFontMetrics();
160162
fontAscent = metrics.getAscent();
161163
//}
162164

163-
//Graphics2D g2 = (Graphics2D) g;
164-
//g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
165-
// RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
165+
Graphics2D g2 = (Graphics2D) g;
166166

167167
// set the background for the offscreen
168168
g.setColor(backgroundColor);
@@ -182,9 +182,8 @@ public void paintComponent(Graphics screen) {
182182
code.getPrettyName() : code.getFileName();
183183

184184
// if modified, add the li'l glyph next to the name
185-
String text = " " + codeName + (code.isModified() ? " \u00A7" : " ");
185+
String text = " " + codeName + " ";
186186

187-
Graphics2D g2 = (Graphics2D) g;
188187
int textWidth = (int)
189188
font.getStringBounds(text, g2.getFontRenderContext()).getWidth();
190189

@@ -207,7 +206,16 @@ public void paintComponent(Graphics screen) {
207206
g.setColor(textColor[state]);
208207
int baseline = (sizeH + fontAscent) / 2;
209208
//g.drawString(sketch.code[i].name, textLeft, baseline);
209+
210+
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
211+
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
212+
210213
g.drawString(text, textLeft, baseline);
214+
215+
if(code.isModified()){
216+
g.setColor(Color.RED);
217+
g.drawString("*", textLeft - 3, baseline);
218+
}
211219

212220
g.drawImage(pieces[state][RIGHT], x, 0, null);
213221
x += PIECE_WIDTH - 1; // overlap by 1 pixel

0 commit comments

Comments
 (0)