Fonts


Character


Character repertoire/character set


Character code


Character encoding


Glyphs


ASCII


ASCII national variants

This is from A tutorial on character code issues by Jukka Korpela (this is really good!)

dec oct hex glyph official Unicode name National variants
35 43 23 # number sign
36 44 24 $ dollar sign
64 100 40 @ commercial at
91 133 5B [ left square bracket
92 134 5C \ reverse solidus
93 135 5D ] right square bracket |
94 136 5E ^ circumflex accent
95 137 5F _ low line
96 140 60 ` grave accent
123 173 7B { left curly bracket
124 174 7C | vertical line f
125 175 7D } right curly bracket
126 176 7E ~ tilde _
Some of the languages which can use these variants are discussed in Der Globalzeichensatz Unicode im Betriebssystem Unix


Extended ASCII


ISO 6937


ISO 8859


Windows 1252


ISO 2022


Issues with ISO 2022


ISO 2022 and Asian languages


Two-byte coded character sets


Chinese character sets


Japanese character sets

There is a discussion of Japanese character sets at http://www.debian.org/doc/manuals/intro-i18n/ch-languages.en.html


Unicode


Java and the console


Java character encodings


Reading and writing text files


Fonts


Java fonts


Java logical fonts


TrueType fonts


Java physical fonts


Font families


Java font families

This program lists the fonts families known to Java


import java.awt.Font;
import java.awt.GraphicsEnvironment;

public class ListFontFamilies {

    public static void main(String[] args) {

	String[] fontFamilyNames = GraphicsEnvironment.
	    getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

	System.out.println("Font family names:");
	for (int n = 0; n < fontFamilyNames.length; n++) {
	    System.out.println("   " + fontFamilyNames[n].toString());
	}
	
    }
}
These can be used to create fonts as in

Font f = new Font("Bitstream Charter", Font.PLAIN, 12);


Java fonts


Adding fonts to Java


Checking font coverage


Displaying text files using Java

This is based on a program from Chinese in Java



import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.ResourceBundle;
import java.nio.charset.Charset;
import java.util.Map;

public class FileReader {

    public static ResourceBundle bundle;
    private Font unicodeFont = new Font("Bitstream Cyberbit",
                                             Font.PLAIN, 16);

    public static void main(String[] args) throws Exception {
	bundle = ResourceBundle.getBundle("FileReader");

	if (args.length != 2) {
	    fatal("Usage");
	}
	
	new FileReader(args[0], args[1]);
    }
    
    public static void fatal(String errorType) {
	String errorMsg = bundle.getString(errorType);
	System.out.println("Fatal error: " + errorMsg);
	System.exit(1);
    }

    public FileReader(String fileName, String encoding) {
	FileInputStream fin = null;
	try {
	    fin = new FileInputStream(fileName);
	} catch (FileNotFoundException e) {
	    fatal("FileNotFound");
	}
	
        BufferedReader in = null;
	try {
	     in = new BufferedReader(new InputStreamReader(fin, encoding));
	} catch (UnsupportedEncodingException e) {
	    fatal("NoEncoding");
	}


	JFrame frame = new JFrame();
	JTextArea text = new JTextArea(20, 100);
	JScrollPane pane = new JScrollPane(text);

	text.setFont(unicodeFont);

	frame.setSize(600,600);
	frame.getContentPane().add(pane, BorderLayout.CENTER);
	frame.setVisible(true);

	String s = null;
	try {
	    while ((s = in.readLine()) != null) {
		text.append(s + "\n");
	    }
	} catch (IOException e) {
	    // do nothing	    
	}
    }
}


Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Last modified: Fri Mar 18 11:58:44 EST 2005
Copyright ©Jan Newmarch
Copyright © Jan Newmarch, Monash University, 2007
Creative Commons License This work is licensed under a Creative Commons License
The moral right of Jan Newmarch to be identified as the author of this page has been asserted.