Note that there are some explanatory texts on larger screens.

plurals
  1. POSwing text looks bad
    primarykey
    data
    text
    <p>I am overriding the paintComponent() method of a JCOmponent and drawing text in a window. I'm running on Ubuntu and using the font "Ubuntu Mono" (the default font for the Ubuntu text editor). When my java app displays the text, it looks wimpy and blurry. What am I doing wrong?</p> <p>I'm drawing the text like this:</p> <pre><code>graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); Font font = new Font("Ubuntu Mono", Font.PLAIN, 18); fontMetrics = graphics.getFontMetrics(font); graphics.setFont(font); graphics.drawString(value, getX(), getY() + fontMetrics.getHeight()); </code></pre> <p>In my java app, it looks like this:</p> <p><img src="https://i.stack.imgur.com/aG3Kh.png" alt="Java app text"></p> <p>In the Ubuntu TextEditor, it looks like this:</p> <p><img src="https://i.stack.imgur.com/XRioE.png" alt="enter image description here"></p> <p>Edit: Would performance suffer if <code>.png</code> images were used instead of <code>drawText()</code>? This is a business application, not a game that requires smooth animation.</p> <p>Edit: I changed the colors to match TextEditor's colors and that actually helped a little on the quality, but the characters are still so much thinner... you almost can't see a ".". In gimp I can recreate the TextEditor look by creating text w/ the right font w/ antialiasing on.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload