org.extex.font.format.tfm
Class TfmLigKernArray

java.lang.Object
  extended by org.extex.font.format.tfm.TfmLigKernArray
All Implemented Interfaces:
java.io.Serializable

public class TfmLigKernArray
extends java.lang.Object
implements java.io.Serializable

Class for TFM lig/kern array.

The array contains instructions in a simple programming language that explains what to do for special letter pairs. Each word is a lig_kern_command of four bytes.

byte description
first skip_byte, indicates that this is the program step if the byte is 128 or more, otherwise the next step is obtained by skipping this number of intervening steps.
second next_char: if next_char follows the current character, then perform the operation and stop, otherwise continue.
third op_byte, indicates a ligature step if less than 128, a kern step otherwise.
fourth remainder

There are eight kinds of ligature steps, having op_byte codes 4a+2b+c where 0 < a < b+c and 0 < b, c < 1. The character whose code is remainder is inserted between the current character and next_char; then the current character is deleted if b=0, and next_char is deleted if c=0; then we pass over a characters to reach the next current character (which may have a ligature/kerning program of its own).

Notice that if a=0 and b=1, the current character is unchanged; if a=b and c=1, the current character is changed but the next character is unchanged.

If the very first instruction of the lig_kern array has skip_byte=255, the next_char byte is the so-called right boundary character of this font; the value of next_char need not lie between bc and ec. If the very last instruction of the lig_kern array has skip_byte=255, there is a special ligature/kerning program for a left boundary character, beginning at location 256op_byte+remainder. The interpretation is that TeX puts implicit boundary characters before and after each consecutive string of characters from the same font. These implicit characters do not appear in the output, but they can affect ligatures and kerning.

If the very first instruction of a character's lig_kern program has skip_byte>128, the program actually begins in location 256op_byte+remainder. This feature allows access to large lig_kern arrays, because the first instruction must otherwise appear in a location <> 255.

Any instruction with skip_byte>128 in the lig_kern array must have 256op_byte+remainder < nl. If such an instruction is encountered during normal program execution, it denotes an unconditional halt; no ligature command is performed.

Information from: The DVI Driver Standard, Level 0 The TUG DVI Driver Standards Committee

Version:
$Revision: 6175 $
Author:
Michael Niedermair
See Also:
Serialized Form

Constructor Summary
TfmLigKernArray(RandomAccessR rar, int nl)
          Create a new object.
 
Method Summary
 void calculate(TfmCharInfoArray chari, TfmKernArray akern, int abc)
          Calculate lig/kern.
 boolean foundLigKern(TfmCharInfoWord ciw)
          Check, if char has ligature or kern.
 int getBc()
          Getter for bc.
 short getBoundaryChar()
          Returns the boundaryChar.
 int getBoundaryStart()
          Returns the boundaryStart.
 TfmCharInfoArray getCharinfo()
          Getter for charinfo.
 TfmFixWord getKerning(int cp1, int cp2)
          Return the kerning.
 int getLigature(int cp1, int cp2)
          Return the ligature.
 TfmLigKernCommand[] getLigkerncommand()
          Returns the ligkerncommand.
 TfmLigKern[] getLigKernTable()
          Returns the ligKernTable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TfmLigKernArray

public TfmLigKernArray(RandomAccessR rar,
                       int nl)
                throws java.io.IOException
Create a new object.

Parameters:
rar - the input
nl - number of words in the lig/kern table
Throws:
java.io.IOException - if an IO-error occurs.
Method Detail

calculate

public void calculate(TfmCharInfoArray chari,
                      TfmKernArray akern,
                      int abc)
Calculate lig/kern.

Parameters:
chari - the charinfo
akern - the kern
abc - smallest character code in the font

foundLigKern

public boolean foundLigKern(TfmCharInfoWord ciw)
Check, if char has ligature or kern.

Parameters:
ciw - the char
Returns:
Returns true, if the char has a ligature or a kern

getBc

public int getBc()
Getter for bc.

Returns:
Returns the bc.

getBoundaryChar

public short getBoundaryChar()
Returns the boundaryChar.

Returns:
Returns the boundaryChar.

getBoundaryStart

public int getBoundaryStart()
Returns the boundaryStart.

Returns:
Returns the boundaryStart.

getCharinfo

public TfmCharInfoArray getCharinfo()
Getter for charinfo.

Returns:
Returns the charinfo.

getKerning

public TfmFixWord getKerning(int cp1,
                             int cp2)
Return the kerning.

Parameters:
cp1 - the left char. This character has to exist.
cp2 - the right char. This character has to exist.
Returns:
the kerning.

getLigature

public int getLigature(int cp1,
                       int cp2)
Return the ligature. If no ligature exists, the -1 is returned.

Parameters:
cp1 - the left char. This character has to exist.
cp2 - the right char. This character has to exist.
Returns:
the ligature.

getLigkerncommand

public TfmLigKernCommand[] getLigkerncommand()
Returns the ligkerncommand.

Returns:
Returns the ligkerncommand.

getLigKernTable

public TfmLigKern[] getLigKernTable()
Returns the ligKernTable.

Returns:
Returns the ligKernTable.