aspose file tools*
The moose likes Beginning Java and the fly likes Trying to change font on a using bufferedwriter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trying to change font on a using bufferedwriter" Watch "Trying to change font on a using bufferedwriter" New topic
Author

Trying to change font on a using bufferedwriter

Justin Char
Ranch Hand

Joined: Mar 05, 2007
Posts: 76
Font f = new Font("Lucida Sans Typewriter", Font.ITALIC, 48);

I tried the above didn't work said f isn't read.

Does anyone know what I am doing wrong.

J
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
I haven't used BufferedWriter for ages, so I can't remember whether you can change Fonts.

Try: Get a list of Fonts with GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts() which returns Font[]. Then iterate through the Font[] using for or for-each and System.out.println(f.getName());

That will confirm that you actually have that Font installed. I tried it a few minutes ago and I didn't have that Font, but I did have Lucida Sans Regular,
Lucida Sans Typewriter Bold, and Lucida Sans Typewriter Regular.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14153
    
  18

Can you explain the problem in more detail? What does this line of code have to do with BufferedWriter? What are you trying to achieve? Do you get a compiler error? If so, please copy and paste the exact error message.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Justin Char
Ranch Hand

Joined: Mar 05, 2007
Posts: 76
strOut = ("TOTALS REPORT FOR TOTAL RCDS WITH NO UPDATES");
Counter.write(strOut);
Counter.newLine();
Counter.newLine();

I am getting no errors I just want to change the font and font size of the
My program works I just want to be able to adjust the fonts on my report.
("TOTALS REPORT FOR TOTAL RCDS WITH NO UPDATES");
//just want to change text to Courier New or something font size 24 or 48 anything.
Justin Char
Ranch Hand

Joined: Mar 05, 2007
Posts: 76
Ritchie can you give me an example of how you would lay that out in a class.


Thanks, I don't know how to layout your suggestion in a class
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
No
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
. . . and I still don't understand what Fonts have to do with BufferedWriters; it doesn't seem possible to change Fonts on BufferedWriters. The Font class is used to format text displayed on Swing (or AWT) text components which accept Fonts. See java.awt.Component.setFont() and java.awt.Graphics.setFont().
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14153
    
  18

A BufferedWriter writes plain text to an output stream (for example to a text file). A plain text file contains only text characters. Those characters do not have properties like a certain font or style.

You cannot "set the font on a BufferedWriter".
Justin Char
Ranch Hand

Joined: Mar 05, 2007
Posts: 76
Thank you

I just wanted to know how if you could.

Or to find you can't do it.

You answered my question ...I appreciate it.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38881
    
  23
You're welcome.
Jinny Morris
Ranch Hand

Joined: Apr 29, 2007
Posts: 101
Thank you Campbell Ritchie! I've been trying to get my font list for a couple of days, and kept messing up my objects & methods - now I've got it! And learned some stuff in the process (mostly about what doesn't work, tho ...)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to change font on a using bufferedwriter