Here you can find the source of setTextRenderingHints(Graphics2D g2d)
public static void setTextRenderingHints(Graphics2D g2d)
//package com.java2s; //License from project: Apache License import java.awt.Graphics2D; import java.awt.RenderingHints; public class Main { public static void setTextRenderingHints(Graphics2D g2d) { // This time, we want to use anti-aliasing if possible to avoid the // jagged edges // With the Java 2D rendering engine (Graphics2D) to do this using a // "rendering hint". // RenderingHints rh = g2d.getRenderingHints(); // Initially set to VALUE_TEXT_ANTIALIAS_GASP RenderingHints rh = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); rh.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); rh.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); rh.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF); rh.put(RenderingHints.KEY_TEXT_LCD_CONTRAST, new Integer(140)); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT); // rh.put(RenderingHints.KEY_COLOR_RENDERING, // RenderingHints.VALUE_COLOR_RENDER_QUALITY); // rh.put(RenderingHints.KEY_STROKE_CONTROL, // RenderingHints.VALUE_STROKE_NORMALIZE); // rh.put(RenderingHints.KEY_TEXT_ANTIALIASING, // RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); // System.out.println("\n\nRendering Hints:\n" + rh.toString()); g2d.setRenderingHints(rh);/*from ww w . j a v a 2 s.c o m*/ } public static void setRenderingHints(Graphics2D g2d) { // This time, we want to use anti-aliasing if possible to avoid the // jagged edges // With the Java 2D rendering engine (Graphics2D) to do this using a // "rendering hint". RenderingHints rh = g2d.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); // rh.put(RenderingHints.KEY_COLOR_RENDERING, // RenderingHints.VALUE_COLOR_RENDER_QUALITY); // rh.put(RenderingHints.KEY_ALPHA_INTERPOLATION, // RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); // rh.put(RenderingHints.KEY_TEXT_ANTIALIASING, // RenderingHints.VALUE_TEXT_ANTIALIAS_ON); // rh.put(RenderingHints.KEY_FRACTIONALMETRICS, // RenderingHints.VALUE_FRACTIONALMETRICS_ON); g2d.setRenderingHints(rh); } }