From 6b56362f68dd52b0a85b675a5737ddb86c3421a7 Mon Sep 17 00:00:00 2001 From: handa Date: Mon, 2 Feb 2004 11:04:23 +0000 Subject: [PATCH] *** empty log message *** --- example/otftobdf.c | 4 ++++ example/otfview.c | 47 ++++++++++++++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/example/otftobdf.c b/example/otftobdf.c index 1a5f584..0d2aed6 100644 --- a/example/otftobdf.c +++ b/example/otftobdf.c @@ -139,10 +139,12 @@ main (int argc, char **argv) if ((err = FT_Set_Pixel_Sizes (face, 0, pixel_size))) FATAL_ERROR ("%s\n", "FT_Set_Pixel_Sizes: error"); + /* for (i = nchars = 0; i < 0x10000; i++) if (! FT_Load_Glyph (face, i, FT_LOAD_RENDER | FT_LOAD_MONOCHROME) && face->glyph->bitmap.rows * face->glyph->bitmap.width) nchars++; + */ for (i = 0; i < 0x10000; i++) if ((unicode_table[i] = FT_Get_Char_Index (face, (FT_ULong) i))) { @@ -158,8 +160,10 @@ main (int argc, char **argv) for (i = 0; i < 0x10000; i++) if (unicode_table[i]) dump_image (pixel_size, unicode_table[i], i, 1); + /* for (i = 0; i < 0x10000; i++) dump_image (pixel_size, i, 0xE000 + i, 0); + */ dump_tailer (); exit (0); diff --git a/example/otfview.c b/example/otfview.c index 696bbd3..ae5f2d8 100644 --- a/example/otfview.c +++ b/example/otfview.c @@ -124,6 +124,7 @@ struct { } glyph_rec; OTF *otf; +char *filename; void create_pixmap (int pixel_size, int index) @@ -267,7 +268,6 @@ DumpProc (Widget w, XtPointer client_data, XtPointer pixel_size) Pixmap pixmap; XImage ximage, *image; int i, x, y; - FILE *fp; char *data; int bytes_per_line; @@ -311,6 +311,7 @@ DumpProc (Widget w, XtPointer client_data, XtPointer pixel_size) 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, @@ -358,13 +359,23 @@ DumpProc (Widget w, XtPointer client_data, XtPointer pixel_size) 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); } @@ -461,11 +472,11 @@ create_widgets (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); @@ -642,13 +653,14 @@ main (int argc, char **argv) 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 @@ -659,7 +671,7 @@ main (int argc, char **argv) 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) @@ -671,8 +683,9 @@ main (int argc, char **argv) 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); } -- 1.7.10.4