From 76e261ade41c6a7bc0a1ed9896dbd7c4f3e498da Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Sun, 15 Jun 2003 14:33:13 +0000 Subject: [PATCH] 2003-06-15 Masatake YAMATO * main.c (read_command_line): added new parameter, input_opts. (main): passed input_opts to read_command_line. Don't set input_opts->background_color here. (read_command_line): Set input_opts->background_color here. (read_command_line): Set input_opts->charcode here. 2003-06-12 Serge Vakulenko (Logged by Masatake.) * autotrace.h (_at_fitting_opts_type): added charcode. * autotrace.h (struct _at_input_opts_type): added charcode. * fit.c (new_fitting_opts): Initialize charcode. (fit_one_spline): Fixed two bugs, which caused unexpected aborts with diagnostics "zero determinant of C0*C1" and "assertion error in line 1276 of fit.c". * main.c (read_command_line::long_options): Added charcode as an option. * module.c: Added gf input. * output.c: included output-ugs.h. (output_formats): Added ugs output. --- ChangeLog | 29 +++++++++++++++++++++++++++++ HACKING | 7 ++++++- Makefile.am | 2 ++ THANKS | 1 + autotrace.c | 2 ++ autotrace.h | 6 ++++++ fit.c | 15 +++++++++------ main.c | 23 ++++++++++++++++------- module.c | 4 +++- output.c | 2 ++ 10 files changed, 76 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8e941c..eca464a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2003-06-15 Masatake YAMATO + + * main.c (read_command_line): added new parameter, input_opts. + (main): passed input_opts to read_command_line. + Don't set input_opts->background_color here. + (read_command_line): Set input_opts->background_color here. + (read_command_line): Set input_opts->charcode here. + +2003-06-12 Serge Vakulenko + + (Logged by Masatake.) + + * autotrace.h (_at_fitting_opts_type): added charcode. + + * autotrace.h (struct _at_input_opts_type): added charcode. + + * fit.c (new_fitting_opts): Initialize charcode. + (fit_one_spline): Fixed two bugs, which caused unexpected aborts with + diagnostics "zero determinant of C0*C1" + and "assertion error in line 1276 of fit.c". + + * main.c (read_command_line::long_options): Added + charcode as an option. + + * module.c: Added gf input. + + * output.c: included output-ugs.h. + (output_formats): Added ugs output. + 2003-06-11 Masatake YAMATO * tools-version.sh (TOOLS): Added glib-gettextize. diff --git a/HACKING b/HACKING index 047587a..e4ad1f8 100644 --- a/HACKING +++ b/HACKING @@ -109,11 +109,16 @@ This variable is passed to aclocal that is invoked by autogen.sh. See http://sourceforge.net/cvs/?group_id=11789 -The module name is autotrace. After checking out the codes, invoke +The module name is autotrace. After checking out the code, invoke autogen.sh in the distribution. That generates configure.in, Makefile.in and so on. autogen.sh invokes automake, autoconf, aclocal and autofig. +When you check out the code, you will find autotrace-0.27pre directory +under autotrace source code top directory. You should ignore +autotrace-0.27pre directory. The directory was checked in by +my mistake(Masatake YAMATO). It is difficult to remove a +directory from a CVS repository. * Autofig diff --git a/Makefile.am b/Makefile.am index bf9d83d..314449b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,6 +32,7 @@ endif input_src=input-pnm.c input-pnm.h \ input-bmp.c input-bmp.h \ input-tga.c input-tga.h \ +input-gf.c input-gf.h \ $(input_png_src) \ $(input_magick_src) @@ -51,6 +52,7 @@ output-er.c output-er.h \ output-fig.c output-fig.h \ output-sk.c output-sk.h \ output-svg.c output-svg.h \ +output-ugs.c output-ugs.h \ output-p2e.c output-p2e.h \ output-emf.c output-emf.h \ output-dxf.c output-dxf.h \ diff --git a/THANKS b/THANKS index 940b95d..5b6a94f 100644 --- a/THANKS +++ b/THANKS @@ -22,3 +22,4 @@ Ralf Stubner (bugfixes about pstoedit usage) Dag Wieers (rpm-spec file) Mario Kleiner (fix a bug in mig output) jakobfrandsen (report a bug in Makefile.am) +Serge Vakulenko (fix a bug, usg export, gf import) diff --git a/autotrace.c b/autotrace.c index 9d9af87..1d1585c 100644 --- a/autotrace.c +++ b/autotrace.c @@ -86,6 +86,7 @@ at_input_opts_new(void) at_input_opts_type * opts; XMALLOC(opts, sizeof(at_input_opts_type)); opts->background_color = NULL; + opts->charcode = 0; return opts; } @@ -94,6 +95,7 @@ at_input_opts_copy(at_input_opts_type * original) { at_input_opts_type * opts; opts = at_input_opts_new(); + *opts = *original; if (original->background_color) opts->background_color = at_color_copy(original->background_color); return opts; diff --git a/autotrace.h b/autotrace.h index d6e1097..0ef835c 100644 --- a/autotrace.h +++ b/autotrace.h @@ -123,6 +123,11 @@ N_("background-color : the color of the background that " \ "default is no background color.") at_color_type *background_color; +#define at_doc__charcode \ +N_("charcode : code of character to load from GF file, " \ +"allowed are 0..255; default is the first character in font.") + unsigned charcode; + #define at_doc__color_count \ N_("color-count : number of colors a color bitmap is reduced to, " \ "it does not work on grayscale, allowed are 1..256; " \ @@ -209,6 +214,7 @@ N_("width-weight-factor : weight factor for fitting the linewidth.") struct _at_input_opts_type { at_color_type *background_color; + unsigned charcode; /* Character code used only in GF input.*/ }; struct _at_output_opts_type diff --git a/fit.c b/fit.c index 4882252..187d437 100644 --- a/fit.c +++ b/fit.c @@ -110,6 +110,7 @@ new_fitting_opts (void) fitting_opts_type fitting_opts; fitting_opts.background_color = NULL; + fitting_opts.charcode = 0; fitting_opts.color_count = 0; fitting_opts.corner_always_threshold = (at_real) 60.0; fitting_opts.corner_surround = 4; @@ -1280,14 +1281,15 @@ fit_one_spline (curve_type curve, C0_C1_det = C[0][0] * C[1][1] - C[1][0] * C[0][1]; if (C0_C1_det == 0.0) { - LOG ("zero determinant of C0*C1"); - at_exception_fatal(exception, "zero determinant of C0*C1"); - goto cleanup; + /* Zero determinant */ + alpha1 = 0; + alpha2 = 0; } - + else + { alpha1 = X_C1_det / C0_C1_det; alpha2 = C0_X_det / C0_C1_det; - + } CONTROL1 (spline) = Vadd_point (START_POINT (spline), Vmult_scalar (t1_hat, alpha1)); CONTROL2 (spline) = Vadd_point (END_POINT (spline), @@ -1321,7 +1323,8 @@ set_initial_parameter_values (curve_type curve) CURVE_T (curve, p) = CURVE_T (curve, p - 1) + d; } - assert (LAST_CURVE_T (curve) != 0.0); + if (LAST_CURVE_T (curve) == 0.0) + LAST_CURVE_T (curve) = 1.0; for (p = 1; p < CURVE_LENGTH (curve); p++) CURVE_T (curve, p) = CURVE_T (curve, p) / LAST_CURVE_T (curve); diff --git a/main.c b/main.c index afdebd1..fd6b0b2 100644 --- a/main.c +++ b/main.c @@ -57,6 +57,7 @@ static void dot_printer(at_real percentage, at_address client_data); static char * read_command_line (int, char * [], at_fitting_opts_type *, + at_input_opts_type *, at_output_opts_type *); static unsigned int hctoi (char c); @@ -94,9 +95,11 @@ main (int argc, char * argv[]) textdomain(PACKAGE); #endif /* Def: ENABLE_NLS */ - fitting_opts = at_fitting_opts_new (); - output_opts = at_output_opts_new (); - input_name = read_command_line (argc, argv, fitting_opts, output_opts); + fitting_opts = at_fitting_opts_new (); + input_opts = at_input_opts_new (); + output_opts = at_output_opts_new (); + + input_name = read_command_line (argc, argv, fitting_opts, input_opts, output_opts); if (strgicmp (output_name, input_name)) FATAL(_("Input and output file may not be the same\n")); @@ -141,10 +144,6 @@ main (int argc, char * argv[]) /* Open the main input file. */ if (input_reader != NULL) { - input_opts = at_input_opts_new (); - if (fitting_opts->background_color) - input_opts->background_color = at_color_copy(fitting_opts->background_color); - bitmap = at_bitmap_read(input_reader, input_name, input_opts, exception_handler, NULL); @@ -214,6 +213,7 @@ main (int argc, char * argv[]) should be ignored, for example FFFFFF;\n\ default is no background color.\n\ centerline: trace a character's centerline, rather than its outline.\n\ +charcode : code of character to load from GF font file.\n\ color-count : number of colors a color bitmap is reduced to,\n\ it does not work on grayscale, allowed are 1..256;\n\ default is 0, that means not color reduction is done.\n\ @@ -265,6 +265,7 @@ width-weight-factor : weight factor for fitting the linewidth.\n\ static char * read_command_line (int argc, char * argv[], at_fitting_opts_type * fitting_opts, + at_input_opts_type * input_opts, at_output_opts_type * output_opts) { int g; /* `getopt' return code. */ @@ -275,6 +276,7 @@ read_command_line (int argc, char * argv[], { "debug-arch", 0, 0, 0 }, { "debug-bitmap", 0, (int *)&dumping_bitmap, 1 }, { "centerline", 0, 0, 0 }, + { "charcode", 1, 0, 0 }, { "color-count", 1, 0, 0 }, { "corner-always-threshold", 1, 0, 0 }, { "corner-surround", 1, 0, 0 }, @@ -323,10 +325,17 @@ read_command_line (int argc, char * argv[], fitting_opts->background_color = at_color_new((unsigned char)(hctoi (optarg[0]) * 16 + hctoi (optarg[1])), (unsigned char)(hctoi (optarg[2]) * 16 + hctoi (optarg[3])), (unsigned char)(hctoi (optarg[4]) * 16 + hctoi (optarg[5]))); + input_opts->background_color = at_color_copy(fitting_opts->background_color); } else if (ARGUMENT_IS ("centerline")) fitting_opts->centerline = true; + else if (ARGUMENT_IS ("charcode")) + { + fitting_opts->charcode = strtoul (optarg, 0, 0); + input_opts->charcode = fitting_opts->charcode; + } + else if (ARGUMENT_IS ("color-count")) fitting_opts->color_count = atou (optarg); diff --git a/module.c b/module.c index fd542e2..a9d6d63 100644 --- a/module.c +++ b/module.c @@ -30,6 +30,8 @@ #include "input-pnm.h" #include "input-bmp.h" #include "input-tga.h" +#include "input-gf.h" + #ifdef HAVE_LIBPNG #include "input-png.h" #endif /* HAVE_LIBPNG */ @@ -56,7 +58,7 @@ at_module_init (void) at_input_add_handler_full ("PGM", "Portable graymap format", input_pnm_reader, 0, "PGM", NULL); at_input_add_handler_full ("PPM", "Portable pixmap format", input_pnm_reader, 0, "PPM", NULL); - + at_input_add_handler ("GF", "TeX raster font", input_gf_reader); #if HAVE_MAGICK #if (MagickLibVersion < 0x0534) diff --git a/output.c b/output.c index cc38307..8851982 100644 --- a/output.c +++ b/output.c @@ -32,6 +32,7 @@ #include "output-p2e.h" #include "output-sk.h" #include "output-svg.h" +#include "output-ugs.h" #include "output-fig.h" #ifdef HAVE_LIBSWF #include "output-swf.h" @@ -61,6 +62,7 @@ static struct output_format_entry output_formats[] = { {"p2e", "pstoedit frontend format", output_p2e_writer}, {"sk", "Sketch", output_sk_writer}, {"svg", "Scalable Vector Graphics", output_svg_writer}, + {"ugs", "Unicode glyph source", output_ugs_writer}, {"fig", "XFIG 3.2", output_fig_writer}, #ifdef HAVE_LIBSWF {"swf", "Shockwave Flash 3", output_swf_writer},