Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Font Derivation 
 

Font derivation refers to the different styles provided by the font. The method deriveFont() provides different styles to the characters.

 

Font Derivation

                         

In this section, you will studied about the font derivation.

Font derivation refers to the different styles provided by the font. The method deriveFont() provides different styles to the characters. We are providing you an example.

The method deriveFont(float size) creates a font object, applying a size to it and replicates the current font object .  The method deriveFont(int style) creates a new font object, applying a new style to it and replicates the current  font object. The method deriveFont(AffineTransform affineTransform) creates a new font object, applying a new transform to it and replicates the current font object. The class AffineTransform provides properties like shearing, translation, scaling and rotation.

Here is the code of FontDerivatonExample.java

import java.awt.*;
import javax.swing.*;
import java.awt.font.TextAttribute;
import java.awt.geom.AffineTransform;

public class FontDerivationExample extends JPanel {
    public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;

    Font font = new Font("Monotype Corsiva", Font.PLAIN, 1);
    float p = 15, q = 15;
    Font font1 = font.deriveFont(20.0f);
    g2d.setFont(font1);
    g2d.drawString("Java is an Object Oriented Programming Language.",p, q += 25);

   Font bold = font1.deriveFont(Font.BOLD);
    g2d.setFont(bold);
    g2d.drawString("Java is an Object Oriented Programming Language.",p, q += 25);

    Font italic = font1.deriveFont(Font.ITALIC);
    g2d.setFont(italic);
    g2d.drawString("Java is an Object Oriented Programming Language.",p, q += 25);

    AffineTransform affineTransform = new AffineTransform();
    affineTransform.shear(.30);
    Font shear = font1.deriveFont(affineTransform);
    g2d.setFont(shear);
    g2d.drawString("Java is an Object Oriented Programming Language.",p, q += 25);
 }
    public static void main(String[] args) {
    JFrame frame = new JFrame("Font Derivation Example");
    frame.getContentPane().add(new FontDerivationExample());
    frame.setSize(400250);
    frame.show();
  }
}

Output will be displayed as

The first sentence is written in plain font, second one is written in bold, third one is written in italics and the last one is written in shear font.

Download Source Code

                         

» View all related tutorials
Related Tags: c com image class list object diff components stack icons user sed entity icon order component ai define container show

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.