This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Creating characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating characters" Watch "Creating characters" New topic
Author

Creating characters

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi, this is probably impossible, or very awquard, but is it possible to create my own characters, such as small chess pieces, which can then be written using System.out.println("Pawn="+pawn);

Thanks
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
you can write your own class Pawn, and then when you could output:



by creating your own String toString() method for that Pawn class, and format the output you want. Whether it be just the name of that piece, or the name and coords.

Justin Fox


You down with OOP? Yeah you know me!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

It's a non-Java thing. You would have to create your own typeface, presumably one with support for at least the first 256 code points. Your typeface ("font") would include both a normal US-ASCII character set and then extra glyphs in the unused code points (128-255) to represent your chess pieces and things. Then you'd have to install it on the computer, and configure your terminal window to use it. Then it's easy: from Java, you'd just print the Unicode values which corresponded to the chess piece glyphs.


[Jess in Action][AskingGoodQuestions]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
I can't tell you where you might find chess pieces, but if you try Unicode numbers more than 2653 and less than 2660 you might find something to your advantage.
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
I'm not sure how I would create my own typeface, I googled it, but couldn't find anything of use.

I don't know how I would use 2653 - 2660 either :roll:
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Even if you did create your own typeface, you probably wouldn't be able to persuade the console to use it. But perhaps your "System.out.println" was just a quick example and you really have a more practical use for these symbols?
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
No, I would be printing to console, and also to the gui.
I was hoping to use an array of points or something to create small images that can come up as normal text, but like I thought, its too complicated.
Bob Good
Ranch Hand

Joined: Jan 09, 2008
Posts: 86
There are some chess pieces in the private area of unicode defined here as an example:

http://www.users.globalnet.co.uk/~ngo/fonts.htm

see these:

http://www.users.globalnet.co.uk/~ngo/QUECHESS.TTF
[ January 18, 2008: Message edited by: Bob Good ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Platform-sensitivity, I am afraid. If you print 2653-2660 on a Linux shell, you get tiny chess pieces appearing. At least I did yesterday. If you tried it on Windows you would get ???
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Thanks, I tried the fonts, but I don't like them, and I wouldn't know how to use them.
I also tried the 2653-2660, but on windows, so they came up as '?'.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating characters
 
Similar Threads
MultiDimensional array doesnt work
Ranch Hand Bashing
java
Quotes
Quotes