Example #1
0
 public void mapGlyph(int index, char ch) {
   TTFGlyph glyph = this.get(index);
   if (null != glyph) {
     glyph.character = ch;
     this.map.put(new Character(ch), index);
   }
 }
Example #2
0
  public static void main(String[] argv) {
    java.io.File file = new java.io.File(argv[0]);
    try {
      TTFFontReader reader = new TTFFontReader(file);
      TTFFont font = new TTFFont(file.getName(), reader);
      if (font.isTTCF) {
        int count = font.countFaces();
        System.out.printf("Found TTCF font '%s' with %d faces.\n", count, font.getName());
        for (int cc = 0; cc < count; cc++) {
          System.out.printf("\tFace '%s'.\n", font.getFaceName(cc));
        }
      } else if (font.isTTF) {
        int count = font.countTables();
        System.out.printf("Found TTF font '%s' with %d tables.\n", font.getName(), count);
        for (int cc = 0; cc < count; cc++) {
          System.out.printf("\tTable '%s'.\n", font.getTableName(cc));
          switch (font.getTableType(cc)) {
            case fv3.font.ttf.Glyf.TYPE:
              {
                for (TTFGlyph glyph : font)
                  System.out.printf("\t\t%s\n", glyph.toString()); // ",\n\t\t      "

                break;
              }
            case fv3.font.ttf.Head.TYPE:
              {
                fv3.font.ttf.Head table = (fv3.font.ttf.Head) font.getTable(cc);
                System.out.printf("\t\tEm-Size %f\n", table.emsize);
                System.out.printf("\t\tMin-X %f\n", table.minX);
                System.out.printf("\t\tMin-Y %f\n", table.minY);
                System.out.printf("\t\tMax-X %f\n", table.maxX);
                System.out.printf("\t\tMax-Y %f\n", table.maxY);
                break;
              }
            case fv3.font.ttf.Hhea.TYPE:
              {
                fv3.font.ttf.Hhea table = (fv3.font.ttf.Hhea) font.getTable(cc);
                System.out.printf("\t\tAscent %f\n", table.ascent);
                System.out.printf("\t\tDescent %f\n", table.descent);
                System.out.printf("\t\tLeading %f\n", table.leading);
                System.out.printf("\t\tAdvance-Width-Max %f\n", table.advanceWidthMax);
                System.out.printf("\t\tMin-Left-Side-Bearing %f\n", table.minLeftSideBearing);
                System.out.printf("\t\tMin-Right-Side-Bearing %f\n", table.minRightSideBearing);
                System.out.printf("\t\tX-Max-Extent %f\n", table.xMaxExtent);
                break;
              }
            case fv3.font.ttf.Maxp.TYPE:
              {
                fv3.font.ttf.Maxp table = (fv3.font.ttf.Maxp) font.getTable(cc);
                System.out.printf("\t\tGlyph-Count %d\n", table.glyphCount);
                break;
              }
            case fv3.font.ttf.Name.TYPE:
              {
                fv3.font.ttf.Name table = (fv3.font.ttf.Name) font.getTable(cc);
                if (null != table.copyright)
                  System.out.printf("\t\tCopyright %s\n", table.copyright);
                if (null != table.family) System.out.printf("\t\tFamily %s\n", table.family);
                if (null != table.subfamily)
                  System.out.printf("\t\tSub-Family %s\n", table.subfamily);
                if (null != table.uniqueid) System.out.printf("\t\tUnique-ID %s\n", table.uniqueid);
                if (null != table.fullname) System.out.printf("\t\tFullname %s\n", table.fullname);
                if (null != table.version) System.out.printf("\t\tVersion %s\n", table.version);
                if (null != table.fontname) System.out.printf("\t\tFontname %s\n", table.fontname);
                if (null != table.trademark)
                  System.out.printf("\t\tTrademark %s\n", table.trademark);
                if (null != table.manufacturer)
                  System.out.printf("\t\tManufacturer %s\n", table.manufacturer);
                if (null != table.designer) System.out.printf("\t\tDesigner %s\n", table.designer);
                if (null != table.descriptor)
                  System.out.printf("\t\tDescriptor %s\n", table.descriptor);
                if (null != table.vendorurl)
                  System.out.printf("\t\tVendor-Url %s\n", table.vendorurl);
                if (null != table.designerurl)
                  System.out.printf("\t\tDesigner-Url %s\n", table.designerurl);
                if (null != table.license) System.out.printf("\t\tLicense %s\n", table.license);
                if (null != table.licenseurl)
                  System.out.printf("\t\tLicense-Url %s\n", table.licenseurl);
                break;
              }
            case fv3.font.ttf.Os2.TYPE:
              {
                fv3.font.ttf.Os2 table = (fv3.font.ttf.Os2) font.getTable(cc);
                System.out.printf("\t\tAch-Vend-ID %s\n", table.achVendID);
                System.out.printf("\t\tUs-Weight-Class %d\n", table.usWeightClass);
                System.out.printf("\t\tUs-Width-Class %d\n", table.usWidthClass);
                System.out.printf("\t\tFs-Type %d\n", table.fsType);
                System.out.printf("\t\tFs-Family-Class %d\n", table.fsFamilyClass);
                System.out.printf("\t\tFs-Selection %d\n", table.fsSelection);
                System.out.printf("\t\tFs-First-Char-Index %d\n", table.fsFirstCharIndex);
                System.out.printf("\t\tFs-Last-Char-Index %d\n", table.fsLastCharIndex);
                System.out.printf("\t\tX-Average-Char-Width %f\n", table.xAverageCharWidth);
                System.out.printf("\t\tY-Subscript-X-Size %f\n", table.ySubscriptXSize);
                System.out.printf("\t\tY-Subscript-Y-Size %f\n", table.ySubscriptYSize);
                System.out.printf("\t\tY-Subscript-X-Offset %f\n", table.ySubscriptXOffset);
                System.out.printf("\t\tY-Subscript-Y-Offset %f\n", table.ySubscriptYOffset);
                System.out.printf("\t\tY-Superscript-X-Size %f\n", table.ySuperscriptXSize);
                System.out.printf("\t\tY-Superscript-Y-Size %f\n", table.ySuperscriptYSize);
                System.out.printf("\t\tY-Superscript-X-Offset %f\n", table.ySuperscriptXOffset);
                System.out.printf("\t\tY-Superscript-Y-Offset %f\n", table.ySuperscriptYOffset);
                System.out.printf("\t\tY-Strikeout-Size %f\n", table.yStrikeoutSize);
                System.out.printf("\t\tY-Strikeout-Position %f\n", table.yStrikeoutPosition);

                break;
              }
          }
        }
      } else {
        System.out.printf("Unrecognized font '%s'.\n", font.getName());
      }

      System.exit(0);
    } catch (java.io.IOException exc) {
      exc.printStackTrace();
      System.exit(1);
    }
  }