MySQL Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP  MySQL Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python MySQL Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python MySQL Application Hosting Web Hosting website hosting, web site hosting, web page hosting Apache, PHP, MySQL, PERL, servlets Java, JSP,Python MySQL Application Hosting Web Hosting website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, JSP,Python
MySQL Application Hosting Web Hosting, website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, JSP, Python MySQL Application Hosting Web Hosting, website hosting, web site hosting, web page hosting, Apache, PHP, MySQL, PERL, servlets Java, Python,JSP
MySQL Application Hosting Web Hosting Sign-Up MySQL Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting  MySQL Application Hosting Resellers web hosting, website hosting, web site hosting MySQL Application Hosting EZ Site Control Panel for web hosting,website hosting, web site hosting
MySQL Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, Python,JSP,  Fundraising
MySQL Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting
WWW.

Call Us Toll-Free
(877) 256-0328

Outside USA
1 - (201) 505-0430

MySQL Application Hosting Welcome MySQL Application Hosting Web Hosting Plans Overview , Fund Raising, Fundraising, web hosting, website hosting, web site hosting MySQL Application Hosting Fund Raising, Fundraising, web hosting MySQL Application Hosting Resellers, web Hosting MySQL Application Hosting Web Design, web Hosting MySQL Application Hosting Extra Services,  web Hosting MySQL Application Hosting Traffic Booster, web hosting MySQL Application Hosting Traffic Booster, web hosting MySQL Application Hosting Technical Support,  web Hosting MySQL Application Hosting webmaster tips,  web Hosting MySQL Application Hosting 30 Day Money Back, web hosting MySQL Application Hosting Legal Notices for Web Hosting MySQL Application Hosting Glossary Computer Terms for web Hosting MySQL Application Hosting Contact Information - web hosting

Site Map
MySQL Application Hosting Web Hosting, website hosting, web site hosting , web page hosting Apache, PHP, MySQL, PERL, servlets Java, Python, JSP MySQL Application Hosting MySQL Application Hosting MySQL Application Hosting MySQL Application Hosting MySQL Application Hosting Displaying Antialiased Text by Using Rendering Hints (The Java™ Tutorials > 2D Graphics > Working with Text APIs)
Trail: 2D Graphics
Lesson: Working with Text APIs
Section: Advanced Text Display
Home Page > 2D Graphics > Working with Text APIs
Displaying Antialiased Text by Using Rendering Hints

Java 2D™ text rendering can be affected by rendering hints.

Recall that the most important text drawing method is the following:

 
Graphics.drawString(String s, int x, int y);
Usually, this method draws each glyph in a string of text with a solid color and each pixel that is “on” in that glyph is set to that colour. This type of drawing produces the highest contrast text, but sometimes with jagged (aliased) edges.

Text antialiasing is a technique used to smooth the edges of text on a screen. The Java 2D API enables applications to specify whether this technique should be used and what algorithm to use by applying a text rendering hint to the Graphics.

The most common rendering hint blends the foreground (text) color with the onscreen background pixels at the edges of the text. To request this hint an application must invoke the following:

graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                           (RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

The following figure illustrates the antialiasing capability.

This figure represents an antialiasing hint for the Hello World string.

If used inappropriately this method can make the text appear overly fuzzy. In such cases, a better hint to use is the following:

graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                           (RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);

This method automatically uses information in the font itself to decide whether to use antialiasing or to use solid colors.

LCD displays have a property that the Java 2D API can use to produce text that isn't as fuzzy as typical antialiasing but is more legible at small sizes. To request that text be drawn using the sub-pixel LCD text mode for a typical LCD display, an application must invoke the following:

graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                           (RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
The code example represented below illustrates the antialiasing capability in the following order:
  1. Antialiasing is off.
  2. Antialiasing is on.
  3. Antialiasing using the TEXT_ANTIALIAS_GASP hint.

  4. Note: Consequently the GASP table specifies to use only hinting at those sizes and not "smoothing". So in many cases the resulting text display is equivalent to VALUE_TEXT_ANTIALIAS_OFF.
  5. Antialiasing using the TEXT_ANTIALIAS_LCD_HRGB hint.


Note: If you don't see the applet running above, you need to install release 6 of the JDK. The complete code for this applet is in AntialiasedText.java.
Previous page: Advanced Text Display
Next page: Using Text Attributes to Style Text
 
 
 

Add to My Yahoo!

XML icon

Add to Google

 

 

 

 

 

 

 

 

 

 

 

JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP at JSP.aldenWEBhosting.com Servlets at servlets.aldenWEBhosting.com Tomcat at Tomcat.aldenWEBhosting.com mysql at mysql.aldenWEBhosting.com Java at Java.aldenWEBhosting.com Web Hosts Portal Web Links Web Links Web Hosting JSP Solutions Web Links JSP Solutions Web Hosting Servlets Solutions Web Links Servlets Solutions Web Hosting Web Links Web Links . . .
.
.
. .
.
. .
. . . . . . . . . . . jsp hosting servlets hosting web hosting web sites designed cheap web hosting web site hosting myspace web hosting