Exemplo n.º 1
0
  /**
   * Creates a final version of kerning instruction after validity checks.
   *
   * @param lkc the original version of lig/kern instruction.
   * @param skip the offset of next lig/kern instruction in the final version of the lig/kern
   *     program.
   * @return Returns the ligkern
   */
  private TfmLigKern makeKern(final TfmLigKernCommand lkc, final int skip) {

    int kernIdx = lkc.kernIndex();
    TfmFixWord kernword = null;
    if (kernIdx < kern.getTable().length) {
      kernword = kern.getTable()[kernIdx];
    } else {
      kernword = TfmFixWord.ZERO;
    }
    return new TfmKerning(skip, lkc.nextChar(), kernword);
  }
Exemplo n.º 2
0
  /**
   * Creates a final version of ligature instruction after validity checks.
   *
   * @param lkc the original version of lig/kern instruction.
   * @param skip the offset of next lig/kern instruction in the final version of the lig/kern
   *     program.
   * @return Returns the ligkern
   */
  private TfmLigKern makeLig(final TfmLigKernCommand lkc, final int skip) {

    //       if (!charExists(lkc.ligChar())) {
    //           badchar(lkc.ligChar(), "Ligature step produces the");
    //           lkc.setLigChar(firstCharCode);
    //       }
    boolean left = lkc.leaveLeft();
    boolean right = lkc.leaveRight();
    byte step = lkc.stepOver();
    return new TfmLigature(skip, lkc.nextChar(), lkc.ligChar(), left, right, step);
  }
Exemplo n.º 3
0
  /** Fills in the blank <code>ligKernTable</code> by the final version of lig/kern instructions. */
  private void buildLigKernTable() {

    int currIns = 0;
    for (int i = 0; i < ligkerncommand.length; i++) {
      setLigStarts(i, currIns);
      TfmLigKernCommand lkc = ligkerncommand[i];
      if (lkc.getActivity() != TfmLigKernCommand.PASSTHROUGH) {
        if (!lkc.meansRestart()) {
          int skip = getSkip(i);
          ligKernTable[currIns++] = (lkc.meansKern()) ? makeKern(lkc, skip) : makeLig(lkc, skip);
        }
      }
    }
  }
Exemplo n.º 4
0
  /**
   * Finds out the actual starting index of lig/kern program in case there is a restart instructions
   * and checks for validity. TFtoPL[67]
   *
   * @param start the starting index of lig/kern program given in a character info.
   * @return Returns the actual starting index.
   */
  private int ligStart(final int start) {

    int newstart = start;
    if (newstart < ligkerncommand.length) {
      TfmLigKernCommand lkc = ligkerncommand[start];
      if (lkc.meansRestart()) {
        newstart = lkc.restartIndex();
        if (newstart < ligkerncommand.length
            && lkc.getActivity() == TfmLigKernCommand.UNREACHABLE) {
          lkc.setActivity(TfmLigKernCommand.PASSTHROUGH);
        }
      }
    }
    return newstart;
  }
Exemplo n.º 5
0
  /**
   * Gets the offset of next lig/kern instruction in a program based on counting only those
   * intervene instructions which will be converted to final lig/kern program.
   *
   * @param pos the position of current lig/kern instruction in ligAuxTable.
   * @return Returns the skip amount of the next instruction in the final version of lig/kern
   *     program.
   */
  private int getSkip(final int pos) {

    TfmLigKernCommand lkc = ligkerncommand[pos];
    if (lkc.meansStop()) {
      return -1;
    }
    int p = pos;
    int skip = 0;
    int next = lkc.nextIndex(pos);
    while (++p < next) {
      if (ligkerncommand[pos].getActivity() != TfmLigKernCommand.PASSTHROUGH) {
        skip++;
      }
    }
    return skip;
  }
Exemplo n.º 6
0
  /**
   * Tries to find the information about lig/kerns for word boundaries in tfm lig/kern table and
   * checks for errors. TFtoPL[69]
   */
  private void setupBoundary() {

    // first entry
    TfmLigKernCommand lkc = ligkerncommand[0];

    if (lkc.meansBoundary()) {
      boundaryChar = lkc.nextChar();
      lkc.setActivity(TfmLigKernCommand.PASSTHROUGH);
    }

    // last entry
    lkc = ligkerncommand[ligkerncommand.length - 1];
    if (lkc.meansBoundary()) {
      int start = lkc.restartIndex();
      lkc.setActivity(TfmLigKernCommand.PASSTHROUGH);
      if (start < ligkerncommand.length) {
        ligkerncommand[start].setActivity(TfmLigKernCommand.ACCESSIBLE);
        labels.add(start, BOUNDARYLABEL);
      }
    }
  }
Exemplo n.º 7
0
  /**
   * Marks the lig/kern instructions which are really a part of some lig/kern program (active),
   * counts the final number of lig/kern instructions, creates the blank final lig/kern table and
   * checks for errors. Uses <code>activity</code> field of LigKern for marking the activity. It
   * supposes that the first instructions of programs are already marked active. TFtoPL[70]
   */
  private void promoteActivity() {

    int ligKernLength = 0;
    for (int i = 0; i < ligkerncommand.length; i++) {
      TfmLigKernCommand lkc = ligkerncommand[i];
      if (lkc.getActivity() == TfmLigKernCommand.ACCESSIBLE) {
        if (!lkc.meansStop()) {
          int next = lkc.nextIndex(i);
          if (next < ligkerncommand.length) {
            ligkerncommand[next].setActivity(TfmLigKernCommand.ACCESSIBLE);
          } else {
            lkc.makeStop();
          }
        }
      }
      if (lkc.getActivity() != TfmLigKernCommand.PASSTHROUGH) {
        ligKernLength++;
      }
    }
    ligKernTable = new TfmLigKern[ligKernLength];
  }