예제 #1
0
파일: Pfm2afm.java 프로젝트: kkazuo/clj-pdf
 private void putkerntab() throws IOException {
   if (kernpairs == 0) return;
   in.seek(kernpairs);
   int count = in.readUnsignedShortLE();
   int nzero = 0;
   int kerns[] = new int[count * 3];
   for (int k = 0; k < kerns.length; ) {
     kerns[k++] = in.read();
     kerns[k++] = in.read();
     if ((kerns[k++] = in.readShortLE()) != 0) ++nzero;
   }
   if (nzero == 0) return;
   out.print("StartKernData\nStartKernPairs");
   outval(nzero);
   out.print('\n');
   for (int k = 0; k < kerns.length; k += 3) {
     if (kerns[k + 2] != 0) {
       out.print("KPX ");
       out.print(WinChars[kerns[k]]);
       out.print(' ');
       out.print(WinChars[kerns[k + 1]]);
       outval(kerns[k + 2]);
       out.print('\n');
     }
   }
   /* Put out trailer */
   out.print("EndKernPairs\nEndKernData\n");
 }
예제 #2
0
파일: Pfm2afm.java 프로젝트: kkazuo/clj-pdf
 private void openpfm() throws IOException {
   in.seek(0);
   vers = in.readShortLE();
   h_len = in.readIntLE();
   copyright = readString(60);
   type = in.readShortLE();
   points = in.readShortLE();
   verres = in.readShortLE();
   horres = in.readShortLE();
   ascent = in.readShortLE();
   intleading = in.readShortLE();
   extleading = in.readShortLE();
   italic = (byte) in.read();
   uline = (byte) in.read();
   overs = (byte) in.read();
   weight = in.readShortLE();
   charset = (byte) in.read();
   pixwidth = in.readShortLE();
   pixheight = in.readShortLE();
   kind = (byte) in.read();
   avgwidth = in.readShortLE();
   maxwidth = in.readShortLE();
   firstchar = in.read();
   lastchar = in.read();
   defchar = (byte) in.read();
   brkchar = (byte) in.read();
   widthby = in.readShortLE();
   device = in.readIntLE();
   face = in.readIntLE();
   bits = in.readIntLE();
   bitoff = in.readIntLE();
   extlen = in.readShortLE();
   psext = in.readIntLE();
   chartab = in.readIntLE();
   res1 = in.readIntLE();
   kernpairs = in.readIntLE();
   res2 = in.readIntLE();
   fontname = in.readIntLE();
   if (h_len != in.length() || extlen != 30 || fontname < 75 || fontname > 512)
     throw new IOException(MessageLocalization.getComposedMessage("not.a.valid.pfm.file"));
   in.seek(psext + 14);
   capheight = in.readShortLE();
   xheight = in.readShortLE();
   ascender = in.readShortLE();
   descender = in.readShortLE();
 }
예제 #3
0
파일: Pfm2afm.java 프로젝트: kkazuo/clj-pdf
  private void putchartab() throws IOException {
    int count = lastchar - firstchar + 1;
    int ctabs[] = new int[count];
    in.seek(chartab);
    for (int k = 0; k < count; ++k) ctabs[k] = in.readUnsignedShortLE();
    int back[] = new int[256];
    if (charset == 0) {
      for (int i = firstchar; i <= lastchar; ++i) {
        if (Win2PSStd[i] != 0) back[Win2PSStd[i]] = i;
      }
    }
    /* Put out the header */
    out.print("StartCharMetrics");
    outval(count);
    out.print('\n');

    /* Put out all encoded chars */
    if (charset != 0) {
      /*
       * If the charset is not the Windows standard, just put out
       * unnamed entries.
       */
      for (int i = firstchar; i <= lastchar; i++) {
        if (ctabs[i - firstchar] != 0) {
          outchar(i, ctabs[i - firstchar], null);
        }
      }
    } else {
      for (int i = 0; i < 256; i++) {
        int j = back[i];
        if (j != 0) {
          outchar(i, ctabs[j - firstchar], WinChars[j]);
          ctabs[j - firstchar] = 0;
        }
      }
      /* Put out all non-encoded chars */
      for (int i = firstchar; i <= lastchar; i++) {
        if (ctabs[i - firstchar] != 0) {
          outchar(-1, ctabs[i - firstchar], WinChars[i]);
        }
      }
    }
    /* Put out the trailer */
    out.print("EndCharMetrics\n");
  }
예제 #4
0
파일: Pfm2afm.java 프로젝트: kkazuo/clj-pdf
  private void putheader() throws IOException {
    out.print("StartFontMetrics 2.0\n");
    if (copyright.length() > 0) out.print("Comment " + copyright + '\n');
    out.print("FontName ");
    in.seek(fontname);
    String fname = readString();
    out.print(fname);
    out.print("\nEncodingScheme ");
    if (charset != 0) out.print("FontSpecific\n");
    else out.print("AdobeStandardEncoding\n");
    /*
     * The .pfm is missing full name, so construct from font name by
     * changing the hyphen to a space.  This actually works in a lot
     * of cases.
     */
    out.print("FullName " + fname.replace('-', ' '));
    if (face != 0) {
      in.seek(face);
      out.print("\nFamilyName " + readString());
    }

    out.print("\nWeight ");
    if (weight > 475 || fname.toLowerCase().indexOf("bold") >= 0) out.print("Bold");
    else if ((weight < 325 && weight != 0) || fname.toLowerCase().indexOf("light") >= 0)
      out.print("Light");
    else if (fname.toLowerCase().indexOf("black") >= 0) out.print("Black");
    else out.print("Medium");

    out.print("\nItalicAngle ");
    if (italic != 0 || fname.toLowerCase().indexOf("italic") >= 0) out.print("-12.00");
    /* this is a typical value; something else may work better for a
    specific font */
    else out.print("0");

    /*
     *  The mono flag in the pfm actually indicates whether there is a
     *  table of font widths, not if they are all the same.
     */
    out.print("\nIsFixedPitch ");
    if ((kind & 1) == 0 || /* Flag for mono */ avgwidth == maxwidth) {
        /* Avg width = max width */
      out.print("true");
      isMono = true;
    } else {
      out.print("false");
      isMono = false;
    }

    /*
     * The font bounding box is lost, but try to reconstruct it.
     * Much of this is just guess work.  The bounding box is required in
     * the .afm, but is not used by the PM font installer.
     */
    out.print("\nFontBBox");
    if (isMono) outval(-20); /* Just guess at left bounds */
    else outval(-100);
    outval(-(descender + 5)); /* Descender is given as positive value */
    outval(maxwidth + 10);
    outval(ascent + 5);

    /*
     * Give other metrics that were kept
     */
    out.print("\nCapHeight");
    outval(capheight);
    out.print("\nXHeight");
    outval(xheight);
    out.print("\nDescender");
    outval(descender);
    out.print("\nAscender");
    outval(ascender);
    out.print('\n');
  }