} glyph_rec;
OTF *otf;
+char *filename;
void
create_pixmap (int pixel_size, int index)
Pixmap pixmap;
XImage ximage, *image;
int i, x, y;
- FILE *fp;
char *data;
int bytes_per_line;
pixmap = XCreatePixmap (display,
RootWindow (display, DefaultScreen (display)),
pix_width, pix_height, 1);
+ XFillRectangle (display, pixmap, gc, 0, 0, pix_width, pix_height);
for (i = 0, x = margin; i <= 16; i++, x += g_width + 1)
XDrawLine (display, pixmap, gc_set, x, margin,
image = XGetImage (display, pixmap, 0, 0, pix_width, pix_height,
AllPlanes, XYPixmap);
XInitImage (image);
- fp = fopen ("temp", "w");
- fprintf (fp, "P4\n%d %d\n", image->width, image->height);
- bytes_per_line = (image->width + 7) / 8;
- data = image->data;
- for (y = 0; y < image->height; y++, data += image->bytes_per_line)
- fwrite (data, 1, bytes_per_line, fp);
- fclose (fp);
+ {
+ char *name = alloca (strlen (filename) + 5);
+ FILE *fp;
+
+ sprintf (name, "%s.pbm", filename);
+#if 1
+ fp = fopen (name, "w");
+ fprintf (fp, "P4\n%d %d\n", image->width, image->height);
+ bytes_per_line = (image->width + 7) / 8;
+ data = image->data;
+ for (y = 0; y < image->height; y++, data += image->bytes_per_line)
+ fwrite (data, 1, bytes_per_line, fp);
+ fclose (fp);
+#else
+ XWriteBitmapFile (display, name, pixmap, pix_width, pix_height, 0, 0);
+#endif
+ }
FT_Set_Pixel_Sizes (face, 0, (int) pixel_size);
}
frame, arg, 6);
XtSetArg (arg[0], XtNaccelerators, XtParseAcceleratorTable (quit_action));
- quit = XtCreateManagedWidget ("quit", commandWidgetClass,
+ quit = XtCreateManagedWidget ("Quit", commandWidgetClass,
command_area, arg, 1);
XtAddCallback (quit, XtNcallback, QuitProc, NULL);
- dump = XtCreateManagedWidget ("dump", commandWidgetClass,
+ dump = XtCreateManagedWidget ("Dump Image", commandWidgetClass,
command_area, arg, 1);
XtAddCallback (dump, XtNcallback, DumpProc, (XtPointer) pixel_size);
if (argc != 2)
FATAL_ERROR ("%s\n", "Usage: otfview [ X-OPTION ... ] OTF-FILE");
+ filename = argv[1];
- if (strstr (argv[1], ".ttf")
- || strstr (argv[1], ".TTF")
- || strstr (argv[1], ".otf")
- || strstr (argv[1], ".OTF"))
+ if (strstr (filename, ".ttf")
+ || strstr (filename, ".TTF")
+ || strstr (filename, ".otf")
+ || strstr (filename, ".OTF"))
{
- otf = OTF_open (argv[1]);
+ otf = OTF_open (filename);
if (! otf
|| OTF_get_table (otf, "head") < 0
|| OTF_get_table (otf, "cmap") < 0
if ((err = FT_Init_FreeType (&library)))
FATAL_ERROR ("%s\n", "FT_Init_FreeType: error");
- err = FT_New_Face (library, argv[1], 0, &face);
+ err = FT_New_Face (library, filename, 0, &face);
if (err == FT_Err_Unknown_File_Format)
FATAL_ERROR ("%s\n", "FT_New_Face: unknown file format");
else if (err)
char title[256];
Arg arg[1];
+ filename = basename (filename);
sprintf (title, "%s family:%s style:%s",
- basename (argv[1]), face->family_name, face->style_name);
+ filename, face->family_name, face->style_name);
XtSetArg (arg[0], XtNtitle, title);
XtSetValues (shell, arg, 1);
}