コード例 #1
0
  @Override
  public boolean removeCharacter(char character) {
    ensureFontInfo();
    if (fontInfoTag == null) {
      return false;
    }

    int code = (int) character;
    int pos = -1;
    List<Integer> codeTable = fontInfoTag.getCodeTable();
    for (int i = 0; i < codeTable.size(); i++) {
      if (codeTable.get(i) >= code) {
        if (codeTable.get(i) == code) {
          pos = i;
          break;
        }

        return false;
      }
    }

    if (pos == -1) {
      return false;
    }

    glyphShapeTable.remove(pos);
    fontInfoTag.removeFontCharacter(pos);

    shiftGlyphIndices(fontId, pos + 1, false);

    setModified(true);
    getSwf().clearImageCache();
    return true;
  }
コード例 #2
0
 @Override
 public int charToGlyph(char c) {
   ensureFontInfo();
   if (fontInfoTag != null) {
     return fontInfoTag.getCodeTable().indexOf((int) c);
   }
   return -1;
 }
コード例 #3
0
 @Override
 public int getCharacterCount() {
   ensureFontInfo();
   if (fontInfoTag != null) {
     List<Integer> codeTable = fontInfoTag.getCodeTable();
     return codeTable.size();
   }
   return 0;
 }
コード例 #4
0
 @Override
 public char glyphToChar(int glyphIndex) {
   ensureFontInfo();
   if (fontInfoTag != null) {
     return (char) (int) fontInfoTag.getCodeTable().get(glyphIndex);
   } else {
     return '?';
   }
 }
コード例 #5
0
 @Override
 public String getCharacters() {
   ensureFontInfo();
   if (fontInfoTag != null) {
     List<Integer> codeTable = fontInfoTag.getCodeTable();
     StringBuilder ret = new StringBuilder(codeTable.size());
     for (int i : codeTable) {
       ret.append((char) i);
     }
     return ret.toString();
   }
   return "";
 }
コード例 #6
0
  @Override
  public void addCharacter(char character, Font font) {
    SHAPE shp =
        SHAPERECORD.fontCharacterToSHAPE(font, (int) Math.round(getDivider() * 1024), character);
    ensureFontInfo();
    int code = (int) character;
    int pos = -1;
    boolean exists = false;
    if (fontInfoTag != null) {
      List<Integer> codeTable = fontInfoTag.getCodeTable();
      for (int i = 0; i < codeTable.size(); i++) {
        if (codeTable.get(i) >= code) {
          if (codeTable.get(i) == code) {
            exists = true;
          }

          pos = i;
          break;
        }
      }

      if (pos == -1) {
        pos = codeTable.size();
      }
    } else {
      pos = 0;
    }

    if (!exists) {
      shiftGlyphIndices(fontId, pos, true);
      glyphShapeTable.add(pos, shp);
      if (fontInfoTag != null) {
        fontInfoTag.addFontCharacter(pos, (int) character);
      }
    } else {
      glyphShapeTable.set(pos, shp);
    }

    setModified(true);
    getSwf().clearImageCache();
  }