Font Creation from TTF file in JDK 1.3

Discussion in 'Java' started by Sameer, Mar 8, 2005.

  1. Sameer

    Sameer Guest

    Hello,

    In JDK1.5.0 there is a static method in Font class having syntax

    Font.createFont(int fontFormat, File fontFile).

    This let you create a font using the supplied font file.
    Thus it is not necessary whether a particular font is installed on the
    machine, we can use font created by this method(?).

    The method available previously (in 1.3) has the syntax:

    Font.createFont(int fontFormat, InputStream fontStream).

    Can we use the functionality of JDK 1.5 in JDK 1.3?
    i.e Can we get the InputStream from the TTF file and pass it to the
    function to work it like the function available in 1.5 and create a new
    Font?

    If it is possible, how to do it?
    Please help me ASAP.
    -Sameer
    Sameer, Mar 8, 2005
    #1
    1. Advertising

  2. Sameer wrote:
    > Can we use the functionality of JDK 1.5 in JDK 1.3?
    > i.e Can we get the InputStream from the TTF file and pass it to the
    > function to work it like the function available in 1.5 and create a new
    > Font?


    Yes. Why didn't you just try it?

    > Please help me ASAP.


    ASAP? But you couldn't be bothered to write ten lines of code to try it?

    /Thomas

    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    Thomas Weidenfeller, Mar 9, 2005
    #2
    1. Advertising

  3. Sameer

    Sameer Guest

    Thank you very much for this 'Brain Washing'. I will definately try to
    write the code for the same. But I am not confident whether it will
    work or not so I want assistance from expert peoples like you and I
    just tried whether anybody is kind enough to give me lines for the
    same.
    -Sameer
    Sameer, Mar 9, 2005
    #3
  4. Sameer

    Viator Guest

    Here are the lines!
    try{
    Font font=Font.createFont(yourFormat,new
    FileInputStream(yourFontFile));
    }catch(Exception e){
    playWith(e);
    }//end try catch
    Viator, Mar 9, 2005
    #4
  5. Sameer

    Sameer Guest

    Dear Sir,
    I created the font using the method createFont using JDK1.3 and apply
    it to a JTextField, but the text displayed is toooo small. Why is it
    so? The method font.deriveFont(int) is used and given a big value...
    still the text was not displaying.
    What may be the problem?
    Sameer, Mar 12, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AJ
    Replies:
    1
    Views:
    6,749
    Ralph Aichinger
    Apr 29, 2004
  2. Sameer
    Replies:
    0
    Views:
    415
    Sameer
    Mar 10, 2005
  3. John Hunter
    Replies:
    0
    Views:
    896
    John Hunter
    Sep 11, 2003
  4. Replies:
    5
    Views:
    923
  5. Laszlo Nagy
    Replies:
    1
    Views:
    642
    David Boddie
    Sep 19, 2009
Loading...

Share This Page