Font Creation from TTF file in JDK 1.3

S

Sameer

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
 
T

Thomas Weidenfeller

Sameer said:
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
 
S

Sameer

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
 
V

Viator

Here are the lines!
try{
Font font=Font.createFont(yourFormat,new
FileInputStream(yourFontFile));
}catch(Exception e){
playWith(e);
}//end try catch
 
S

Sameer

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top