JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.page.adobe.postscript
Class AFMParser

java.lang.Object
  |
  +--com.klg.jclass.page.adobe.postscript.AFMParser
All Implemented Interfaces:
FontParser

public class AFMParser
extends Object
implements FontParser

Reads in a file corresponding to the Adobe Font Metrics Format Specification (.afm files) and builds an in-memory representation of the specific font's information.

Parsing details: Each afm file contains information for one PostScript font program. Each begins with Global information about the font in general, then sections on individual character metrics.

The file format is line-oriented, each line beginning with a property (key) followed by values for that property. Keys and values are separated by one or more white spaces. Key names are case-sensitive.


Field Summary
static int ASCENDER
           
static int CAPHEIGHT
           
static int CHARBBOX
           
static int CHARNAME
           
static int CODE
           
static int COMMENT
           
static int COMPCHAR
           
static int COMPCHARPIECE
           
protected  String currentLine
           
protected  String DELIMITERS
           
static int DESCENDER
           
static int ENCODINGSCHEME
           
static int ENDCHARMETRICS
           
static int ENDCOMPOSITES
           
static int ENDFONTMETRICS
           
static int ENDKERNDATA
           
static int ENDKERNPAIRS
           
static int ENDTRACKKERN
           
protected static int EOF
           
static int FAMILYNAME
           
static int FONTBBOX
           
static int FONTNAME
           
static int FULLNAME
           
static int ISFIXEDPITCH
           
static int ITALICANGLE
           
static int KERNPAIR
           
static int KERNPAIRXAMT
           
static String[] keyStrings
           
static int LIGATURE
           
static int NOPE
           
protected static int NOT_FOUND
           
static int NOTICE
           
protected  BufferedReader reader
           
static int STARTCHARMETRICS
           
static int STARTCOMPOSITES
           
static int STARTFONTMETRICS
           
static int STARTKERNDATA
           
static int STARTKERNPAIRS
           
static int STARTTRACKKERN
           
static int STDHW
           
static int STDVW
           
protected  StringTokenizer tokenizer
           
static int TRACKKERN
           
static int UNDERLINEPOSITION
           
static int UNDERLINETHICKNESS
           
static int VERSION
           
static int WEIGHT
           
static int XHEIGHT
           
static int XWIDTH
           
static int XYWIDTH
           
 
Constructor Summary
AFMParser()
          Constructor Call parse() to parse the file.
AFMParser(String afmFileName)
          Constructor Calls parse() for you.
 
Method Summary
protected  float atof(String a)
           
protected  int atoi(String a)
           
protected  String getLine()
          Return the rest of the current line and move the pointer to the next line.
static void main(String[] args)
          Driver
 Vector parse(InputStream inputStream)
          Parse the file and build the in-memory image.
protected  void parseCharMetrics(com.klg.jclass.page.adobe.postscript.FontPS font)
          This function is called by parseFile to save all character metric information.
protected  void parseCompCharData()
           
protected  void parseGlobals(com.klg.jclass.page.adobe.postscript.FontPS font)
          This function is called by "parseFile".
protected  void parsePairKernData(com.klg.jclass.page.adobe.postscript.FontPS font)
           
protected  void parseTrackKernData(com.klg.jclass.page.adobe.postscript.FontPS font)
          This function is called by "parseFile".
protected  int recognize(String key)
           
protected  String token()
          Return the next token from the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASCENDER

public static final int ASCENDER
See Also:
Constant Field Values

CHARBBOX

public static final int CHARBBOX
See Also:
Constant Field Values

CODE

public static final int CODE
See Also:
Constant Field Values

COMPCHAR

public static final int COMPCHAR
See Also:
Constant Field Values

CAPHEIGHT

public static final int CAPHEIGHT
See Also:
Constant Field Values

COMMENT

public static final int COMMENT
See Also:
Constant Field Values

DESCENDER

public static final int DESCENDER
See Also:
Constant Field Values

ENCODINGSCHEME

public static final int ENCODINGSCHEME
See Also:
Constant Field Values

ENDCHARMETRICS

public static final int ENDCHARMETRICS
See Also:
Constant Field Values

ENDCOMPOSITES

public static final int ENDCOMPOSITES
See Also:
Constant Field Values

ENDFONTMETRICS

public static final int ENDFONTMETRICS
See Also:
Constant Field Values

ENDKERNDATA

public static final int ENDKERNDATA
See Also:
Constant Field Values

ENDKERNPAIRS

public static final int ENDKERNPAIRS
See Also:
Constant Field Values

ENDTRACKKERN

public static final int ENDTRACKKERN
See Also:
Constant Field Values

FAMILYNAME

public static final int FAMILYNAME
See Also:
Constant Field Values

FONTBBOX

public static final int FONTBBOX
See Also:
Constant Field Values

FONTNAME

public static final int FONTNAME
See Also:
Constant Field Values

FULLNAME

public static final int FULLNAME
See Also:
Constant Field Values

ISFIXEDPITCH

public static final int ISFIXEDPITCH
See Also:
Constant Field Values

ITALICANGLE

public static final int ITALICANGLE
See Also:
Constant Field Values

