- if (charmap_index >= 0)
- idx = FT_Get_Char_Index (face, (FT_ULong) i);
- else
- idx = i;
- x = margin + (g_width + 1) * (i % 16);
- y = margin + (g_height + FONT_HEIGHT + 1) * (i / 16);
- if (FT_Load_Glyph (face, idx, FT_LOAD_RENDER | FT_LOAD_MONOCHROME) == 0)
- {
- ximage.height = face->glyph->bitmap.rows;
- ximage.width = face->glyph->bitmap.width;
- ximage.depth = 1;
- ximage.bits_per_pixel = 1;
- ximage.xoffset = 0;
- ximage.format = XYPixmap;
- ximage.data = (char *) face->glyph->bitmap.buffer;
- ximage.byte_order = MSBFirst;
- ximage.bitmap_unit = 8;
- ximage.bitmap_bit_order = MSBFirst;
- ximage.bitmap_pad = 8;
- ximage.bytes_per_line = face->glyph->bitmap.pitch;
- XInitImage (&ximage);
- XPutImage (display, pixmap, gc, &ximage, 0, 0,
- x + g_x + face->glyph->bitmap_left,
- y + g_y - face->glyph->bitmap_top,
- ximage.width, ximage.height);
- }
- sprintf (str, "0x%02X", i);
- XDrawString (display, pixmap, gc_inv,
- x + (g_width - XTextWidth (font, str, 4))/ 2,
- y + g_height + FONT_ASCENT, str, 4);
- }
+ FT_Set_Pixel_Sizes (face, 0, size);
+
+ sprintf (name, "%s-%04X.ps", face->family_name, index);
+ printf ("Writing %s ... ", name);
+ fflush (stdout);
+ fp = fopen (name, "w");
+
+ fprintf (fp, "%s\n", "%!PS-Adobe-2.0 EPSF-2.0");
+ fprintf (fp, "%s\n", "%%Creater: otfview");
+ fprintf (fp, "%s %s(%s)-%04X\n", "%%Title:",
+ face->family_name, face->style_name, index);
+ fprintf (fp, "%s\n", "%%Pages: 1");
+ fprintf (fp, "%s %d %d %d %d\n", "%%BoundingBox:",
+ xoff, yoff, xoff + total_width, yoff + total_height);
+ fprintf (fp, "%s\n", "%%EndComments");
+ fprintf (fp, "%s\n", "%%BeginProlog");
+ fprintf (fp, "/W %d def\n", unit + margin * 2);
+ fprintf (fp, "/H %d def\n", unit + margin * 2 + label_height);
+ fprintf (fp, "/STR 10 string def\n");
+ fprintf (fp, "/DrawIndex {\n");
+ fprintf (fp, " I 16 lt { (000) show } { I 256 lt { (00) show } { I 4096 lt { (0) show} if } ifelse } ifelse I 16 STR cvrs show\n");
+ fprintf (fp, "} def\n");
+ fprintf (fp, "/DrawTitle {\n");
+ fprintf (fp, " /Courier findfont 20 scalefont setfont\n");
+ fprintf (fp, " %d %d 4 add moveto\n", xoff + total_width / 2,
+ yoff + total_height - title_height + 2);
+ fprintf (fp, " (%s(%s)-%04X) dup stringwidth pop 2 div neg 0 rmoveto show\n",
+ face->family_name, face->style_name, index);
+ fprintf (fp, "} def\n");
+ fprintf (fp, "/DrawFrame { gsave %d %d translate 0 setlinewidth\n",
+ xoff, yoff);
+ fprintf (fp, " /Courier findfont 10 scalefont setfont\n");
+ fprintf (fp, " /I %d def\n", index);
+ fprintf (fp, " 0 1 16 { W mul 0 moveto 0 H 16 mul rlineto stroke } for\n");
+ fprintf (fp, " 0 1 16 { H mul 0 exch moveto W 16 mul 0 rlineto stroke } for\n");
+ fprintf (fp, " 0 1 15 { H mul %d add 0 exch moveto W 16 mul 0 rlineto stroke } for\n", label_height);
+ fprintf (fp, " 15 -1 0 { gsave H mul 0 exch translate 0 0 moveto\n");
+ fprintf (fp, " 0 1 15 { gsave W mul 0 moveto\n");
+ fprintf (fp, " 4 2 rmoveto DrawIndex /I I 1 add def grestore} for\n");
+ fprintf (fp, " grestore } for grestore } def\n");
+ fprintf (fp, "%s\n", "%%EndProlog");
+ fprintf (fp, "DrawTitle DrawFrame\n");
+
+ for (i = 0; i < 16; i++)
+ for (j = 0; j < 16; j++, index++)
+ {
+ int idx;
+
+ if (charmap_index >= 0)
+ idx = FT_Get_Char_Index (face, (FT_ULong) index);
+ else
+ idx = index;
+ if (idx > 0
+ && FT_Load_Glyph (face, idx, FT_LOAD_RENDER | FT_LOAD_MONOCHROME) == 0
+ && face->glyph->bitmap.rows > 0
+ && face->glyph->bitmap.width > 0)
+ {
+ unsigned char *p = face->glyph->bitmap.buffer;
+ int width = (face->glyph->bitmap.width - 1) / 8 + 1;
+
+ fprintf (fp, "gsave %f %f translate %d %d scale 0 0 moveto\n",
+ xoff + (unit + margin * 2) * j + margin - g_x,
+ yoff + (unit + label_height + margin * 2) * (15 - i) + label_height + margin - g_y,
+ unit, unit);
+ fprintf (fp, "%d %d true [%f 0 0 %f %d %d]\n",
+ width * 8, face->glyph->bitmap.rows,
+ scale, -scale, -face->glyph->bitmap_left,
+ face->glyph->bitmap_top);
+ fprintf (fp, "{< ");
+ for (k = 0; k < face->glyph->bitmap.rows;
+ k++, p += face->glyph->bitmap.pitch)
+ {
+ for (l = 0; l < width; l++)
+ fprintf (fp, "%02X", p[l]);
+ fprintf (fp, "\n");
+ }
+ fprintf (fp, ">} imagemask grestore\n");
+ }
+ else
+ {
+ int boxsize = unit + margin * 2;
+
+ fprintf (fp, "gsave 0 setlinewidth %d %d translate\n",
+ xoff + boxsize * j,
+ yoff + (boxsize + label_height) * (15 - i) + label_height);
+ fprintf (fp, "0 0 moveto %d %d lineto stroke\n",
+ boxsize, boxsize);
+ fprintf (fp, "0 %d moveto %d 0 lineto stroke grestore\n",
+ boxsize, boxsize);
+ }
+ }
+ fprintf (fp, "showpage\n");
+ fclose (fp);
+ printf ("done\n");