net.sourceforge.wohenchan
Class HBFFont

java.lang.Object
  |
  +--net.sourceforge.wohenchan.HBFFont

public class HBFFont
extends java.lang.Object

Class hbf_font is used for manipulating HBF (Hanzi Bitmap Font) files for Chinese.

This font format is described in: http://www.ifcss.org/ftp-pub/software/info/HBF-1.1/

Sample HBF files can be downloaded from CND or IFCSS:

GB (simplified characters)
ftp://ftp.cnd.org/pub/software/fonts/gb/hbf/
ftp://ftp.ifcss.org/pub/software/fonts/gb/hbf/
Big5 (traditional characters)
ftp://ftp.cnd.org/pub/software/fonts/big5/hbf/
ftp://ftp.ifcss.org/pub/software/fonts/big5/hbf/


Field Summary
private  java.lang.String dirname
           
private  HBFByte2Range[] m_byte2Ranges
           
private  int m_byte2RangeTotal
           
private  HBFCodeRange[] m_codeRange
           
private  int m_fontAscent
           
private  int m_fontDescent
           
private  int m_pixelSize
           
static int MAXIMUM_NARROW_CHAR
           
 
Constructor Summary
HBFFont(java.lang.String hbf_filename)
          Opens and parses an HBF file.
 
Method Summary
private  int calculateRealOffset(char mychar, int idx)
           
 byte[] getarr(char mychar)
          Returns the bitmap corresponding to a character.
 int getFontAscent()
          Returns FONT_ASCENT as specified in the HBF file.
 int getFontDescent()
          Returns FONT_DESCENT as specified in the HBF file.
 int getPixelSize()
          Returns PIXEL_SIZE as specified in the HBF file.
private  boolean isNarrow(char mychar)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_byte2Ranges

private HBFByte2Range[] m_byte2Ranges

m_codeRange

private HBFCodeRange[] m_codeRange

m_byte2RangeTotal

private int m_byte2RangeTotal

m_pixelSize

private int m_pixelSize

m_fontAscent

private int m_fontAscent

m_fontDescent

private int m_fontDescent

dirname

private java.lang.String dirname

MAXIMUM_NARROW_CHAR

public static final int MAXIMUM_NARROW_CHAR
See Also:
Constant Field Values
Constructor Detail

HBFFont

public HBFFont(java.lang.String hbf_filename)
        throws java.io.FileNotFoundException
Opens and parses an HBF file.

Method Detail

getPixelSize

public final int getPixelSize()
Returns PIXEL_SIZE as specified in the HBF file.


getFontAscent

public final int getFontAscent()
Returns FONT_ASCENT as specified in the HBF file.


getFontDescent

public final int getFontDescent()
Returns FONT_DESCENT as specified in the HBF file.


calculateRealOffset

private int calculateRealOffset(char mychar,
                                int idx)
                         throws HBFByte2NotFoundException
HBFByte2NotFoundException

isNarrow

private boolean isNarrow(char mychar)

getarr

public byte[] getarr(char mychar)
              throws java.io.IOException,
                     HBFByte2NotFoundException
Returns the bitmap corresponding to a character. The length in bytes will be P*P/8 (for normal Chinese characters) or P*P/16 (for half-width ASCII characters) where P is the PIXEL_SIZE of the HBF font.

Throws:
HBFByte2NotFoundException - ???
java.io.IOException - codeRange.activateFile() throws this.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object