KERNPAIR

public static final int KERNPAIR
See Also:
Constant Field Values

KERNPAIRXAMT

public static final int KERNPAIRXAMT
See Also:
Constant Field Values

LIGATURE

public static final int LIGATURE
See Also:
Constant Field Values

CHARNAME

public static final int CHARNAME
See Also:
Constant Field Values

NOTICE

public static final int NOTICE
See Also:
Constant Field Values

COMPCHARPIECE

public static final int COMPCHARPIECE
See Also:
Constant Field Values

STARTCHARMETRICS

public static final int STARTCHARMETRICS
See Also:
Constant Field Values

STARTCOMPOSITES

public static final int STARTCOMPOSITES
See Also:
Constant Field Values

STARTFONTMETRICS

public static final int STARTFONTMETRICS
See Also:
Constant Field Values

STARTKERNDATA

public static final int STARTKERNDATA
See Also:
Constant Field Values

STARTKERNPAIRS

public static final int STARTKERNPAIRS
See Also:
Constant Field Values

STARTTRACKKERN

public static final int STARTTRACKKERN
See Also:
Constant Field Values

STDHW

public static final int STDHW
See Also:
Constant Field Values

STDVW

public static final int STDVW
See Also:
Constant Field Values

TRACKKERN

public static final int TRACKKERN
See Also:
Constant Field Values

UNDERLINEPOSITION

public static final int UNDERLINEPOSITION
See Also:
Constant Field Values

UNDERLINETHICKNESS

public static final int UNDERLINETHICKNESS
See Also:
Constant Field Values

VERSION

public static final int VERSION
See Also:
Constant Field Values

XYWIDTH

public static final int XYWIDTH
See Also:
Constant Field Values

XWIDTH

public static final int XWIDTH
See Also:
Constant Field Values

WEIGHT

public static final int WEIGHT
See Also:
Constant Field Values

XHEIGHT

public static final int XHEIGHT
See Also:
Constant Field Values

NOPE

public static final int NOPE
See Also:
Constant Field Values

keyStrings

public static String[] keyStrings

currentLine

protected String currentLine

EOF

protected static final int EOF
See Also:
Constant Field Values

NOT_FOUND

protected static final int NOT_FOUND
See Also:
Constant Field Values

reader

protected BufferedReader reader

DELIMITERS

protected String DELIMITERS

tokenizer

protected StringTokenizer tokenizer
Constructor Detail

AFMParser

public AFMParser()
Constructor Call parse() to parse the file.


AFMParser

public AFMParser(String afmFileName)
          throws FileNotFoundException,
                 IOException
Constructor Calls parse() for you.

Parameters:
afmFileName - a String file name.
Throws:
FileNotFoundException - If a file is not found.
IOException - If there is an error.
Method Detail

parse

public Vector parse(InputStream inputStream)
             throws IOException
Parse the file and build the in-memory image.

Specified by:
parse in interface FontParser
Returns:
the FontPS object created by reading this file.
Throws:
IOException - If there is an error.

token

protected String token()
                throws IOException
Return the next token from the file.

Returns:
the next String token from the file or null if the end of file has been reached.
IOException

getLine

protected String getLine()
                  throws IOException
Return the rest of the current line and move the pointer to the next line. And sets up the next line.

Returns:
the currentLine
IOException

parseCompCharData

protected void parseCompCharData()
                          throws IOException
IOException

parsePairKernData

protected void parsePairKernData(com.klg.jclass.page.adobe.postscript.FontPS font)
                          throws IOException
IOException

parseTrackKernData

protected void parseTrackKernData(com.klg.jclass.page.adobe.postscript.FontPS font)
                           throws IOException
This function is called by "parseFile". It will parse the AFM File up to the "EndTrackKern" or "EndKernData" keywords and save the track kerning data. parseTrackKernData is passed in a pointer to the PSFontInfo record. If data is to be saved, the PSFontInfo record will already contain a valid pointer to storage for the track kerning data.

IOException

parseCharMetrics

protected void parseCharMetrics(com.klg.jclass.page.adobe.postscript.FontPS font)
                         throws IOException
This function is called by parseFile to save all character metric information. parseCharMetrics is passed in a pointer to an array of records to hold information on a per character basis. This function parses the Character Metrics section storing all character metric information for the ALL characters (mapped and unmapped) into the array.

IOException

parseGlobals

protected void parseGlobals(com.klg.jclass.page.adobe.postscript.FontPS font)
                     throws IOException
This function is called by "parseFile". It will parse the AFM File up to the "StartCharMetrics" keyword, which essentially marks the end of the Global Font Information and the beginning of the character metrics information. If the caller of "parseFile" specified that it wanted the Global Font Information (as defined by the "AFM File Specification" document), then that information will be stored in the returned data structure. Any Global Font Information entries that are not found in a given file, will have the usual default initialization value for its type (i.e. entries of type int will be 0, etc).

IOException

atoi

protected int atoi(String a)

atof

protected float atof(String a)

recognize

protected int recognize(String key)

main

public static void main(String[] args)
Driver


Copyright © 2004 Quest Software Inc..
All rights reserved.