diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-19 23:49:56 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-19 23:49:56 +0200 |
commit | 781969994b5381ba4bed03beef217f9bde6e7c58 (patch) | |
tree | aede27c7532f0fbe82f03dc0c04c9316be510fd5 /tools/gslite | |
parent | 0b17959f31afe3baffbc328e7f92e88e634ad8b8 (diff) |
Indent with spaces and strip trailing whitespace.
Diffstat (limited to 'tools/gslite')
-rw-r--r-- | tools/gslite/gslt.h | 1 | ||||
-rw-r--r-- | tools/gslite/gslt_alloc.c | 95 | ||||
-rw-r--r-- | tools/gslite/gslt_alloc.h | 1 | ||||
-rw-r--r-- | tools/gslite/gslt_font.h | 1 | ||||
-rw-r--r-- | tools/gslite/gslt_font_api.c | 1 | ||||
-rw-r--r-- | tools/gslite/gslt_font_api.h | 1 | ||||
-rw-r--r-- | tools/gslite/gslt_font_api_test.c | 2 | ||||
-rw-r--r-- | tools/gslite/gslt_font_cache.c | 25 | ||||
-rw-r--r-- | tools/gslite/gslt_font_cff.c | 657 | ||||
-rw-r--r-- | tools/gslite/gslt_font_encoding.c | 57 | ||||
-rw-r--r-- | tools/gslite/gslt_font_glyph.c | 95 | ||||
-rw-r--r-- | tools/gslite/gslt_font_int.h | 1 | ||||
-rw-r--r-- | tools/gslite/gslt_font_test.c | 78 | ||||
-rw-r--r-- | tools/gslite/gslt_font_ttf.c | 9 | ||||
-rw-r--r-- | tools/gslite/gslt_image.c | 11 | ||||
-rw-r--r-- | tools/gslite/gslt_image.h | 5 | ||||
-rw-r--r-- | tools/gslite/gslt_image_jpeg.c | 26 | ||||
-rw-r--r-- | tools/gslite/gslt_image_png.c | 24 | ||||
-rw-r--r-- | tools/gslite/gslt_image_test.c | 77 | ||||
-rw-r--r-- | tools/gslite/gslt_image_threads_test.c | 82 | ||||
-rw-r--r-- | tools/gslite/gslt_image_tiff.c | 42 | ||||
-rw-r--r-- | tools/gslite/gslt_init.c | 7 | ||||
-rw-r--r-- | tools/gslite/gslt_test.c | 644 |
23 files changed, 953 insertions, 989 deletions
diff --git a/tools/gslite/gslt.h b/tools/gslite/gslt.h index 347862ac8..96c6a5de5 100644 --- a/tools/gslite/gslt.h +++ b/tools/gslite/gslt.h @@ -61,4 +61,3 @@ void gslt_free_library(gs_memory_t *mem); void gslt_get_device_param(gs_memory_t *mem, gx_device *dev, char *key); void gslt_set_device_param(gs_memory_t *mem, gx_device *dev, char *key, char *val); - diff --git a/tools/gslite/gslt_alloc.c b/tools/gslite/gslt_alloc.c index 5e21ad188..10aff0f04 100644 --- a/tools/gslite/gslt_alloc.c +++ b/tools/gslite/gslt_alloc.c @@ -75,7 +75,7 @@ gslt_alloc(gs_memory_t *mem, uint size, gs_memory_type_ptr_t type, client_name_t /* NB apparently there is code floating around that does 0 size mallocs. sigh. */ if ( size == 0 ) - return NULL; + return NULL; /* use 2 starting machine words for size and type - assumes malloc() returns on max boundary and first 2 words will hold @@ -85,23 +85,23 @@ gslt_alloc(gs_memory_t *mem, uint size, gs_memory_type_ptr_t type, client_name_t newsize = size + minsize + minsize; { - byte *ptr = (byte *)malloc(newsize); - if ( !ptr ) - return NULL; - num_alloc_called ++; + byte *ptr = (byte *)malloc(newsize); + if ( !ptr ) + return NULL; + num_alloc_called ++; #ifdef DEBUG - if_debug2('A', "[da]:malloc:%p:%s\n", &ptr[minsize * 2], cname ); + if_debug2('A', "[da]:malloc:%p:%s\n", &ptr[minsize * 2], cname ); #endif - /* set the type and size */ - set_type(ptr, type); - set_size(ptr, size); - /* initialize for debugging */ + /* set the type and size */ + set_type(ptr, type); + set_size(ptr, size); + /* initialize for debugging */ #ifdef DEBUG - if ( gs_debug_c('@') ) - memset(&ptr[minsize * 2], 0xff, get_size(&ptr[minsize * 2])); + if ( gs_debug_c('@') ) + memset(&ptr[minsize * 2], 0xff, get_size(&ptr[minsize * 2])); #endif - /* return the memory after the size and type words. */ - return &ptr[minsize * 2]; + /* return the memory after the size and type words. */ + return &ptr[minsize * 2]; } } @@ -119,47 +119,46 @@ gslt_alloc_bytes(gs_memory_t * mem, uint size, client_name_t cname) static void * gslt_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype, - client_name_t cname) + client_name_t cname) { return gslt_alloc(mem, pstype->ssize, pstype, cname); } static void * gslt_alloc_struct(gs_memory_t * mem, gs_memory_type_ptr_t pstype, - client_name_t cname) + client_name_t cname) { return gslt_alloc(mem, pstype->ssize, pstype, cname); } static byte * gslt_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements, - uint elt_size, client_name_t cname) + uint elt_size, client_name_t cname) { return gslt_alloc_bytes(mem, num_elements * elt_size, cname); } static byte * gslt_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size, - client_name_t cname) + client_name_t cname) { return gslt_alloc_bytes(mem, num_elements * elt_size, cname); } static void * gslt_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements, - gs_memory_type_ptr_t pstype, client_name_t cname) + gs_memory_type_ptr_t pstype, client_name_t cname) { return gslt_alloc(mem, num_elements * pstype->ssize, pstype, cname); } static void * gslt_alloc_struct_array(gs_memory_t * mem, uint num_elements, - gs_memory_type_ptr_t pstype, client_name_t cname) + gs_memory_type_ptr_t pstype, client_name_t cname) { return gslt_alloc(mem, num_elements * pstype->ssize, pstype, cname); } - static void * gslt_resize_object(gs_memory_t * mem, void *obj, uint new_num_elements, client_name_t cname) { @@ -173,8 +172,8 @@ gslt_resize_object(gs_memory_t * mem, void *obj, uint new_num_elements, client_n ulong new_size = (objs_type->ssize * new_num_elements) + header_size; /* replace the size field */ ptr = (byte *)realloc(&bptr[-header_size], new_size); - if ( !ptr ) - return NULL; + if ( !ptr ) + return NULL; num_resize_called ++; @@ -186,24 +185,23 @@ gslt_resize_object(gs_memory_t * mem, void *obj, uint new_num_elements, client_n return &ptr[round_up_to_align(1) * 2]; } - static void gslt_free_object(gs_memory_t * mem, void *ptr, client_name_t cname) { if ( ptr != NULL ) { - byte *bptr = (byte *)ptr; - uint header_size = round_up_to_align(1) * 2; + byte *bptr = (byte *)ptr; + uint header_size = round_up_to_align(1) * 2; #ifdef DEBUG - if ( gs_debug_c('@') ) - memset(bptr-header_size, 0xee, header_size + get_size(ptr)); + if ( gs_debug_c('@') ) + memset(bptr-header_size, 0xee, header_size + get_size(ptr)); #endif - free(bptr-header_size); + free(bptr-header_size); + + num_free_called ++; - num_free_called ++; - #ifdef DEBUG - /* da for debug allocator - so scripts can parse the trace */ - if_debug2('A', "[da]:free:%p:%s\n", ptr, cname ); + /* da for debug allocator - so scripts can parse the trace */ + if_debug2('A', "[da]:free:%p:%s\n", ptr, cname ); #endif } } @@ -224,7 +222,7 @@ gslt_alloc_string(gs_memory_t * mem, uint nbytes, client_name_t cname) static byte * gslt_resize_string(gs_memory_t * mem, byte * data, uint old_num, uint new_num, - client_name_t cname) + client_name_t cname) { /* just resize object - ignores old_num */ return gslt_resize_object(mem, data, new_num, cname); @@ -232,13 +230,12 @@ gslt_resize_string(gs_memory_t * mem, byte * data, uint old_num, uint new_num, static void gslt_free_string(gs_memory_t * mem, byte * data, uint nbytes, - client_name_t cname) + client_name_t cname) { gslt_free_object(mem, data, cname); return; } - static void gslt_status(gs_memory_t * mem, gs_memory_status_t * pstat) { @@ -263,7 +260,6 @@ gslt_consolidate_free(gs_memory_t *mem) return; } - static uint gslt_object_size(gs_memory_t * mem, const void /*obj_header_t */ *obj) { @@ -278,7 +274,7 @@ gslt_object_type(gs_memory_t * mem, const void /*obj_header_t */ *obj) static int gslt_register_root(gs_memory_t * mem, gs_gc_root_t * rp, gs_ptr_type_t ptype, - void **up, client_name_t cname) + void **up, client_name_t cname) { return 0; } @@ -296,11 +292,9 @@ no_recover_proc(gs_memory_retrying_t *rmem, void *proc_data) return RECOVER_STATUS_NO_RETRY; } - /* forward decl */ static gs_memory_t * gslt_stable(gs_memory_t *mem); - gs_memory_retrying_t gslt_mem = { (gs_memory_t *)&gslt_mem, /* also this is stable_memory since no save/restore */ { gslt_alloc_bytes_immovable, /* alloc_bytes_immovable */ @@ -310,7 +304,7 @@ gs_memory_retrying_t gslt_mem = { gslt_status, /* status */ gslt_free_all, /* free_all */ gslt_consolidate_free, /* consolidate_free */ - gslt_alloc_bytes, /* alloc_bytes */ + gslt_alloc_bytes, /* alloc_bytes */ gslt_alloc_struct, /* alloc_struct */ gslt_alloc_struct_immovable, /* alloc_struct_immovable */ gslt_alloc_byte_array, /* alloc_byte_array */ @@ -323,9 +317,9 @@ gs_memory_retrying_t gslt_mem = { gslt_alloc_string_immovable, /* alloc_string_immovable */ gslt_resize_string, /* resize_string */ gslt_free_string, /* free_string */ - gslt_register_root, /* register_root */ + gslt_register_root, /* register_root */ gslt_unregister_root, /* unregister_root */ - gslt_enable_free /* enable_free */ + gslt_enable_free /* enable_free */ }, NULL, /* gs_lib_ctx */ NULL, /* head */ @@ -350,7 +344,7 @@ const gs_malloc_memory_t gslt_malloc_memory = { gslt_status, /* status */ gslt_free_all, /* free_all */ gslt_consolidate_free, /* consolidate_free */ - gslt_alloc_bytes, /* alloc_bytes */ + gslt_alloc_bytes, /* alloc_bytes */ gslt_alloc_struct, /* alloc_struct */ gslt_alloc_struct_immovable, /* alloc_struct_immovable */ gslt_alloc_byte_array, /* alloc_byte_array */ @@ -363,16 +357,16 @@ const gs_malloc_memory_t gslt_malloc_memory = { gslt_alloc_string_immovable, /* alloc_string_immovable */ gslt_resize_string, /* resize_string */ gslt_free_string, /* free_string */ - gslt_register_root, /* register_root */ + gslt_register_root, /* register_root */ gslt_unregister_root, /* unregister_root */ - gslt_enable_free /* enable_free */ - }, + gslt_enable_free /* enable_free */ + }, NULL, /* gs_lib_ctx */ NULL, /* head */ NULL, /* non_gc_memory */ 0, /* allocated */ - 0, /* limit */ - 0, /* used */ + 0, /* limit */ + 0, /* used */ 0 /* max used */ }; @@ -387,7 +381,7 @@ gs_memory_t * gslt_alloc_init() { if ( gslt_malloc_init() == NULL ) - return NULL; + return NULL; gs_lib_ctx_init((gs_memory_t *)&gslt_mem); @@ -405,4 +399,3 @@ gslt_alloc_print_leaks(void) dprintf1("number of resizes: %d\n", num_resize_called); dprintf1("number of leaked chunks: %d\n", num_alloc_called - num_free_called); } - diff --git a/tools/gslite/gslt_alloc.h b/tools/gslite/gslt_alloc.h index 280a20dbd..6c84a6498 100644 --- a/tools/gslite/gslt_alloc.h +++ b/tools/gslite/gslt_alloc.h @@ -2,4 +2,3 @@ gs_memory_t *gslt_alloc_init(void); void gslt_alloc_print_leaks(void); - diff --git a/tools/gslite/gslt_font.h b/tools/gslite/gslt_font.h index 8b33e3033..dc26951c7 100644 --- a/tools/gslite/gslt_font.h +++ b/tools/gslite/gslt_font.h @@ -135,4 +135,3 @@ void gslt_release_font_glyph(gs_memory_t *mem, gslt_glyph_bitmap_t *slot); * Return -1 on failure. */ int gslt_measure_font_glyph(gs_state *pgs, gslt_font_t *font, int gid, gslt_glyph_metrics_t *mtx); - diff --git a/tools/gslite/gslt_font_api.c b/tools/gslite/gslt_font_api.c index 9b59ce5a9..563c7448a 100644 --- a/tools/gslite/gslt_font_api.c +++ b/tools/gslite/gslt_font_api.c @@ -774,4 +774,3 @@ gslt_measure_font_glyph(gslt_font_t *xf, int gid, gslt_glyph_metrics_t *mtx) return 0; } #endif - diff --git a/tools/gslite/gslt_font_api.h b/tools/gslite/gslt_font_api.h index 220328082..a94e42b9a 100644 --- a/tools/gslite/gslt_font_api.h +++ b/tools/gslite/gslt_font_api.h @@ -127,4 +127,3 @@ int gslt_render_font_glyph(gs_state *pgs, gslt_font_t *font, gs_matrix *tm, int * Return -1 on failure. */ int gslt_measure_font_glyph(gs_state *pgs, gslt_font_t *font, int gid, gslt_glyph_metrics_t *mtx); - diff --git a/tools/gslite/gslt_font_api_test.c b/tools/gslite/gslt_font_api_test.c index 7425f64dc..1c34e67da 100644 --- a/tools/gslite/gslt_font_api_test.c +++ b/tools/gslite/gslt_font_api_test.c @@ -226,7 +226,6 @@ main(int argc, const char *argv[]) continue; } - printf("glyph %3d: v=%f,%f w=%f,%f ", gid, mtx.v[0], mtx.v[1], mtx.w[0], mtx.w[1]); printf(" -> %dx%d+(%d,%d) w=%f,%f\n", slot.w, slot.h, @@ -265,4 +264,3 @@ main(int argc, const char *argv[]) return 0; } - diff --git a/tools/gslite/gslt_font_cache.c b/tools/gslite/gslt_font_cache.c index 2a7e0022c..f0a27489b 100644 --- a/tools/gslite/gslt_font_cache.c +++ b/tools/gslite/gslt_font_cache.c @@ -16,7 +16,6 @@ #include "gslt.h" #include "gslt_font.h" - /* * The font cache is a gs_font_dir. * It has some parameters that need to be set, @@ -53,7 +52,6 @@ gslt_free_font_cache(gs_memory_t *mem, gs_font_dir *fontdir) gs_free_object(mem, fontdir, "gs_font_dir"); } - /* * Find the offset and length of an SFNT table. * Return -1 if no table by the specified name is found. @@ -72,14 +70,14 @@ gslt_find_sfnt_table(gslt_font_t *xf, char *name, int *lengthp) if (!memcmp(xf->data, "ttcf", 4)) { - int nfonts = u32(xf->data + 8); - if (xf->subfontid < 0 || xf->subfontid >= nfonts) - return -1; - offset = u32(xf->data + 12 + xf->subfontid * 4); + int nfonts = u32(xf->data + 8); + if (xf->subfontid < 0 || xf->subfontid >= nfonts) + return -1; + offset = u32(xf->data + 12 + xf->subfontid * 4); } else { - offset = 0; + offset = 0; } ntables = u16(xf->data + offset + 4); @@ -134,18 +132,18 @@ gslt_new_font(gs_memory_t *mem, gs_font_dir *fontdir, char *buf, int buflen, int xf->charstrings = 0; if (memcmp(xf->data, "OTTO", 4) == 0) - t = gslt_init_postscript_font(mem, fontdir, xf); + t = gslt_init_postscript_font(mem, fontdir, xf); else if (memcmp(xf->data, "\0\1\0\0", 4) == 0) - t = gslt_init_truetype_font(mem, fontdir, xf); + t = gslt_init_truetype_font(mem, fontdir, xf); else if (memcmp(xf->data, "true", 4) == 0) - t = gslt_init_truetype_font(mem, fontdir, xf); + t = gslt_init_truetype_font(mem, fontdir, xf); else if (memcmp(xf->data, "ttcf", 4) == 0) - t = gslt_init_truetype_font(mem, fontdir, xf); + t = gslt_init_truetype_font(mem, fontdir, xf); else { gslt_free_font(mem, xf); - gs_throw(-1, "not an opentype font"); - return NULL; + gs_throw(-1, "not an opentype font"); + return NULL; } if (t < 0) @@ -171,4 +169,3 @@ gslt_free_font(gs_memory_t *mem, gslt_font_t *xf) gs_free_object(mem, xf->font, "font object"); gs_free_object(mem, xf, "gslt_font struct"); } - diff --git a/tools/gslite/gslt_font_cff.c b/tools/gslite/gslt_font_cff.c index 15cb0a55a..aeee420a2 100644 --- a/tools/gslite/gslt_font_cff.c +++ b/tools/gslite/gslt_font_cff.c @@ -62,25 +62,25 @@ gslt_read_cff_real(byte *p, byte *e, float *val) while (txt < buf + (sizeof buf) - 3 && p < e) { - int b, n; - - b = *p++; - - n = (b >> 4) & 0xf; - if (n < 0xA) { *txt++ = n + '0'; } - else if (n == 0xA) { *txt++ = '.'; } - else if (n == 0xB) { *txt++ = 'E'; } - else if (n == 0xC) { *txt++ = 'E'; *txt++ = '-'; } - else if (n == 0xE) { *txt++ = '-'; } - else if (n == 0xF) { break; } - - n = b & 0xf; - if (n < 0xA) { *txt++ = n + '0'; } - else if (n == 0xA) { *txt++ = '.'; } - else if (n == 0xB) { *txt++ = 'E'; } - else if (n == 0xC) { *txt++ = 'E'; *txt++ = '-'; } - else if (n == 0xE) { *txt++ = '-'; } - else if (n == 0xF) { break; } + int b, n; + + b = *p++; + + n = (b >> 4) & 0xf; + if (n < 0xA) { *txt++ = n + '0'; } + else if (n == 0xA) { *txt++ = '.'; } + else if (n == 0xB) { *txt++ = 'E'; } + else if (n == 0xC) { *txt++ = 'E'; *txt++ = '-'; } + else if (n == 0xE) { *txt++ = '-'; } + else if (n == 0xF) { break; } + + n = b & 0xf; + if (n < 0xA) { *txt++ = n + '0'; } + else if (n == 0xA) { *txt++ = '.'; } + else if (n == 0xB) { *txt++ = 'E'; } + else if (n == 0xC) { *txt++ = 'E'; *txt++ = '-'; } + else if (n == 0xE) { *txt++ = '-'; } + else if (n == 0xF) { break; } } *txt = 0; @@ -97,55 +97,55 @@ gslt_read_cff_integer(byte *p, byte *e, int b0, int *val) if (b0 == 28) { - if (p + 2 > e) - { - gs_throw(-1, "corrupt dictionary (integer)"); - return 0; - } - b1 = *p++; - b2 = *p++; - *val = (b1 << 8) | b2; + if (p + 2 > e) + { + gs_throw(-1, "corrupt dictionary (integer)"); + return 0; + } + b1 = *p++; + b2 = *p++; + *val = (b1 << 8) | b2; } else if (b0 == 29) { - if (p + 4 > e) - { - gs_throw(-1, "corrupt dictionary (integer)"); - return 0; - } - b1 = *p++; - b2 = *p++; - b3 = *p++; - b4 = *p++; - *val = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; + if (p + 4 > e) + { + gs_throw(-1, "corrupt dictionary (integer)"); + return 0; + } + b1 = *p++; + b2 = *p++; + b3 = *p++; + b4 = *p++; + *val = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4; } else if (b0 < 247) { - *val = b0 - 139; + *val = b0 - 139; } else if (b0 < 251) { - if (p + 1 > e) - { - gs_throw(-1, "corrupt dictionary (integer)"); - return 0; - } - b1 = *p++; - *val = (b0 - 247) * 256 + b1 + 108; + if (p + 1 > e) + { + gs_throw(-1, "corrupt dictionary (integer)"); + return 0; + } + b1 = *p++; + *val = (b0 - 247) * 256 + b1 + 108; } else { - if (p + 1 > e) - { - gs_throw(-1, "corrupt dictionary (integer)"); - return 0; - } - b1 = *p++; - *val = -(b0 - 251) * 256 - b1 - 108; + if (p + 1 > e) + { + gs_throw(-1, "corrupt dictionary (integer)"); + return 0; + } + b1 = *p++; + *val = -(b0 - 251) * 256 - b1 - 108; } return p; @@ -168,191 +168,191 @@ gslt_read_cff_dict(byte *p, byte *e, gslt_font_t *fontobj, gs_font_type1 *pt1) n = 0; while (p < e) { - b0 = *p++; - - if (b0 < 22) - { - if (b0 == 12) - { - if (p + 1 > e) - { - return gs_throw(-1, "corrupt dictionary (operator)"); - } - b0 = 0x100 | *p++; - } - - /* some CFF file offsets */ - - if (b0 == 17) - { - fontobj->charstrings = fontobj->cffdata + args[0].ival; - } - - if (b0 == 18) - { - privatelen = args[0].ival; - privateofs = args[1].ival; - } - - if (b0 == 19) - { - fontobj->subrs = fontobj->cffdata + offset + args[0].ival; - } - - if (b0 == (256 | 36)) - errprintf("warning: cid cff fonts not supported yet"); - if (b0 == (256 | 37)) - errprintf("warning: cid cff fonts not supported yet"); - - /* Type1 stuff that need to be set for the pt1 struct */ - - if (b0 == (256 | 6)) - { - if (args[0].ival == 1) - { - pt1->data.interpret = gs_type1_interpret; - pt1->data.lenIV = -1; // FIXME - } - } - - if (b0 == (256 | 7)) - { - pt1->FontMatrix.xx = args[0].fval * 1000; - pt1->FontMatrix.xy = args[1].fval * 1000; - pt1->FontMatrix.yx = args[2].fval * 1000; - pt1->FontMatrix.yy = args[3].fval * 1000; - pt1->FontMatrix.tx = args[4].fval * 1000; - pt1->FontMatrix.ty = args[5].fval * 1000; - } - - if (b0 == 5) - { - pt1->FontBBox.p.x = args[0].fval; - pt1->FontBBox.p.y = args[1].fval; - pt1->FontBBox.q.x = args[2].fval; - pt1->FontBBox.q.y = args[3].fval; - } - - if (b0 == 20) - pt1->data.defaultWidthX = float2fixed(args[0].fval); - - if (b0 == 21) - pt1->data.nominalWidthX = float2fixed(args[0].fval); - - if (b0 == (256 | 19)) - pt1->data.initialRandomSeed = args[0].ival; - - /* Monday morning blues */ - - if (b0 == 6) - { - pt1->data.BlueValues.count = n / 2; - for (f = 0, i = 0; i < n; f += args[i].fval, i++) - pt1->data.BlueValues.values[i] = f; - } - - if (b0 == 7) - { - pt1->data.OtherBlues.count = n / 2; - for (f = 0, i = 0; i < n; f += args[i].fval, i++) - pt1->data.OtherBlues.values[i] = f; - } - - if (b0 == 8) - { - pt1->data.FamilyBlues.count = n / 2; - for (f = 0, i = 0; i < n; f += args[i].fval, i++) - pt1->data.FamilyBlues.values[i] = f; - } - - if (b0 == 9) - { - pt1->data.FamilyOtherBlues.count = n / 2; - for (f = 0, i = 0; i < n; f += args[i].fval, i++) - pt1->data.FamilyOtherBlues.values[i] = f; - } - - if (b0 == 10) - { - pt1->data.StdHW.count = 1; - pt1->data.StdHW.values[0] = args[0].fval; - } - - if (b0 == 11) - { - pt1->data.StdVW.count = 1; - pt1->data.StdVW.values[0] = args[0].fval; - } - - if (b0 == (256 | 9)) - pt1->data.BlueScale = args[0].fval; - - if (b0 == (256 | 10)) - pt1->data.BlueShift = args[0].fval; - - if (b0 == (256 | 11)) - pt1->data.BlueFuzz = args[0].fval; - - if (b0 == (256 | 12)) - { - pt1->data.StemSnapH.count = n; - for (f = 0, i = 0; i < n; f += args[i].fval, i++) - pt1->data.StemSnapH.values[i] = f; - } - - if (b0 == (256 | 13)) - { - pt1->data.StemSnapV.count = n; - for (f = 0, i = 0; i < n; f += args[i].fval, i++) - pt1->data.StemSnapV.values[i] = f; - } - - if (b0 == (256 | 14)) - pt1->data.ForceBold = args[0].ival; - - if (b0 == (256 | 17)) - pt1->data.LanguageGroup = args[0].ival; - - if (b0 == (256 | 18)) - pt1->data.ExpansionFactor = args[0].fval; - - n = 0; - } - - else - { - if (b0 == 30) - { - p = gslt_read_cff_real(p, e, &args[n].fval); - if (!p) - return gs_throw(-1, "corrupt dictionary operand"); - args[n].ival = (int) args[n].fval; - n++; - } - else if (b0 == 28 || b0 == 29 || (b0 >= 32 && b0 <= 254)) - { - p = gslt_read_cff_integer(p, e, b0, &args[n].ival); - if (!p) - return gs_throw(-1, "corrupt dictionary operand"); - args[n].fval = (float) args[n].ival; - n++; - } - else - { - return gs_throw1(-1, "corrupt dictionary operand (b0 = %d)", b0); - } - } + b0 = *p++; + + if (b0 < 22) + { + if (b0 == 12) + { + if (p + 1 > e) + { + return gs_throw(-1, "corrupt dictionary (operator)"); + } + b0 = 0x100 | *p++; + } + + /* some CFF file offsets */ + + if (b0 == 17) + { + fontobj->charstrings = fontobj->cffdata + args[0].ival; + } + + if (b0 == 18) + { + privatelen = args[0].ival; + privateofs = args[1].ival; + } + + if (b0 == 19) + { + fontobj->subrs = fontobj->cffdata + offset + args[0].ival; + } + + if (b0 == (256 | 36)) + errprintf("warning: cid cff fonts not supported yet"); + if (b0 == (256 | 37)) + errprintf("warning: cid cff fonts not supported yet"); + + /* Type1 stuff that need to be set for the pt1 struct */ + + if (b0 == (256 | 6)) + { + if (args[0].ival == 1) + { + pt1->data.interpret = gs_type1_interpret; + pt1->data.lenIV = -1; // FIXME + } + } + + if (b0 == (256 | 7)) + { + pt1->FontMatrix.xx = args[0].fval * 1000; + pt1->FontMatrix.xy = args[1].fval * 1000; + pt1->FontMatrix.yx = args[2].fval * 1000; + pt1->FontMatrix.yy = args[3].fval * 1000; + pt1->FontMatrix.tx = args[4].fval * 1000; + pt1->FontMatrix.ty = args[5].fval * 1000; + } + + if (b0 == 5) + { + pt1->FontBBox.p.x = args[0].fval; + pt1->FontBBox.p.y = args[1].fval; + pt1->FontBBox.q.x = args[2].fval; + pt1->FontBBox.q.y = args[3].fval; + } + + if (b0 == 20) + pt1->data.defaultWidthX = float2fixed(args[0].fval); + + if (b0 == 21) + pt1->data.nominalWidthX = float2fixed(args[0].fval); + + if (b0 == (256 | 19)) + pt1->data.initialRandomSeed = args[0].ival; + + /* Monday morning blues */ + + if (b0 == 6) + { + pt1->data.BlueValues.count = n / 2; + for (f = 0, i = 0; i < n; f += args[i].fval, i++) + pt1->data.BlueValues.values[i] = f; + } + + if (b0 == 7) + { + pt1->data.OtherBlues.count = n / 2; + for (f = 0, i = 0; i < n; f += args[i].fval, i++) + pt1->data.OtherBlues.values[i] = f; + } + + if (b0 == 8) + { + pt1->data.FamilyBlues.count = n / 2; + for (f = 0, i = 0; i < n; f += args[i].fval, i++) + pt1->data.FamilyBlues.values[i] = f; + } + + if (b0 == 9) + { + pt1->data.FamilyOtherBlues.count = n / 2; + for (f = 0, i = 0; i < n; f += args[i].fval, i++) + pt1->data.FamilyOtherBlues.values[i] = f; + } + + if (b0 == 10) + { + pt1->data.StdHW.count = 1; + pt1->data.StdHW.values[0] = args[0].fval; + } + + if (b0 == 11) + { + pt1->data.StdVW.count = 1; + pt1->data.StdVW.values[0] = args[0].fval; + } + + if (b0 == (256 | 9)) + pt1->data.BlueScale = args[0].fval; + + if (b0 == (256 | 10)) + pt1->data.BlueShift = args[0].fval; + + if (b0 == (256 | 11)) + pt1->data.BlueFuzz = args[0].fval; + + if (b0 == (256 | 12)) + { + pt1->data.StemSnapH.count = n; + for (f = 0, i = 0; i < n; f += args[i].fval, i++) + pt1->data.StemSnapH.values[i] = f; + } + + if (b0 == (256 | 13)) + { + pt1->data.StemSnapV.count = n; + for (f = 0, i = 0; i < n; f += args[i].fval, i++) + pt1->data.StemSnapV.values[i] = f; + } + + if (b0 == (256 | 14)) + pt1->data.ForceBold = args[0].ival; + + if (b0 == (256 | 17)) + pt1->data.LanguageGroup = args[0].ival; + + if (b0 == (256 | 18)) + pt1->data.ExpansionFactor = args[0].fval; + + n = 0; + } + + else + { + if (b0 == 30) + { + p = gslt_read_cff_real(p, e, &args[n].fval); + if (!p) + return gs_throw(-1, "corrupt dictionary operand"); + args[n].ival = (int) args[n].fval; + n++; + } + else if (b0 == 28 || b0 == 29 || (b0 >= 32 && b0 <= 254)) + { + p = gslt_read_cff_integer(p, e, b0, &args[n].ival); + if (!p) + return gs_throw(-1, "corrupt dictionary operand"); + args[n].fval = (float) args[n].ival; + n++; + } + else + { + return gs_throw1(-1, "corrupt dictionary operand (b0 = %d)", b0); + } + } } /* recurse for the private dictionary */ if (privatelen) { - int code = gslt_read_cff_dict( - fontobj->cffdata + privateofs, - fontobj->cffdata + privateofs + privatelen, - fontobj, pt1); - if (code < 0) - return gs_rethrow(code, "cannot read private dictionary"); + int code = gslt_read_cff_dict( + fontobj->cffdata + privateofs, + fontobj->cffdata + privateofs + privatelen, + fontobj, pt1); + if (code < 0) + return gs_rethrow(code, "cannot read private dictionary"); } return 0; @@ -370,28 +370,28 @@ gslt_count_cff_index(byte *p, byte *e, int *countp) if (p + 3 > e) { - gs_throw(-1, "not enough data for index header"); - return 0; + gs_throw(-1, "not enough data for index header"); + return 0; } count = u16(p); p += 2; *countp = count; if (count == 0) - return p; + return p; offsize = *p++; if (offsize < 1 || offsize > 4) { - gs_throw(-1, "corrupt index header"); - return 0; + gs_throw(-1, "corrupt index header"); + return 0; } if (p + count * offsize > e) { - gs_throw(-1, "not enough data for index offset table"); - return 0; + gs_throw(-1, "not enough data for index offset table"); + return 0; } p += count * offsize; @@ -401,8 +401,8 @@ gslt_count_cff_index(byte *p, byte *e, int *countp) if (p + last > e) { - gs_throw(-1, "not enough data for index data"); - return 0; + gs_throw(-1, "not enough data for index data"); + return 0; } p += last; @@ -423,32 +423,32 @@ gslt_find_cff_index(byte *p, byte *e, int idx, byte **pp, byte **ep) if (p + 3 > e) { - gs_throw(-1, "not enough data for index header"); - return 0; + gs_throw(-1, "not enough data for index header"); + return 0; } count = u16(p); p += 2; if (count == 0) - return 0; + return 0; offsize = *p++; if (offsize < 1 || offsize > 4) { - gs_throw(-1, "corrupt index header"); - return 0; + gs_throw(-1, "corrupt index header"); + return 0; } if (p + count * offsize > e) { - gs_throw(-1, "not enough data for index offset table"); - return 0; + gs_throw(-1, "not enough data for index offset table"); + return 0; } if (idx < 0 || idx >= count) { - gs_throw(-1, "tried to access non-existing index item"); - return 0; + gs_throw(-1, "tried to access non-existing index item"); + return 0; } sofs = uofs(p + idx * offsize, offsize); @@ -461,14 +461,14 @@ gslt_find_cff_index(byte *p, byte *e, int idx, byte **pp, byte **ep) if (p + last > e) { - gs_throw(-1, "not enough data for index data"); - return 0; + gs_throw(-1, "not enough data for index data"); + return 0; } if (sofs < 0 || eofs < 0 || sofs > eofs || eofs > last) { - gs_throw(-1, "corrupt index offset table"); - return 0; + gs_throw(-1, "corrupt index offset table"); + return 0; } *pp = p + sofs; @@ -494,66 +494,66 @@ gslt_read_cff_file(gslt_font_t *fontobj, gs_font_type1 *pt1) /* CFF header */ { - int major, minor, hdrsize, offsize; + int major, minor, hdrsize, offsize; - if (p + 4 > e) - return gs_throw(-1, "not enough data for header"); + if (p + 4 > e) + return gs_throw(-1, "not enough data for header"); - major = *p++; - minor = *p++; - hdrsize = *p++; - offsize = *p++; + major = *p++; + minor = *p++; + hdrsize = *p++; + offsize = *p++; - if (major != 1 || minor != 0) - return gs_throw(-1, "not a CFF 1.0 file"); + if (major != 1 || minor != 0) + return gs_throw(-1, "not a CFF 1.0 file"); - if (p + hdrsize - 4 > e) - return gs_throw(-1, "not enough data for extended header"); + if (p + hdrsize - 4 > e) + return gs_throw(-1, "not enough data for extended header"); } /* Name INDEX */ p = gslt_count_cff_index(p, e, &count); if (!p) - return gs_throw(-1, "cannot read name index"); + return gs_throw(-1, "cannot read name index"); if (count != 1) - return gs_throw(-1, "file did not contain exactly one font"); + return gs_throw(-1, "file did not contain exactly one font"); /* Top Dict INDEX */ p = gslt_find_cff_index(p, e, 0, &dictp, &dicte); if (!p) - return gs_throw(-1, "cannot read top dict index"); + return gs_throw(-1, "cannot read top dict index"); /* String index */ p = gslt_count_cff_index(p, e, &count); if (!p) - return gs_throw(-1, "cannot read string index"); + return gs_throw(-1, "cannot read string index"); /* Global Subr INDEX */ fontobj->gsubrs = p; p = gslt_count_cff_index(p, e, &ngsubrs); if (!p) - return gs_throw(-1, "cannot read gsubr index"); + return gs_throw(-1, "cannot read gsubr index"); /* Read the top and private dictionaries */ code = gslt_read_cff_dict(dictp, dicte, fontobj, pt1); if (code < 0) - return gs_rethrow(code, "cannot read top dictionary"); + return gs_rethrow(code, "cannot read top dictionary"); /* Check the subrs index */ nsubrs = 0; if (fontobj->subrs) { - p = gslt_count_cff_index(fontobj->subrs, e, &nsubrs); - if (!p) - return gs_rethrow(-1, "cannot read subrs index"); + p = gslt_count_cff_index(fontobj->subrs, e, &nsubrs); + if (!p) + return gs_rethrow(-1, "cannot read subrs index"); } /* Check the charstrings index */ if (fontobj->charstrings) { - p = gslt_count_cff_index(fontobj->charstrings, e, &count); - if (!p) - return gs_rethrow(-1, "cannot read charstrings index"); + p = gslt_count_cff_index(fontobj->charstrings, e, &count); + if (!p) + return gs_rethrow(-1, "cannot read charstrings index"); } pt1->data.subroutineNumberBias = subrbias(nsubrs); @@ -563,7 +563,6 @@ gslt_read_cff_file(gslt_font_t *fontobj, gs_font_type1 *pt1) return 0; } - /* * */ @@ -575,7 +574,7 @@ gslt_post_callback_encode_char(gs_font *pfont, gs_char chr, gs_glyph_space_t spc int value; value = gslt_encode_font_char(xf, chr); if (value == 0) - return gs_no_glyph; + return gs_no_glyph; return value; } @@ -593,14 +592,14 @@ gslt_post_callback_glyph_name(gs_font *pf, gs_glyph glyph, gs_const_string *pstr static int gslt_post_callback_glyph_info(gs_font *font, gs_glyph glyph, - const gs_matrix *pmat, int members, gs_glyph_info_t *info) + const gs_matrix *pmat, int members, gs_glyph_info_t *info) { return -1; } static int gslt_post_callback_glyph_outline(gs_font *font, int wmode, gs_glyph glyph, - const gs_matrix *pmat, gx_path *ppath, double sbw[4]) + const gs_matrix *pmat, gx_path *ppath, double sbw[4]) { dprintf2("glyph_outline wmode=%d glyph=%d\n", wmode, glyph); return -1; @@ -637,7 +636,7 @@ gslt_post_callback_glyph_data(gs_font_type1 * pfont, gs_glyph glyph, gs_glyph_da p = gslt_find_cff_index(fontobj->charstrings, fontobj->cffend, glyph, &s, &e); if (!p) - return gs_rethrow(-1, "cannot find charstring"); + return gs_rethrow(-1, "cannot find charstring"); gs_glyph_data_from_string(pgd, s, e - s, NULL); @@ -646,7 +645,7 @@ gslt_post_callback_glyph_data(gs_font_type1 * pfont, gs_glyph glyph, gs_glyph_da static int gslt_post_callback_subr_data(gs_font_type1 * pfont, - int subr_num, bool global, gs_glyph_data_t *pgd) + int subr_num, bool global, gs_glyph_data_t *pgd) { gslt_font_t *fontobj = pfont->client_data; byte *s, *e; @@ -656,15 +655,15 @@ gslt_post_callback_subr_data(gs_font_type1 * pfont, if (global) { - p = gslt_find_cff_index(fontobj->gsubrs, fontobj->cffend, subr_num, &s, &e); - if (!p) - return gs_rethrow(-1, "cannot find gsubr"); + p = gslt_find_cff_index(fontobj->gsubrs, fontobj->cffend, subr_num, &s, &e); + if (!p) + return gs_rethrow(-1, "cannot find gsubr"); } else { - p = gslt_find_cff_index(fontobj->subrs, fontobj->cffend, subr_num, &s, &e); - if (!p) - return gs_rethrow(-1, "cannot find subr"); + p = gslt_find_cff_index(fontobj->subrs, fontobj->cffend, subr_num, &s, &e); + if (!p) + return gs_rethrow(-1, "cannot find subr"); } gs_glyph_data_from_string(pgd, s, e - s, NULL); @@ -674,7 +673,7 @@ gslt_post_callback_subr_data(gs_font_type1 * pfont, static int gslt_post_callback_seac_data(gs_font_type1 * pfont, int ccode, gs_glyph * pglyph, - gs_const_string *gstr, gs_glyph_data_t *pgd) + gs_const_string *gstr, gs_glyph_data_t *pgd) { return gs_throw(-1, "seac is deprecated in CFF fonts"); } @@ -691,7 +690,6 @@ gslt_post_callback_pop(void *callback_data, fixed *value) return gs_throw(-1, "pop not implemented");; } - static int gslt_cff_append(gs_state *pgs, gs_font_type1 *pt1, gs_glyph glyph, int donthint) { @@ -708,7 +706,7 @@ gslt_cff_append(gs_state *pgs, gs_font_type1 *pt1, gs_glyph glyph, int donthint) // get charstring data code = gslt_post_callback_glyph_data(pt1, glyph, pgd); if (code < 0) - return gs_rethrow(code, "cannot get glyph data"); + return gs_rethrow(code, "cannot get glyph data"); mtx.xx = ctm_only(pgs).xx; mtx.xy = ctm_only(pgs).xy; @@ -722,7 +720,7 @@ gslt_cff_append(gs_state *pgs, gs_font_type1 *pt1, gs_glyph glyph, int donthint) code = gs_type1_interp_init(&cxs.cis, pgis, pgs->path, NULL, NULL, donthint, 0, pt1); if (code < 0) - return gs_throw(code, "cannot init type1 interpreter"); + return gs_throw(code, "cannot init type1 interpreter"); gs_type1_set_callback_data(pcis, &cxs); @@ -734,26 +732,26 @@ gslt_cff_append(gs_state *pgs, gs_font_type1 *pt1, gs_glyph glyph, int donthint) while (1) { - code = pt1->data.interpret(pcis, pgd, &value); - switch (code) - { - case type1_result_callothersubr: /* unknown OtherSubr */ - return_error(-15); /* can't handle it */ - case type1_result_sbw: /* [h]sbw, just continue */ - type1_cis_get_metrics(pcis, cxs.sbw); - type1_cis_get_metrics(pcis, sbw); - pgd = 0; - break; - case 0: /* all done */ - default: /* code < 0, error */ - return code; - } + code = pt1->data.interpret(pcis, pgd, &value); + switch (code) + { + case type1_result_callothersubr: /* unknown OtherSubr */ + return_error(-15); /* can't handle it */ + case type1_result_sbw: /* [h]sbw, just continue */ + type1_cis_get_metrics(pcis, cxs.sbw); + type1_cis_get_metrics(pcis, sbw); + pgd = 0; + break; + case 0: /* all done */ + default: /* code < 0, error */ + return code; + } } } static int gslt_post_callback_build_char(gs_text_enum_t *ptextenum, gs_state *pgs, - gs_font *pfont, gs_char chr, gs_glyph glyph) + gs_font *pfont, gs_char chr, gs_glyph glyph) { gs_show_enum *penum = (gs_show_enum*)ptextenum; gs_font_type1 *pt1 = (gs_font_type1*)pfont; @@ -776,32 +774,32 @@ gslt_post_callback_build_char(gs_text_enum_t *ptextenum, gs_state *pgs, /* Expand the bbox when stroking */ if ( pfont->PaintType ) { - float expand = max(1.415, gs_currentmiterlimit(pgs)) * gs_currentlinewidth(pgs) / 2; - w2[2] -= expand, w2[3] -= expand; - w2[4] += expand, w2[5] += expand; + float expand = max(1.415, gs_currentmiterlimit(pgs)) * gs_currentlinewidth(pgs) / 2; + w2[2] -= expand, w2[3] -= expand; + w2[4] += expand, w2[5] += expand; } if ( (code = gs_moveto(pgs, 0.0, 0.0)) < 0 ) - return code; - + return code; + if ( (code = gs_setcachedevice(penum, pgs, w2)) < 0 ) - return code; + return code; code = gslt_cff_append(pgs, pt1, glyph, - gs_show_in_charpath(penum) != cpm_show); + gs_show_in_charpath(penum) != cpm_show); if (code < 0) - return code; + return code; code = (pfont->PaintType ? gs_stroke(pgs) : gs_fill(pgs)); if (code < 0) - return code; + return code; return 0; } int gslt_init_postscript_font(gs_memory_t *mem, - gs_font_dir *fontdir, gslt_font_t *fontobj) + gs_font_dir *fontdir, gslt_font_t *fontobj) { gs_font_type1 *pt1; int cffofs; @@ -815,23 +813,23 @@ gslt_init_postscript_font(gs_memory_t *mem, #if 0 gs_glyph_data_t; gs_type1_data_procs_t { - z1_glyph_data, z1_subr_data, z1_seac_data, z1_push, z1_pop + z1_glyph_data, z1_subr_data, z1_seac_data, z1_push, z1_pop }; gs_type1_data_s { procs; ...; - subroutineNumberBias; - gsubrNumberBias; - defaultWidthX; - nominalWidthX; + subroutineNumberBias; + gsubrNumberBias; + defaultWidthX; + nominalWidthX; } gs_font_type1 { font_base_common; data } #endif cffofs = gslt_find_sfnt_table(fontobj, "CFF ", &cfflen); if (cffofs < 0) - return gs_throw(-1, "cannot find CFF table"); + return gs_throw(-1, "cannot find CFF table"); if (cfflen < 0 || cffofs + cfflen > fontobj->length) - return gs_throw(-1, "corrupt CFF table location"); + return gs_throw(-1, "corrupt CFF table location"); fontobj->cffdata = fontobj->data + cffofs; fontobj->cffend = fontobj->data + cffofs + cfflen; @@ -842,7 +840,7 @@ gslt_init_postscript_font(gs_memory_t *mem, pt1 = (void*) gs_alloc_struct(mem, gs_font_type1, &st_gs_font_type1, "gslt_font type1"); if (!pt1) - return gs_throw(-1, "out of memory"); + return gs_throw(-1, "out of memory"); fontobj->font = (void*) pt1; @@ -891,7 +889,7 @@ gslt_init_postscript_font(gs_memory_t *mem, pt1->procs.make_font = gs_no_make_font; pt1->procs.font_info = gs_default_font_info; // same_font - pt1->procs.encode_char = gslt_post_callback_encode_char; + pt1->procs.encode_char = gslt_post_callback_encode_char; pt1->procs.decode_glyph = gslt_post_callback_decode_glyph; // enumerate_glyph pt1->procs.glyph_info = gslt_post_callback_glyph_info;; @@ -960,12 +958,11 @@ gslt_init_postscript_font(gs_memory_t *mem, code = gslt_read_cff_file(fontobj, pt1); if (code < 0) { - // TODO free pt1 here? - return gs_rethrow(code, "cannot read cff file structure"); + // TODO free pt1 here? + return gs_rethrow(code, "cannot read cff file structure"); } gs_definefont(fontdir, fontobj->font); return 0; } - diff --git a/tools/gslite/gslt_font_encoding.c b/tools/gslite/gslt_font_encoding.c index fc0eb47af..122e97f21 100644 --- a/tools/gslite/gslt_font_encoding.c +++ b/tools/gslite/gslt_font_encoding.c @@ -69,7 +69,7 @@ gslt_identify_font_encoding(gslt_font_t *xf, int idx, int *pid, int *eid) byte *cmapdata, *entry; if (idx < 0 || idx >= xf->cmapsubcount) return -1; - cmapdata = xf->data + xf->cmaptable; + cmapdata = xf->data + xf->cmaptable; entry = cmapdata + 4 + idx * 8; *pid = u16(entry + 0); *eid = u16(entry + 2); @@ -165,34 +165,34 @@ gslt_encode_font_char_int(gslt_font_t *xf, int code) } case 10: /* Trimmed array (like 6) */ - { - int startCharCode = u32(table + 12); - int numChars = u32(table + 16); - if ( code < startCharCode || code >= startCharCode + numChars ) - return 0; - return u32(table + 20 + (code - startCharCode) * 4); - } + { + int startCharCode = u32(table + 12); + int numChars = u32(table + 16); + if ( code < startCharCode || code >= startCharCode + numChars ) + return 0; + return u32(table + 20 + (code - startCharCode) * 4); + } case 12: /* Segmented coverage. (like 4) */ - { - int nGroups = u32(table + 12); - byte *group = table + 16; - int i; - - for (i = 0; i < nGroups; i++) - { - int startCharCode = u32(group + 0); - int endCharCode = u32(group + 4); - int startGlyphID = u32(group + 8); - if ( code < startCharCode ) - return 0; - if ( code <= endCharCode ) - return startGlyphID + (code - startCharCode); - group += 12; - } - - return 0; - } + { + int nGroups = u32(table + 12); + byte *group = table + 16; + int i; + + for (i = 0; i < nGroups; i++) + { + int startCharCode = u32(group + 0); + int endCharCode = u32(group + 4); + int startGlyphID = u32(group + 8); + if ( code < startCharCode ) + return 0; + if ( code <= endCharCode ) + return startGlyphID + (code - startCharCode); + group += 12; + } + + return 0; + } case 2: /* High-byte mapping through table. */ case 8: /* Mixed 16-bit and 32-bit coverage (like 2) */ @@ -209,7 +209,6 @@ gslt_encode_font_char(gslt_font_t *xf, int code) { int gid = gslt_encode_font_char_int(xf, code); if (gid == 0 && xf->usepua) - gid = gslt_encode_font_char_int(xf, 0xF000 | code); + gid = gslt_encode_font_char_int(xf, 0xF000 | code); return gid; } - diff --git a/tools/gslite/gslt_font_glyph.c b/tools/gslite/gslt_font_glyph.c index f4f809edd..8aa61a42e 100644 --- a/tools/gslite/gslt_font_glyph.c +++ b/tools/gslite/gslt_font_glyph.c @@ -78,14 +78,14 @@ gslt_render_font_glyph(gs_state *pgs, gslt_font_t *xf, gs_matrix *tm, int gid, g params.data.d_glyph = gid; params.size = 1; - gs_moveto(pgs, 100.0, 100.0); // why? + gs_moveto(pgs, 100.0, 100.0); // why? code = gs_text_begin(pgs, ¶ms, xf->font->memory, &textenum); - if (code != 0) + if (code != 0) return gs_throw1(-1, "cannot gs_text_begin() (%d)", code); code = gs_text_process(textenum); - if (code != 0) + if (code != 0) return gs_throw1(-1, "cannot gs_text_process() (%d)", code); gs_text_release(textenum, "gslt font render"); @@ -230,24 +230,24 @@ gslt_measure_font_glyph(gs_state *pgs, gslt_font_t *xf, int gid, gslt_glyph_metr ofs = gslt_find_sfnt_table(xf, "hhea", &len); if (ofs < 0) - return gs_throw(-1, "cannot find hhea table"); + return gs_throw(-1, "cannot find hhea table"); if (len < 2 * 18) - return gs_throw(-1, "hhea table is too short"); + return gs_throw(-1, "hhea table is too short"); vorg = s16(xf->data + ofs + 4); /* ascender is default vorg */ desc = s16(xf->data + ofs + 6); /* descender */ if (desc < 0) - desc = -desc; + desc = -desc; n = u16(xf->data + ofs + 17 * 2); ofs = gslt_find_sfnt_table(xf, "hmtx", &len); if (ofs < 0) - return gs_throw(-1, "cannot find hmtx table"); + return gs_throw(-1, "cannot find hmtx table"); idx = gid; if (idx > n - 1) - idx = n - 1; + idx = n - 1; hadv = u16(xf->data + ofs + idx * 4); vadv = 0; @@ -259,71 +259,71 @@ gslt_measure_font_glyph(gs_state *pgs, gslt_font_t *xf, int gid, gslt_glyph_metr head = gslt_find_sfnt_table(xf, "head", &len); if (head > 0) { - scale = u16(xf->data + head + 18); /* units per em */ + scale = u16(xf->data + head + 18); /* units per em */ } ofs = gslt_find_sfnt_table(xf, "OS/2", &len); if (ofs > 0 && len > 70) { - vorg = s16(xf->data + ofs + 68); /* sTypoAscender */ - desc = s16(xf->data + ofs + 70); /* sTypoDescender */ - if (desc < 0) - desc = -desc; + vorg = s16(xf->data + ofs + 68); /* sTypoAscender */ + desc = s16(xf->data + ofs + 70); /* sTypoDescender */ + if (desc < 0) + desc = -desc; } ofs = gslt_find_sfnt_table(xf, "vhea", &len); if (ofs > 0) { - if (len < 2 * 18) - return gs_throw(-1, "vhea table is too short"); + if (len < 2 * 18) + return gs_throw(-1, "vhea table is too short"); - n = u16(xf->data + ofs + 17 * 2); + n = u16(xf->data + ofs + 17 * 2); - ofs = gslt_find_sfnt_table(xf, "vmtx", &len); - if (ofs < 0) - return gs_throw(-1, "cannot find vmtx table"); + ofs = gslt_find_sfnt_table(xf, "vmtx", &len); + if (ofs < 0) + return gs_throw(-1, "cannot find vmtx table"); - idx = gid; - if (idx > n - 1) - idx = n - 1; + idx = gid; + if (idx > n - 1) + idx = n - 1; - vadv = u16(xf->data + ofs + idx * 4); - vtop = u16(xf->data + ofs + idx * 4 + 2); + vadv = u16(xf->data + ofs + idx * 4); + vtop = u16(xf->data + ofs + idx * 4 + 2); - glyf = gslt_find_sfnt_table(xf, "glyf", &len); - loca = gslt_find_sfnt_table(xf, "loca", &len); - if (head > 0 && glyf > 0 && loca > 0) - { - format = u16(xf->data + head + 50); /* indexToLocaFormat */ + glyf = gslt_find_sfnt_table(xf, "glyf", &len); + loca = gslt_find_sfnt_table(xf, "loca", &len); + if (head > 0 && glyf > 0 && loca > 0) + { + format = u16(xf->data + head + 50); /* indexToLocaFormat */ - if (format == 0) - ofs = u16(xf->data + loca + gid * 2) * 2; - else - ofs = u32(xf->data + loca + gid * 4); + if (format == 0) + ofs = u16(xf->data + loca + gid * 2) * 2; + else + ofs = u32(xf->data + loca + gid * 4); - ymax = u16(xf->data + glyf + ofs + 8); /* yMax */ + ymax = u16(xf->data + glyf + ofs + 8); /* yMax */ - vorg = ymax + vtop; - } + vorg = ymax + vtop; + } } ofs = gslt_find_sfnt_table(xf, "VORG", &len); if (ofs > 0) { - vorg = u16(xf->data + ofs + 6); - n = u16(xf->data + ofs + 6); - for (i = 0; i < n; i++) - { - if (u16(xf->data + ofs + 8 + 4 * i) == gid) - { - vorg = s16(xf->data + ofs + 8 + 4 * i + 2); - break; - } - } + vorg = u16(xf->data + ofs + 6); + n = u16(xf->data + ofs + 6); + for (i = 0; i < n; i++) + { + if (u16(xf->data + ofs + 8 + 4 * i) == gid) + { + vorg = s16(xf->data + ofs + 8 + 4 * i + 2); + break; + } + } } if (vadv == 0) - vadv = vorg + desc; + vadv = vorg + desc; mtx->hadv = hadv / (float) scale; mtx->vadv = vadv / (float) scale; @@ -331,4 +331,3 @@ gslt_measure_font_glyph(gs_state *pgs, gslt_font_t *xf, int gid, gslt_glyph_metr return 0; } - diff --git a/tools/gslite/gslt_font_int.h b/tools/gslite/gslt_font_int.h index 3fe0001ba..88a61688e 100644 --- a/tools/gslite/gslt_font_int.h +++ b/tools/gslite/gslt_font_int.h @@ -104,4 +104,3 @@ static inline int u32(byte *p) { return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; } - diff --git a/tools/gslite/gslt_font_test.c b/tools/gslite/gslt_font_test.c index 44fa42352..9f7611542 100644 --- a/tools/gslite/gslt_font_test.c +++ b/tools/gslite/gslt_font_test.c @@ -35,22 +35,22 @@ int readfile(char *filename, char **datap, int *lengthp) fp = fopen(filename, "rb"); if (!fp) { printf("cannot open font file\n"); - return 1; + return 1; } t = fseek(fp, 0, 2); if (t < 0) { fclose(fp); - printf("cannot seek in font file\n"); - return 1; + printf("cannot seek in font file\n"); + return 1; } n = ftell(fp); if (n < 0) { fclose(fp); - printf("cannot tell in font file\n"); - return 1; + printf("cannot tell in font file\n"); + return 1; } t = fseek(fp, 0, 0); @@ -58,15 +58,15 @@ int readfile(char *filename, char **datap, int *lengthp) { fclose(fp); printf("cannot seek in font file\n"); - return 1; + return 1; } p = malloc(n); if (!p) { fclose(fp); - printf("out of memory\n"); - return 1; + printf("out of memory\n"); + return 1; } t = fread(p, 1, n, fp); @@ -74,8 +74,8 @@ int readfile(char *filename, char **datap, int *lengthp) { free(p); fclose(fp); - printf("cannot read font file data\n"); - return 1; + printf("cannot read font file data\n"); + return 1; } t = fclose(fp); @@ -158,8 +158,8 @@ main(int argc, const char *argv[]) if (argc < 2) { filename = "/Users/tor/src/work/gslite/TrajanPro-Regular.otf"; - // filename = "/Users/tor/src/work/gslite/GenR102.TTF"; - // return gs_throw(1, "usage: gslt_font_api_test font.otf [subfontid]"); + // filename = "/Users/tor/src/work/gslite/GenR102.TTF"; + // return gs_throw(1, "usage: gslt_font_api_test font.otf [subfontid]"); } else { @@ -168,14 +168,14 @@ main(int argc, const char *argv[]) subfontid = 0; if (argc == 3) - subfontid = atoi(argv[2]); + subfontid = atoi(argv[2]); printf("Loading font '%s' subfont %d.\n", filename, subfontid); n = readfile(filename, &buf, &len); if (n < 0) { printf("cannot read font file '%s'", filename); - return 1; + return 1; } /* @@ -185,7 +185,6 @@ main(int argc, const char *argv[]) // gslt_get_device_param(mem, dev, "Name"); gslt_set_device_param(mem, dev, "OutputFile", "-"); - /* * Create a font cache */ @@ -193,7 +192,7 @@ main(int argc, const char *argv[]) cache = gslt_new_font_cache(mem); if (!cache) { printf("cannot create font cache\n"); - return 1; + return 1; } /* @@ -203,33 +202,33 @@ main(int argc, const char *argv[]) font = gslt_new_font(mem, cache, buf, len, subfontid); if (!font) { printf("cannot create font"); - return 1; + return 1; } static struct { int pid, eid; } xps_cmap_list[] = { - { 3, 10 }, /* Unicode with surrogates */ - { 3, 1 }, /* Unicode without surrogates */ - { 3, 5 }, /* Wansung */ - { 3, 4 }, /* Big5 */ - { 3, 3 }, /* Prc */ - { 3, 2 }, /* ShiftJis */ - { 3, 0 }, /* Symbol */ - // { 0, * }, -- Unicode (deprecated) - { 1, 0 }, - { -1, -1 }, + { 3, 10 }, /* Unicode with surrogates */ + { 3, 1 }, /* Unicode without surrogates */ + { 3, 5 }, /* Wansung */ + { 3, 4 }, /* Big5 */ + { 3, 3 }, /* Prc */ + { 3, 2 }, /* ShiftJis */ + { 3, 0 }, /* Symbol */ + // { 0, * }, -- Unicode (deprecated) + { 1, 0 }, + { -1, -1 }, }; n = gslt_count_font_encodings(font); best = -1; for (k = 0; xps_cmap_list[k].pid != -1; k++) { - for (i = 0; i < n; i++) - { - gslt_identify_font_encoding(font, i, &pid, &eid); - if (pid == xps_cmap_list[k].pid && eid == xps_cmap_list[k].eid) - goto found_cmap; - } + for (i = 0; i < n; i++) + { + gslt_identify_font_encoding(font, i, &pid, &eid); + if (pid == xps_cmap_list[k].pid && eid == xps_cmap_list[k].eid) + goto found_cmap; + } } gs_throw(-1, "could not find a suitable cmap"); return 1; @@ -257,7 +256,7 @@ found_cmap: /* * Test bitmap rendering. */ - + printf("getting bitmaps\n"); text = "Pack my box with five dozen liquor jugs!"; @@ -274,10 +273,10 @@ text = "This"; { int gid = gslt_encode_font_char(font, *s); - if (s == text) - gid = 2119; + if (s == text) + gid = 2119; - printf("char '%c' -> glyph %d\n", *s, gid); + printf("char '%c' -> glyph %d\n", *s, gid); code = gslt_measure_font_glyph(pgs, font, gid, &mtx); if (code < 0) @@ -291,14 +290,14 @@ text = "This"; if (code < 0) { printf("error in gslt_render_font_glyph\n"); - return 1; + return 1; } printf(" -> %dx%d+(%d,%d)\n", slot.w, slot.h, slot.lsb, slot.top); - gslt_release_font_glyph(mem, &slot); + gslt_release_font_glyph(mem, &slot); } /* @@ -316,4 +315,3 @@ text = "This"; return 0; } - diff --git a/tools/gslite/gslt_font_ttf.c b/tools/gslite/gslt_font_ttf.c index f3a5b9ab9..ad60424db 100644 --- a/tools/gslite/gslt_font_ttf.c +++ b/tools/gslite/gslt_font_ttf.c @@ -79,7 +79,7 @@ gslt_true_callback_build_char(gs_text_enum_t *ptextenum, gs_state *pgs, gs_font w2[3] = pbbox->p.y; w2[4] = pbbox->q.x; w2[5] = pbbox->q.y; - + dprintf6(" bbox (%g %g) %g %g %g %g\n", w2[0], w2[1], w2[2], w2[3], w2[4], w2[5]); /* Expand the bbox when stroking */ @@ -97,9 +97,9 @@ gslt_true_callback_build_char(gs_text_enum_t *ptextenum, gs_state *pgs, gs_font return code; code = gs_type42_append(glyph, pgs, - gx_current_path(pgs), - ptextenum, (gs_font*)p42, - gs_show_in_charpath(penum) != cpm_show); + gx_current_path(pgs), + ptextenum, (gs_font*)p42, + gs_show_in_charpath(penum) != cpm_show); if (code < 0) return code; @@ -193,4 +193,3 @@ gslt_init_truetype_font(gs_memory_t *mem, gs_font_dir *fontdir, gslt_font_t *xf) return 0; } - diff --git a/tools/gslite/gslt_image.c b/tools/gslite/gslt_image.c index 09f463f76..7dab2097c 100644 --- a/tools/gslite/gslt_image.c +++ b/tools/gslite/gslt_image.c @@ -40,12 +40,11 @@ /* define the gslt_image_t structure descriptor */ public_st_gslt_image(); - /* * Strip alpha channel from an image * assumes a collapsed stride */ -static void +static void gslt_strip_alpha(gslt_image_t *image) { gslt_image_colorspace cs = image->colorspace; @@ -109,9 +108,9 @@ void gslt_image_free(gs_memory_t *mem, gslt_image_t *image) { if (image != NULL) { - if (image->samples) { - gs_free_object(mem, image->samples, "free gslt_image samples"); - } - gs_free_object(mem, image, "free gslt_image"); + if (image->samples) { + gs_free_object(mem, image->samples, "free gslt_image samples"); + } + gs_free_object(mem, image, "free gslt_image"); } } diff --git a/tools/gslite/gslt_image.h b/tools/gslite/gslt_image.h index bdafb9a45..89087e8cf 100644 --- a/tools/gslite/gslt_image.h +++ b/tools/gslite/gslt_image.h @@ -26,10 +26,10 @@ typedef enum { GSLT_GRAY_A, GSLT_RGB, GSLT_RGB_A, - GSLT_CMYK, + GSLT_CMYK, GSLT_CMYK_A, GSLT_UNDEFINED /* sentinel for the last defined colorspace */ -} gslt_image_colorspace; +} gslt_image_colorspace; /* definition of the image object structure */ struct gslt_image_s { @@ -50,7 +50,6 @@ gslt_image_t *gslt_image_decode(gs_memory_t *mem, byte *buf, int len); /* free an image object when it is no longer needed */ void gslt_image_free(gs_memory_t *mem, gslt_image_t *image); - /* decode a memory buffer as a particular image format */ gslt_image_t *gslt_image_decode_jpeg(gs_memory_t *mem, byte *buf, int len); gslt_image_t *gslt_image_decode_png( gs_memory_t *mem, byte *buf, int len); diff --git a/tools/gslite/gslt_image_jpeg.c b/tools/gslite/gslt_image_jpeg.c index ebc6b4957..d7ea4261f 100644 --- a/tools/gslite/gslt_image_jpeg.c +++ b/tools/gslite/gslt_image_jpeg.c @@ -60,7 +60,7 @@ gslt_image_decode_jpeg(gs_memory_t *mem, byte *buf, int len) if ((code = gs_jpeg_create_decompress(&state)) < 0) { error = gs_throw(-1, "cannot gs_jpeg_create_decompress"); - return NULL; + return NULL; } s_DCTD_template.init((stream_state*)&state); @@ -74,16 +74,16 @@ gslt_image_decode_jpeg(gs_memory_t *mem, byte *buf, int len) code = s_DCTD_template.process((stream_state*)&state, &rp, &wp, true); if (code != 1) { - error = gs_throw(-1, "premature EOF or error in jpeg"); - return NULL; + error = gs_throw(-1, "premature EOF or error in jpeg"); + return NULL; } image = gs_alloc_struct_immovable(mem, gslt_image_t, - &st_gslt_image, "jpeg gslt_image"); + &st_gslt_image, "jpeg gslt_image"); if (image == NULL) { - error = gs_throw(-1, "unable to allocate jpeg gslt_image"); - gs_jpeg_destroy(&state); - return NULL; + error = gs_throw(-1, "unable to allocate jpeg gslt_image"); + gs_jpeg_destroy(&state); + return NULL; } image->width = jddp.dinfo.output_width; @@ -119,9 +119,9 @@ gslt_image_decode_jpeg(gs_memory_t *mem, byte *buf, int len) wbuf = gs_alloc_bytes(mem, wlen, "decodejpeg"); if (!wbuf) { error = gs_throw1(-1, "out of memory allocating samples: %d", wlen); - gs_free_object(mem, image, "free jpeg gslt_image"); - gs_jpeg_destroy(&state); - return NULL; + gs_free_object(mem, image, "free jpeg gslt_image"); + gs_jpeg_destroy(&state); + return NULL; } image->samples = wbuf; @@ -132,9 +132,9 @@ gslt_image_decode_jpeg(gs_memory_t *mem, byte *buf, int len) if (code != EOFC) { error = gs_throw1(-1, "error in jpeg (code = %d)", code); #ifndef DEBUG /* return whatever we got when debugging */ - gs_free_object(mem, image, "free jpeg gslt_image"); - gs_jpeg_destroy(&state); - return NULL; + gs_free_object(mem, image, "free jpeg gslt_image"); + gs_jpeg_destroy(&state); + return NULL; #endif } diff --git a/tools/gslite/gslt_image_png.c b/tools/gslite/gslt_image_png.c index b46eab8ca..dad09af81 100644 --- a/tools/gslite/gslt_image_png.c +++ b/tools/gslite/gslt_image_png.c @@ -79,14 +79,14 @@ gslt_image_decode_png(gs_memory_t *mem, byte *buf, int len) NULL, NULL, NULL, /* error callbacks */ mem, gslt_png_malloc, gslt_png_free); if (!png) { - gs_throw(-1, "png_create_read_struct_2 failed"); - return NULL; + gs_throw(-1, "png_create_read_struct_2 failed"); + return NULL; } info = png_create_info_struct(png); if (!info) { gs_throw(-1, "png_create_info_struct"); - png_destroy_read_struct(&png, NULL, NULL); - return NULL; + png_destroy_read_struct(&png, NULL, NULL); + return NULL; } png_set_read_fn(png, &io, gslt_png_read); @@ -98,7 +98,7 @@ gslt_image_decode_png(gs_memory_t *mem, byte *buf, int len) { png_destroy_read_struct(&png, &info, NULL); gs_throw(-1, "png reading failed"); - return NULL; + return NULL; } /* @@ -108,11 +108,11 @@ gslt_image_decode_png(gs_memory_t *mem, byte *buf, int len) png_read_info(png, info); image = gs_alloc_struct_immovable(mem, gslt_image_t, - &st_gslt_image, "new png gslt_image"); + &st_gslt_image, "new png gslt_image"); if (image == NULL) { - gs_throw(-1, "unable to allocate png gslt_image"); - png_destroy_read_struct(&png, &info, NULL); - return NULL; + gs_throw(-1, "unable to allocate png gslt_image"); + png_destroy_read_struct(&png, &info, NULL); + return NULL; } image->width = png_get_image_width(png, info); @@ -176,9 +176,9 @@ gslt_image_decode_png(gs_memory_t *mem, byte *buf, int len) default: gs_throw(-1, "cannot handle this png color type"); - png_destroy_read_struct(&png, &info, NULL); - gs_free_object(mem, image, "free png gslt_image"); - return NULL; + png_destroy_read_struct(&png, &info, NULL); + gs_free_object(mem, image, "free png gslt_image"); + return NULL; } image->stride = (image->width * image->components * image->bits + 7) / 8; diff --git a/tools/gslite/gslt_image_test.c b/tools/gslite/gslt_image_test.c index bdae1393b..2efe91051 100644 --- a/tools/gslite/gslt_image_test.c +++ b/tools/gslite/gslt_image_test.c @@ -39,8 +39,8 @@ decode_image_file(gs_memory_t *mem, FILE *in) bytes = fread(buf, 1, len, in); if (bytes != len) { - free(buf); - return NULL; + free(buf); + return NULL; } image = gslt_image_decode(mem, buf, len); @@ -68,46 +68,46 @@ decode_image_filename(gs_memory_t *mem, const char *filename) int write_image_file(gslt_image_t *image, FILE *out) { - byte *row; + byte *row; int j, bytes; if (image == NULL || image->samples == NULL) { - fprintf(stderr, "ignoring empty image object\n"); - return -1; + fprintf(stderr, "ignoring empty image object\n"); + return -1; } if (image->components == 1 && image->bits == 1) { - /* PBM file */ - int i; - int rowbytes = (image->width+7)>>3; - byte *local = malloc(rowbytes); - - fprintf(out, "P4\n%d %d\n", image->width, image->height); - row = image->samples; - for (j = 0; j < image->height; j++) { - /* PBM images are inverted relative to our XPS/PS convention */ - for (i = 0; i < rowbytes; i++) - local[i] = row[i] ^ 0xFF; - bytes = fwrite(local, 1, rowbytes, out); - row += image->stride; - } - free(local); + /* PBM file */ + int i; + int rowbytes = (image->width+7)>>3; + byte *local = malloc(rowbytes); + + fprintf(out, "P4\n%d %d\n", image->width, image->height); + row = image->samples; + for (j = 0; j < image->height; j++) { + /* PBM images are inverted relative to our XPS/PS convention */ + for (i = 0; i < rowbytes; i++) + local[i] = row[i] ^ 0xFF; + bytes = fwrite(local, 1, rowbytes, out); + row += image->stride; + } + free(local); } else if (image->components == 1 && image->bits == 8) { - /* PGM file */ - fprintf(out, "P5\n%d %d\n255\n", image->width, image->height); - row = image->samples; - for (j = 0; j < image->height; j++) { - bytes = fwrite(row, 1, image->width, out); - row += image->stride; - } + /* PGM file */ + fprintf(out, "P5\n%d %d\n255\n", image->width, image->height); + row = image->samples; + for (j = 0; j < image->height; j++) { + bytes = fwrite(row, 1, image->width, out); + row += image->stride; + } } else { - /* PPM file */ - fprintf(out, "P6\n%d %d\n255\n", image->width, image->height); - row = image->samples; - for (j = 0; j < image->height; j++) { - bytes = fwrite(row, image->components, image->width, out); - row += image->stride; - } + /* PPM file */ + fprintf(out, "P6\n%d %d\n255\n", image->width, image->height); + row = image->samples; + for (j = 0; j < image->height; j++) { + bytes = fwrite(row, image->components, image->width, out); + row += image->stride; + } } return 0; @@ -121,8 +121,8 @@ write_image_filename(gslt_image_t *image, const char *filename) out = fopen(filename, "wb"); if (out == NULL) { - fprintf(stderr, "could not open '%s' for writing\n", filename); - return -1; + fprintf(stderr, "could not open '%s' for writing\n", filename); + return -1; } error = write_image_file(image, out); @@ -161,8 +161,8 @@ main(int argc, const char *argv[]) /* load and decode the image */ image = decode_image_filename(mem, argv[argc-1]); if (image == NULL) { - fprintf(stderr, "reading image failed.\n"); - code = -1; + fprintf(stderr, "reading image failed.\n"); + code = -1; } /* save an uncompressed copy for verification */ write_image_filename(image, "out.pnm"); @@ -178,4 +178,3 @@ main(int argc, const char *argv[]) gslt_free_library(mem); return code; } - diff --git a/tools/gslite/gslt_image_threads_test.c b/tools/gslite/gslt_image_threads_test.c index 0cdab1d2f..431dba6c2 100644 --- a/tools/gslite/gslt_image_threads_test.c +++ b/tools/gslite/gslt_image_threads_test.c @@ -44,8 +44,8 @@ decode_image_file(gs_memory_t *mem, FILE *in) bytes = fread(buf, 1, len, in); if (bytes != len) { - free(buf); - return NULL; + free(buf); + return NULL; } image = gslt_image_decode(mem, buf, len); @@ -73,46 +73,46 @@ decode_image_filename(gs_memory_t *mem, const char *filename) int write_image_file(gslt_image_t *image, FILE *out) { - byte *row; + byte *row; int j, bytes; if (image == NULL || image->samples == NULL) { - fprintf(stderr, "ignoring empty image object\n"); - return -1; + fprintf(stderr, "ignoring empty image object\n"); + return -1; } if (image->components == 1 && image->bits == 1) { - /* PBM file */ - int i; - int rowbytes = (image->width+7)>>3; - byte *local = malloc(rowbytes); - - fprintf(out, "P4\n%d %d\n", image->width, image->height); - row = image->samples; - for (j = 0; j < image->height; j++) { - /* PBM images are inverted relative to our XPS/PS convention */ - for (i = 0; i < rowbytes; i++) - local[i] = row[i] ^ 0xFF; - bytes = fwrite(local, 1, rowbytes, out); - row += image->stride; - } - free(local); + /* PBM file */ + int i; + int rowbytes = (image->width+7)>>3; + byte *local = malloc(rowbytes); + + fprintf(out, "P4\n%d %d\n", image->width, image->height); + row = image->samples; + for (j = 0; j < image->height; j++) { + /* PBM images are inverted relative to our XPS/PS convention */ + for (i = 0; i < rowbytes; i++) + local[i] = row[i] ^ 0xFF; + bytes = fwrite(local, 1, rowbytes, out); + row += image->stride; + } + free(local); } else if (image->components == 1 && image->bits == 8) { - /* PGM file */ - fprintf(out, "P5\n%d %d\n255\n", image->width, image->height); - row = image->samples; - for (j = 0; j < image->height; j++) { - bytes = fwrite(row, 1, image->width, out); - row += image->stride; - } + /* PGM file */ + fprintf(out, "P5\n%d %d\n255\n", image->width, image->height); + row = image->samples; + for (j = 0; j < image->height; j++) { + bytes = fwrite(row, 1, image->width, out); + row += image->stride; + } } else { - /* PPM file */ - fprintf(out, "P6\n%d %d\n255\n", image->width, image->height); - row = image->samples; - for (j = 0; j < image->height; j++) { - bytes = fwrite(row, image->components, image->width, out); - row += image->stride; - } + /* PPM file */ + fprintf(out, "P6\n%d %d\n255\n", image->width, image->height); + row = image->samples; + for (j = 0; j < image->height; j++) { + bytes = fwrite(row, image->components, image->width, out); + row += image->stride; + } } return 0; @@ -126,8 +126,8 @@ write_image_filename(gslt_image_t *image, const char *filename) out = fopen(filename, "wb"); if (out == NULL) { - fprintf(stderr, "could not open '%s' for writing\n", filename); - return -1; + fprintf(stderr, "could not open '%s' for writing\n", filename); + return -1; } error = write_image_file(image, out); @@ -166,12 +166,11 @@ print_image(void *threadid) gs_erasepage(gs); gs_moveto(gs, 72.0, 72.0); - /* load and decode the image */ image = decode_image_filename(mem, filename); if (image == NULL) { - fprintf(stderr, "reading image failed.\n"); - code = -1; + fprintf(stderr, "reading image failed.\n"); + code = -1; } /* save an uncompressed copy for verification */ { @@ -188,7 +187,7 @@ print_image(void *threadid) /* output the page (unused) */ gs_output_page(gs, 1, 1); - + /* clean up the library */ gslt_free_state(mem, gs); gslt_free_device(mem, dev); @@ -208,7 +207,7 @@ main(int argc, const char *argv[]) filename = argv[argc-1]; fprintf(stderr, "loading '%s'\n", filename); - + if ( ((ret=pthread_create(&thread1, NULL, print_image, (void *)t1)) != 0) || ((ret=pthread_create(&thread2, NULL, print_image, (void *)t2)) != 0) ) { fprintf(stderr, "Error creating thread code=%d", ret); @@ -216,4 +215,3 @@ main(int argc, const char *argv[]) } pthread_exit(NULL); } - diff --git a/tools/gslite/gslt_image_tiff.c b/tools/gslite/gslt_image_tiff.c index 51419d5c2..7f6775baf 100644 --- a/tools/gslite/gslt_image_tiff.c +++ b/tools/gslite/gslt_image_tiff.c @@ -686,31 +686,31 @@ gslt_decode_tiff_strips(gs_memory_t *mem, gslt_tiff_t *tiff, gslt_image_t *image switch (tiff->compression) { case 1: - error = gslt_decode_tiff_uncompressed(mem, tiff, rp, rp + rlen, wp, wp + wlen); + error = gslt_decode_tiff_uncompressed(mem, tiff, rp, rp + rlen, wp, wp + wlen); break; case 2: - error = gslt_decode_tiff_fax(mem, tiff, 2, rp, rp + rlen, wp, wp + wlen); + error = gslt_decode_tiff_fax(mem, tiff, 2, rp, rp + rlen, wp, wp + wlen); break; case 3: - error = gslt_decode_tiff_fax(mem, tiff, 3, rp, rp + rlen, wp, wp + wlen); + error = gslt_decode_tiff_fax(mem, tiff, 3, rp, rp + rlen, wp, wp + wlen); break; case 4: - error = gslt_decode_tiff_fax(mem, tiff, 4, rp, rp + rlen, wp, wp + wlen); + error = gslt_decode_tiff_fax(mem, tiff, 4, rp, rp + rlen, wp, wp + wlen); break; case 5: - error = gslt_decode_tiff_lzw(mem, tiff, rp, rp + rlen, wp, wp + wlen); + error = gslt_decode_tiff_lzw(mem, tiff, rp, rp + rlen, wp, wp + wlen); break; case 6: - error = gs_throw(-1, "deprecated JPEG in TIFF compression not supported"); + error = gs_throw(-1, "deprecated JPEG in TIFF compression not supported"); break; case 7: - error = gslt_decode_tiff_jpeg(mem, tiff, rp, rp + rlen, wp, wp + wlen); + error = gslt_decode_tiff_jpeg(mem, tiff, rp, rp + rlen, wp, wp + wlen); break; case 8: - error = gslt_decode_tiff_flate(mem, tiff, rp, rp + rlen, wp, wp + wlen); + error = gslt_decode_tiff_flate(mem, tiff, rp, rp + rlen, wp, wp + wlen); break; case 32773: - error = gslt_decode_tiff_packbits(mem, tiff, rp, rp + rlen, wp, wp + wlen); + error = gslt_decode_tiff_packbits(mem, tiff, rp, rp + rlen, wp, wp + wlen); break; default: error = gs_throw1(-1, "unknown TIFF compression: %d", tiff->compression); @@ -797,7 +797,7 @@ gslt_read_tiff_tag_value(unsigned *p, gslt_tiff_t *tiff, unsigned type, unsigned } } -static int +static int gslt_read_tiff_tag(gs_memory_t *mem, gslt_tiff_t *tiff, unsigned offset) { unsigned tag; @@ -981,8 +981,8 @@ gslt_image_decode_tiff(gs_memory_t *mem, byte *buf, int len) error = gslt_read_tiff_tag(mem, tiff, offset); if (error) { error = gs_rethrow(error, "could not read TIFF header tag"); - return NULL; - } + return NULL; + } offset += 12; } #ifdef GSLT_DEBUG_TIFF @@ -990,17 +990,17 @@ gslt_image_decode_tiff(gs_memory_t *mem, byte *buf, int len) #endif /* new image */ image = gs_alloc_struct_immovable(mem, gslt_image_t, - &st_gslt_image, "new tiff gslt_image"); + &st_gslt_image, "new tiff gslt_image"); if (image == NULL) { - error = gs_throw(-1, "unable to allocate tiff gslt_image"); - return NULL; + error = gs_throw(-1, "unable to allocate tiff gslt_image"); + return NULL; } image->samples = gs_alloc_bytes(mem, image->stride * image->height, - "decoded tiff data"); + "decoded tiff data"); if (image->samples == NULL) { - error = gs_throw(-1, "unable to allocate tiff gslt_image pixel data"); - gs_free_object(mem, image, "free tiff gslt_image"); - return NULL; + error = gs_throw(-1, "unable to allocate tiff gslt_image pixel data"); + gs_free_object(mem, image, "free tiff gslt_image"); + return NULL; } /* @@ -1012,8 +1012,8 @@ gslt_image_decode_tiff(gs_memory_t *mem, byte *buf, int len) error = gslt_decode_tiff_strips(mem, tiff, image); if (error) { - error = gs_rethrow(error, "could not decode image data"); - return NULL; + error = gs_rethrow(error, "could not decode image data"); + return NULL; } /* diff --git a/tools/gslite/gslt_init.c b/tools/gslite/gslt_init.c index 4d58f984c..e3003177a 100644 --- a/tools/gslite/gslt_init.c +++ b/tools/gslite/gslt_init.c @@ -1,12 +1,12 @@ /* Copyright (C) 1995, 2000 Aladdin Enterprises. All rights reserved. - + This software is provided AS-IS with no warranty, either express or implied. - + This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of the license contained in the file LICENSE in this distribution. - + For more information about licensing, please refer to http://www.ghostscript.com/licensing/. For information on commercial licensing, go to http://www.artifex.com/licensing/ or @@ -212,4 +212,3 @@ main(int argc, const char *argv[]) } #endif - diff --git a/tools/gslite/gslt_test.c b/tools/gslite/gslt_test.c index 855c08c79..aadca1e37 100644 --- a/tools/gslite/gslt_test.c +++ b/tools/gslite/gslt_test.c @@ -66,7 +66,7 @@ static int (*tests[]) (gs_state *, gs_memory_t *) = test1, test2, test3, test4, test5, test6, #ifdef HALFTONE_FIX - test7, + test7, #else 0, #endif @@ -79,7 +79,6 @@ extern_gs_lib_device_list(); /* Forward references */ static float odsf(floatp, floatp); - /* return index in gs device list -1 if not found */ static inline int get_device_index(const gs_memory_t *mem, const char *value) @@ -89,11 +88,11 @@ get_device_index(const gs_memory_t *mem, const char *value) int di; for ( di = 0; di < num_devs; ++di ) - if ( !strcmp(gs_devicename(dev_list[di]), value) ) - break; + if ( !strcmp(gs_devicename(dev_list[di]), value) ) + break; if ( di == num_devs ) { - lprintf1("Unknown device name %s.\n", value); - return -1; + lprintf1("Unknown device name %s.\n", value); + return -1; } return di; } @@ -116,10 +115,10 @@ main(int argc, const char *argv[]) gp_init(); gs_lib_init1(mem); if (argc < 3 || (achar = argv[2][0]) < '1' || - achar > '0' + countof(tests) - ) { - lprintf1("Usage: gslt [device] 1..%c\n", '0' + (char)countof(tests)); - exit(1); + achar > '0' + countof(tests) + ) { + lprintf1("Usage: gslt [device] 1..%c\n", '0' + (char)countof(tests)); + exit(1); } memset(gs_debug, 0, 128); gs_debug['@'] = 1; @@ -136,7 +135,7 @@ main(int argc, const char *argv[]) int devindex = get_device_index(mem, argv[1]); if (devindex < 0) { lprintf1("device %s not found\n", argv[1]); - exit(1); + exit(1); } gs_lib_device_list(&list, NULL); gs_copydevice(&dev, list[devindex], mem); @@ -146,60 +145,60 @@ main(int argc, const char *argv[]) gx_device_fill_in_procs(dev); /* Print out the device name just to test the gsparam.c API. */ { - gs_c_param_list list; - gs_param_string nstr; - - gs_c_param_list_write(&list, mem); - code = gs_getdeviceparams(dev, (gs_param_list *) & list); - if (code < 0) { - lprintf1("getdeviceparams failed! code = %d\n", code); - exit(1); - } - gs_c_param_list_read(&list); - code = param_read_string((gs_param_list *) & list, "Name", &nstr); - if (code < 0) { - lprintf1("reading Name failed! code = %d\n", code); - exit(1); - } - dputs("Device name = "); - debug_print_string(nstr.data, nstr.size); - dputs("\n"); - gs_c_param_list_release(&list); + gs_c_param_list list; + gs_param_string nstr; + + gs_c_param_list_write(&list, mem); + code = gs_getdeviceparams(dev, (gs_param_list *) & list); + if (code < 0) { + lprintf1("getdeviceparams failed! code = %d\n", code); + exit(1); + } + gs_c_param_list_read(&list); + code = param_read_string((gs_param_list *) & list, "Name", &nstr); + if (code < 0) { + lprintf1("reading Name failed! code = %d\n", code); + exit(1); + } + dputs("Device name = "); + debug_print_string(nstr.data, nstr.size); + dputs("\n"); + gs_c_param_list_release(&list); } /* * If this is a device that takes an OutputFile, set the OutputFile * to "-" in the copy. */ { - gs_c_param_list list; - gs_param_string nstr; - - gs_c_param_list_write(&list, mem); - param_string_from_string(nstr, "-"); - code = param_write_string((gs_param_list *)&list, "OutputFile", &nstr); - if (code < 0) { - lprintf1("writing OutputFile failed! code = %d\n", code); - exit(1); - } - gs_c_param_list_read(&list); - code = gs_putdeviceparams(dev, (gs_param_list *)&list); - gs_c_param_list_release(&list); - if (code < 0 && code != gs_error_undefined) { - lprintf1("putdeviceparams failed! code = %d\n", code); - exit(1); - } + gs_c_param_list list; + gs_param_string nstr; + + gs_c_param_list_write(&list, mem); + param_string_from_string(nstr, "-"); + code = param_write_string((gs_param_list *)&list, "OutputFile", &nstr); + if (code < 0) { + lprintf1("writing OutputFile failed! code = %d\n", code); + exit(1); + } + gs_c_param_list_read(&list); + code = gs_putdeviceparams(dev, (gs_param_list *)&list); + gs_c_param_list_release(&list); + if (code < 0 && code != gs_error_undefined) { + lprintf1("putdeviceparams failed! code = %d\n", code); + exit(1); + } } pgs = gs_state_alloc(mem); gs_setdevice_no_erase(pgs, dev); /* can't erase yet */ { - gs_point dpi; - gs_screen_halftone ht; - - gs_dtransform(pgs, 72.0, 72.0, &dpi); - ht.frequency = min(fabs(dpi.x), fabs(dpi.y)) / 16.001; - ht.angle = 0; - ht.spot_function = odsf; - gs_setscreen(pgs, &ht); + gs_point dpi; + gs_screen_halftone ht; + + gs_dtransform(pgs, 72.0, 72.0, &dpi); + ht.frequency = min(fabs(dpi.x), fabs(dpi.y)) / 16.001; + ht.angle = 0; + ht.spot_function = odsf; + gs_setscreen(pgs, &ht); } /* gsave and grestore (among other places) assume that */ /* there are at least 2 gstates on the graphics stack. */ @@ -208,7 +207,7 @@ main(int argc, const char *argv[]) gs_erasepage(pgs); if (tests[achar - '1']) { - dprintf1("gslt test case = %d\n", achar - '1'); + dprintf1("gslt test case = %d\n", achar - '1'); code = (*tests[achar - '1']) (pgs, mem); gs_output_page(pgs, 1, 1); if (code) @@ -220,7 +219,7 @@ main(int argc, const char *argv[]) } gs_lib_finit(0, 0, mem); return code; - + #undef mem } /* Ordered dither spot function */ @@ -229,22 +228,22 @@ odsf(floatp x, floatp y) { static const byte dither[256] = { - 0x0E, 0x8E, 0x2E, 0xAE, 0x06, 0x86, 0x26, 0xA6, 0x0C, 0x8C, 0x2C, 0xAC, 0x04, 0x84, 0x24, 0xA4, - 0xCE, 0x4E, 0xEE, 0x6E, 0xC6, 0x46, 0xE6, 0x66, 0xCC, 0x4C, 0xEC, 0x6C, 0xC4, 0x44, 0xE4, 0x64, - 0x3E, 0xBE, 0x1E, 0x9E, 0x36, 0xB6, 0x16, 0x96, 0x3C, 0xBC, 0x1C, 0x9C, 0x34, 0xB4, 0x14, 0x94, - 0xFE, 0x7E, 0xDE, 0x5E, 0xF6, 0x76, 0xD6, 0x56, 0xFC, 0x7C, 0xDC, 0x5C, 0xF4, 0x74, 0xD4, 0x54, - 0x01, 0x81, 0x21, 0xA1, 0x09, 0x89, 0x29, 0xA9, 0x03, 0x83, 0x23, 0xA3, 0x0B, 0x8B, 0x2B, 0xAB, - 0xC1, 0x41, 0xE1, 0x61, 0xC9, 0x49, 0xE9, 0x69, 0xC3, 0x43, 0xE3, 0x63, 0xCB, 0x4B, 0xEB, 0x6B, - 0x31, 0xB1, 0x11, 0x91, 0x39, 0xB9, 0x19, 0x99, 0x33, 0xB3, 0x13, 0x93, 0x3B, 0xBB, 0x1B, 0x9B, - 0xF1, 0x71, 0xD1, 0x51, 0xF9, 0x79, 0xD9, 0x59, 0xF3, 0x73, 0xD3, 0x53, 0xFB, 0x7B, 0xDB, 0x5B, - 0x0D, 0x8D, 0x2D, 0xAD, 0x05, 0x85, 0x25, 0xA5, 0x0F, 0x8F, 0x2F, 0xAF, 0x07, 0x87, 0x27, 0xA7, - 0xCD, 0x4D, 0xED, 0x6D, 0xC5, 0x45, 0xE5, 0x65, 0xCF, 0x4F, 0xEF, 0x6F, 0xC7, 0x47, 0xE7, 0x67, - 0x3D, 0xBD, 0x1D, 0x9D, 0x35, 0xB5, 0x15, 0x95, 0x3F, 0xBF, 0x1F, 0x9F, 0x37, 0xB7, 0x17, 0x97, - 0xFD, 0x7D, 0xDD, 0x5D, 0xF5, 0x75, 0xD5, 0x55, 0xFF, 0x7F, 0xDF, 0x5F, 0xF7, 0x77, 0xD7, 0x57, - 0x02, 0x82, 0x22, 0xA2, 0x0A, 0x8A, 0x2A, 0xAA, 0x00, 0x80, 0x20, 0xA0, 0x08, 0x88, 0x28, 0xA8, - 0xC2, 0x42, 0xE2, 0x62, 0xCA, 0x4A, 0xEA, 0x6A, 0xC0, 0x40, 0xE0, 0x60, 0xC8, 0x48, 0xE8, 0x68, - 0x32, 0xB2, 0x12, 0x92, 0x3A, 0xBA, 0x1A, 0x9A, 0x30, 0xB0, 0x10, 0x90, 0x38, 0xB8, 0x18, 0x98, - 0xF2, 0x72, 0xD2, 0x52, 0xFA, 0x7A, 0xDA, 0x5A, 0xF0, 0x70, 0xD0, 0x50, 0xF8, 0x78, 0xD8, 0x58 + 0x0E, 0x8E, 0x2E, 0xAE, 0x06, 0x86, 0x26, 0xA6, 0x0C, 0x8C, 0x2C, 0xAC, 0x04, 0x84, 0x24, 0xA4, + 0xCE, 0x4E, 0xEE, 0x6E, 0xC6, 0x46, 0xE6, 0x66, 0xCC, 0x4C, 0xEC, 0x6C, 0xC4, 0x44, 0xE4, 0x64, + 0x3E, 0xBE, 0x1E, 0x9E, 0x36, 0xB6, 0x16, 0x96, 0x3C, 0xBC, 0x1C, 0x9C, 0x34, 0xB4, 0x14, 0x94, + 0xFE, 0x7E, 0xDE, 0x5E, 0xF6, 0x76, 0xD6, 0x56, 0xFC, 0x7C, 0xDC, 0x5C, 0xF4, 0x74, 0xD4, 0x54, + 0x01, 0x81, 0x21, 0xA1, 0x09, 0x89, 0x29, 0xA9, 0x03, 0x83, 0x23, 0xA3, 0x0B, 0x8B, 0x2B, 0xAB, + 0xC1, 0x41, 0xE1, 0x61, 0xC9, 0x49, 0xE9, 0x69, 0xC3, 0x43, 0xE3, 0x63, 0xCB, 0x4B, 0xEB, 0x6B, + 0x31, 0xB1, 0x11, 0x91, 0x39, 0xB9, 0x19, 0x99, 0x33, 0xB3, 0x13, 0x93, 0x3B, 0xBB, 0x1B, 0x9B, + 0xF1, 0x71, 0xD1, 0x51, 0xF9, 0x79, 0xD9, 0x59, 0xF3, 0x73, 0xD3, 0x53, 0xFB, 0x7B, 0xDB, 0x5B, + 0x0D, 0x8D, 0x2D, 0xAD, 0x05, 0x85, 0x25, 0xA5, 0x0F, 0x8F, 0x2F, 0xAF, 0x07, 0x87, 0x27, 0xA7, + 0xCD, 0x4D, 0xED, 0x6D, 0xC5, 0x45, 0xE5, 0x65, 0xCF, 0x4F, 0xEF, 0x6F, 0xC7, 0x47, 0xE7, 0x67, + 0x3D, 0xBD, 0x1D, 0x9D, 0x35, 0xB5, 0x15, 0x95, 0x3F, 0xBF, 0x1F, 0x9F, 0x37, 0xB7, 0x17, 0x97, + 0xFD, 0x7D, 0xDD, 0x5D, 0xF5, 0x75, 0xD5, 0x55, 0xFF, 0x7F, 0xDF, 0x5F, 0xF7, 0x77, 0xD7, 0x57, + 0x02, 0x82, 0x22, 0xA2, 0x0A, 0x8A, 0x2A, 0xAA, 0x00, 0x80, 0x20, 0xA0, 0x08, 0x88, 0x28, 0xA8, + 0xC2, 0x42, 0xE2, 0x62, 0xCA, 0x4A, 0xEA, 0x6A, 0xC0, 0x40, 0xE0, 0x60, 0xC8, 0x48, 0xE8, 0x68, + 0x32, 0xB2, 0x12, 0x92, 0x3A, 0xBA, 0x1A, 0x9A, 0x30, 0xB0, 0x10, 0x90, 0x38, 0xB8, 0x18, 0x98, + 0xF2, 0x72, 0xD2, 0x52, 0xFA, 0x7A, 0xDA, 0x5A, 0xF0, 0x70, 0xD0, 0x50, 0xF8, 0x78, 0xD8, 0x58 }; int i = (int)((x + 1) * 7.9999); int j = (int)((y + 1) * 7.9999); @@ -295,10 +294,9 @@ void gs_abort(const gs_memory_t *mem) { gs_to_exit(mem, 1); /* cleanup */ - gp_do_exit(1); /* system independent exit() */ + gp_do_exit(1); /* system independent exit() */ } - /* Return the number with the magnitude of x and the sign of y. */ /* This is a BSD addition to libm; not all compilers have it. */ static double @@ -307,7 +305,6 @@ gs_copysign(floatp x, floatp y) return ( y >= 0 ? fabs(x) : -fabs(x) ); } - /* ---------------- Test program 1 ---------------- */ /* Draw a colored kaleidoscope. */ @@ -323,7 +320,7 @@ rand(void) rand_state = A * (rand_state % Q) - R * (rand_state / Q); /* Note that rand_state cannot be 0 here. */ if (rand_state <= 0) - rand_state += M; + rand_state += M; #undef A #undef M #undef Q @@ -340,22 +337,22 @@ test1(gs_state * pgs, gs_memory_t * mem) gs_scale(pgs, 4.0, 4.0); gs_newpath(pgs); for (n = 200; --n >= 0;) { - int j; + int j; #define rf() (rand() / (1.0 * 0x10000 * 0x8000)) - double r = rf(), g = rf(), b = rf(); - double x0 = rf(), y0 = rf(), x1 = rf(), y1 = rf(), x2 = rf(), y2 = rf(); - - gs_setrgbcolor(pgs, r, g, b); - for (j = 0; j < 6; j++) { - gs_gsave(pgs); - gs_rotate(pgs, 60.0 * j); - gs_moveto(pgs, x0, y0); - gs_lineto(pgs, x1, y1); - gs_lineto(pgs, x2, y2); - gs_fill(pgs); - gs_grestore(pgs); - } + double r = rf(), g = rf(), b = rf(); + double x0 = rf(), y0 = rf(), x1 = rf(), y1 = rf(), x2 = rf(), y2 = rf(); + + gs_setrgbcolor(pgs, r, g, b); + for (j = 0; j < 6; j++) { + gs_gsave(pgs); + gs_rotate(pgs, 60.0 * j); + gs_moveto(pgs, x0, y0); + gs_lineto(pgs, x1, y1); + gs_lineto(pgs, x2, y2); + gs_fill(pgs); + gs_grestore(pgs); + } } #undef mem return 0; @@ -379,8 +376,8 @@ test2(gs_state * pgs, gs_memory_t * mem) .x.... x..... */ - 0x3c, 0, 0, 0, 0x04, 0, 0, 0, 0x04, 0, 0, 0, 0x3c, 0, 0, 0, - 0x40, 0, 0, 0, 0x80, 0, 0, 0 + 0x3c, 0, 0, 0, 0x04, 0, 0, 0, 0x04, 0, 0, 0, 0x3c, 0, 0, 0, + 0x40, 0, 0, 0, 0x80, 0, 0, 0 }; gs_newpath(pgs); @@ -452,14 +449,14 @@ test3(gs_state * pgs, gs_memory_t * mem) tile.id = gs_next_ids(mem, 1); tile.rep_width = tile.rep_height = 4; (*dev_proc(dev, copy_rop)) - (dev, NULL, 0, 0, gx_no_bitmap_id, black2, - &tile, white_black, 100, 100, 150, 150, 0, 0, rop3_T); + (dev, NULL, 0, 0, gx_no_bitmap_id, black2, + &tile, white_black, 100, 100, 150, 150, 0, 0, rop3_T); (*dev_proc(dev, copy_rop)) - (dev, NULL, 0, 0, gx_no_bitmap_id, black2, - NULL, NULL, 120, 120, 110, 110, 0, 0, ~rop3_S & rop3_1); + (dev, NULL, 0, 0, gx_no_bitmap_id, black2, + NULL, NULL, 120, 120, 110, 110, 0, 0, ~rop3_S & rop3_1); (*dev_proc(dev, copy_rop)) - (dev, NULL, 0, 0, gx_no_bitmap_id, black2, - &tile, white_black, 110, 110, 130, 130, 0, 0, rop3_T ^ rop3_D); + (dev, NULL, 0, 0, gx_no_bitmap_id, black2, + &tile, white_black, 110, 110, 130, 130, 0, 0, rop3_T ^ rop3_D); #undef pbytes return 0; } @@ -482,26 +479,26 @@ test4(gs_state * pgs, gs_memory_t * mem) ares.size = 2; ares.persistent = true; code = param_write_float_array((gs_param_list *) & list, - "HWResolution", &ares); + "HWResolution", &ares); if (code < 0) { - lprintf1("Writing HWResolution failed: %d\n", code); - exit(1); + lprintf1("Writing HWResolution failed: %d\n", code); + exit(1); } gs_c_param_list_read(&list); code = gs_putdeviceparams(dev, (gs_param_list *) & list); gs_c_param_list_release(&list); if (code < 0) { - lprintf1("Setting HWResolution failed: %d\n", code); - exit(1); + lprintf1("Setting HWResolution failed: %d\n", code); + exit(1); } gs_initmatrix(pgs); gs_initclip(pgs); if (code == 1) { - code = (*dev_proc(dev, open_device)) (dev); - if (code < 0) { - lprintf1("Reopening device failed: %d\n", code); - exit(1); - } + code = (*dev_proc(dev, open_device)) (dev); + if (code < 0) { + lprintf1("Reopening device failed: %d\n", code); + exit(1); + } } gs_moveto(pgs, 0.0, 72.0); gs_rlineto(pgs, 72.0, 0.0); @@ -524,10 +521,10 @@ test5(gs_state * pgs, gs_memory_t * mem) int code; static const byte data3[] = { - 0x00, 0x44, 0x88, 0xcc, - 0x44, 0x88, 0xcc, 0x00, - 0x88, 0xcc, 0x00, 0x44, - 0xcc, 0x00, 0x44, 0x88 + 0x00, 0x44, 0x88, 0xcc, + 0x44, 0x88, 0xcc, 0x00, + 0x88, 0xcc, 0x00, 0x44, + 0xcc, 0x00, 0x44, 0x88 }; gs_color_space gray_cs; @@ -541,14 +538,14 @@ test5(gs_state * pgs, gs_memory_t * mem) /* Scale everything up, and fill the background. */ { - gs_matrix mat; - - gs_currentmatrix(pgs, &mat); - mat.xx = gs_copysign(98.6, mat.xx); - mat.yy = gs_copysign(98.6, mat.yy); - mat.tx = floor(mat.tx) + 0.499; - mat.ty = floor(mat.ty) + 0.499; - gs_setmatrix(pgs, &mat); + gs_matrix mat; + + gs_currentmatrix(pgs, &mat); + mat.xx = gs_copysign(98.6, mat.xx); + mat.yy = gs_copysign(98.6, mat.yy); + mat.tx = floor(mat.tx) + 0.499; + mat.ty = floor(mat.ty) + 0.499; + gs_setmatrix(pgs, &mat); } gs_setrgbcolor(pgs, 1.0, 0.9, 0.9); fill_rect1(pgs, 0.25, 0.25, 4.0, 6.0); @@ -581,37 +578,37 @@ test5(gs_state * pgs, gs_memory_t * mem) /* Test an unmasked image. */ gs_gsave(pgs); { - gs_image1_t image1; - void *info1; + gs_image1_t image1; + void *info1; gs_color_space cs; gs_cspace_init_DeviceGray(mem, &cs); - gs_image_t_init(&image1, &cs); - /* image */ - image1.ImageMatrix.xx = W; - image1.ImageMatrix.yy = -H; - image1.ImageMatrix.ty = H; - /* data_image */ - image1.Width = W; - image1.Height = H; - image1.BitsPerComponent = 8; - - gs_translate(pgs, 0.5, 4.0); + gs_image_t_init(&image1, &cs); + /* image */ + image1.ImageMatrix.xx = W; + image1.ImageMatrix.yy = -H; + image1.ImageMatrix.ty = H; + /* data_image */ + image1.Width = W; + image1.Height = H; + image1.BitsPerComponent = 8; + + gs_translate(pgs, 0.5, 4.0); code = (*dev_proc(dev, begin_image)) (dev, (const gs_imager_state *)pgs, &image1, gs_image_format_chunky, (const gs_int_rect *)0, &dcolor, NULL, mem, &info1); /****** TEST code >= 0 ******/ - planes[0].data = data3; - planes[0].data_x = 0; - planes[0].raster = - (image1.Height * image1.BitsPerComponent + 7) >> 3; - /* Use the old image_data API. */ - code = (*dev_proc(dev, image_data)) + planes[0].data = data3; + planes[0].data_x = 0; + planes[0].raster = + (image1.Height * image1.BitsPerComponent + 7) >> 3; + /* Use the old image_data API. */ + code = (*dev_proc(dev, image_data)) (dev, info1, &planes[0].data, 0, planes[0].raster, image1.Height); /****** TEST code == 1 ******/ - code = (*dev_proc(dev, end_image))(dev, info1, true); + code = (*dev_proc(dev, end_image))(dev, info1, true); /****** TEST code >= 0 ******/ } gs_grestore(pgs); @@ -619,87 +616,87 @@ test5(gs_state * pgs, gs_memory_t * mem) /* Test an explicitly masked image. */ gs_gsave(pgs); { - gs_image3_t image3; - static const byte data3mask[] = - { - 0x60, - 0x90, - 0x90, - 0x60 - }; - static const byte data3x2mask[] = - { - 0x66, - 0x99, - 0x99, - 0x66, - 0x66, - 0x99, - 0x99, - 0x66 - }; - - gs_image3_t_init(&image3, &gray_cs, interleave_scan_lines); - /* image */ - image3.ImageMatrix.xx = W; - image3.ImageMatrix.yy = -H; - image3.ImageMatrix.ty = H; - /* data_image */ - image3.Width = W; - image3.Height = H; - image3.BitsPerComponent = 8; - /* MaskDict */ - image3.MaskDict.ImageMatrix = image3.ImageMatrix; - image3.MaskDict.Width = image3.Width; - image3.MaskDict.Height = image3.Height; - - /* Display with 1-for-1 mask and image. */ - gs_translate(pgs, 0.5, 2.0); - code = gx_device_begin_typed_image(dev, (gs_imager_state *) pgs, - NULL, (gs_image_common_t *) & image3, - NULL, &dcolor, NULL, mem, &info); + gs_image3_t image3; + static const byte data3mask[] = + { + 0x60, + 0x90, + 0x90, + 0x60 + }; + static const byte data3x2mask[] = + { + 0x66, + 0x99, + 0x99, + 0x66, + 0x66, + 0x99, + 0x99, + 0x66 + }; + + gs_image3_t_init(&image3, &gray_cs, interleave_scan_lines); + /* image */ + image3.ImageMatrix.xx = W; + image3.ImageMatrix.yy = -H; + image3.ImageMatrix.ty = H; + /* data_image */ + image3.Width = W; + image3.Height = H; + image3.BitsPerComponent = 8; + /* MaskDict */ + image3.MaskDict.ImageMatrix = image3.ImageMatrix; + image3.MaskDict.Width = image3.Width; + image3.MaskDict.Height = image3.Height; + + /* Display with 1-for-1 mask and image. */ + gs_translate(pgs, 0.5, 2.0); + code = gx_device_begin_typed_image(dev, (gs_imager_state *) pgs, + NULL, (gs_image_common_t *) & image3, + NULL, &dcolor, NULL, mem, &info); /****** TEST code >= 0 ******/ - planes[0].data = data3mask; - planes[0].data_x = 0; - planes[0].raster = (image3.MaskDict.Height + 7) >> 3; - planes[1].data = data3; - planes[1].data_x = 0; - planes[1].raster = - (image3.Height * image3.BitsPerComponent + 7) >> 3; - code = gx_image_plane_data(info, planes, image3.Height); + planes[0].data = data3mask; + planes[0].data_x = 0; + planes[0].raster = (image3.MaskDict.Height + 7) >> 3; + planes[1].data = data3; + planes[1].data_x = 0; + planes[1].raster = + (image3.Height * image3.BitsPerComponent + 7) >> 3; + code = gx_image_plane_data(info, planes, image3.Height); /****** TEST code == 1 ******/ - code = gx_image_end(info, true); + code = gx_image_end(info, true); /****** TEST code >= 0 ******/ - /* Display with 2-for-1 mask and image. */ - image3.MaskDict.ImageMatrix.xx *= 2; - image3.MaskDict.ImageMatrix.yy *= 2; - image3.MaskDict.ImageMatrix.ty *= 2; - image3.MaskDict.Width *= 2; - image3.MaskDict.Height *= 2; - gs_translate(pgs, 1.5, 0.0); - code = gx_device_begin_typed_image(dev, (gs_imager_state *) pgs, - NULL, (gs_image_common_t *) & image3, - NULL, &dcolor, NULL, mem, &info); + /* Display with 2-for-1 mask and image. */ + image3.MaskDict.ImageMatrix.xx *= 2; + image3.MaskDict.ImageMatrix.yy *= 2; + image3.MaskDict.ImageMatrix.ty *= 2; + image3.MaskDict.Width *= 2; + image3.MaskDict.Height *= 2; + gs_translate(pgs, 1.5, 0.0); + code = gx_device_begin_typed_image(dev, (gs_imager_state *) pgs, + NULL, (gs_image_common_t *) & image3, + NULL, &dcolor, NULL, mem, &info); /****** TEST code >= 0 ******/ - planes[0].data = data3x2mask; - planes[0].raster = (image3.MaskDict.Width + 7) >> 3; - { - int i; - - for (i = 0; i < H; ++i) { - planes[1].data = 0; - code = gx_image_plane_data(info, planes, 1); - planes[0].data += planes[0].raster; + planes[0].data = data3x2mask; + planes[0].raster = (image3.MaskDict.Width + 7) >> 3; + { + int i; + + for (i = 0; i < H; ++i) { + planes[1].data = 0; + code = gx_image_plane_data(info, planes, 1); + planes[0].data += planes[0].raster; /****** TEST code == 0 ******/ - planes[1].data = data3 + i * planes[1].raster; - code = gx_image_plane_data(info, planes, 1); - planes[0].data += planes[0].raster; + planes[1].data = data3 + i * planes[1].raster; + code = gx_image_plane_data(info, planes, 1); + planes[0].data += planes[0].raster; /****** TEST code >= 0 ******/ - } - } + } + } /****** TEST code == 1 ******/ - code = gx_image_end(info, true); + code = gx_image_end(info, true); /****** TEST code >= 0 ******/ } gs_grestore(pgs); @@ -707,31 +704,31 @@ test5(gs_state * pgs, gs_memory_t * mem) /* Test a chroma-keyed masked image. */ gs_gsave(pgs); { - gs_image4_t image4; - const byte *data4 = data3; - - gs_image4_t_init(&image4, &gray_cs); - /* image */ - image4.ImageMatrix.xx = W; - image4.ImageMatrix.yy = -H; - image4.ImageMatrix.ty = H; - /* data_image */ - image4.Width = W; - image4.Height = H; - image4.BitsPerComponent = 8; - - /* Display with a single mask color. */ - gs_translate(pgs, 0.5, 0.5); - image4.MaskColor_is_range = false; - image4.MaskColor[0] = 0xcc; - do_image(image4, data4); - - /* Display a second time with a color range. */ - gs_translate(pgs, 1.5, 0.0); - image4.MaskColor_is_range = true; - image4.MaskColor[0] = 0x40; - image4.MaskColor[1] = 0x90; - do_image(image4, data4); + gs_image4_t image4; + const byte *data4 = data3; + + gs_image4_t_init(&image4, &gray_cs); + /* image */ + image4.ImageMatrix.xx = W; + image4.ImageMatrix.yy = -H; + image4.ImageMatrix.ty = H; + /* data_image */ + image4.Width = W; + image4.Height = H; + image4.BitsPerComponent = 8; + + /* Display with a single mask color. */ + gs_translate(pgs, 0.5, 0.5); + image4.MaskColor_is_range = false; + image4.MaskColor[0] = 0xcc; + do_image(image4, data4); + + /* Display a second time with a color range. */ + gs_translate(pgs, 1.5, 0.0); + image4.MaskColor_is_range = true; + image4.MaskColor[0] = 0x40; + image4.MaskColor[1] = 0x90; + do_image(image4, data4); } gs_grestore(pgs); @@ -753,19 +750,19 @@ spectrum(gs_state * pgs, int n) int a, b, c; for (a = 0; a < n; ++a) - for (b = 0; b < n; ++b) - for (c = 0; c < n; ++c) { - double size = (n * 2 - c * 2 - 1) / den2; - gs_client_color cc; - - cc.paint.values[0] = a / den1; - cc.paint.values[1] = b / den1; - cc.paint.values[2] = c / den1; - gs_setcolor(pgs, &cc); - fill_rect1(pgs, - a / den + c / den2, b / den + c / den2, - size, size); - } + for (b = 0; b < n; ++b) + for (c = 0; c < n; ++c) { + double size = (n * 2 - c * 2 - 1) / den2; + gs_client_color cc; + + cc.paint.values[0] = a / den1; + cc.paint.values[1] = b / den1; + cc.paint.values[2] = c / den1; + gs_setcolor(pgs, &cc); + fill_rect1(pgs, + a / den + c / den2, b / den + c / den2, + size, size); + } } static float render_abc(floatp v, const gs_cie_render * ignore_crd) @@ -783,7 +780,7 @@ test6(gs_state * pgs, gs_memory_t * mem) {1, 1, 1}; static const gs_cie_render_proc3 encode_abc = { - {render_abc, render_abc, render_abc} + {render_abc, render_abc, render_abc} }; #ifdef COLOR_MAP_DEVICE gx_device_cmap *cmdev; @@ -801,12 +798,12 @@ test6(gs_state * pgs, gs_memory_t * mem) /* We must set the CRD before the color space. */ code = gs_cie_render1_build(&pcrd, mem, "test6"); if (code < 0) - return code; + return code; gs_cie_render1_initialize(mem, pcrd, NULL, &white_point, NULL, - NULL, NULL, NULL, - NULL, NULL, NULL, - NULL, &encode_abc, NULL, - NULL); + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, &encode_abc, NULL, + NULL); gs_setcolorrendering(pgs, pcrd); gs_cspace_build_CIEABC(&pcs, NULL, mem); /* There should be an API for initializing CIE color spaces too.... */ @@ -819,10 +816,10 @@ test6(gs_state * pgs, gs_memory_t * mem) #ifdef COLOR_MAP_DEVICE /* Now test color snapping. */ cmdev = - gs_alloc_struct_immovable(mem, gx_device_cmap, &st_device_cmap, - "cmap device"); + gs_alloc_struct_immovable(mem, gx_device_cmap, &st_device_cmap, + "cmap device"); gdev_cmap_init(cmdev, gs_currentdevice(pgs), - device_cmap_snap_to_primaries); + device_cmap_snap_to_primaries); gs_setdevice_no_init(pgs, (gx_device *) cmdev); #endif /* COLOR_MAP_DEVICE */ gs_setrgbcolor(pgs, 0.0, 0.0, 0.0); /* back to DeviceRGB space */ @@ -852,13 +849,13 @@ test7(gs_state * pgs, gs_memory_t * mem) static const byte masks[1 * 4 * 4] = { /* 0% */ - 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, /* 25% */ - 0x80, 0x40, 0x20, 0x10, + 0x80, 0x40, 0x20, 0x10, /* 50% */ - 0xa0, 0xa0, 0x50, 0x50, + 0xa0, 0xa0, 0x50, 0x50, /* 75% */ - 0xd0, 0xe0, 0x70, 0xb0 + 0xd0, 0xe0, 0x70, 0xb0 }; gs_ht *pht; int code; @@ -868,13 +865,13 @@ test7(gs_state * pgs, gs_memory_t * mem) code = gs_ht_build(&pht, 1, mem); dprintf1("ht build code = %d\n", code); code = gs_ht_set_mask_comp(pht, 0, - 4, 4, 4, masks, NULL, NULL); + 4, 4, 4, masks, NULL, NULL); dprintf1("set mask code = %d\n", code); code = gs_sethalftone(pgs, pht); dprintf1("sethalftone code = %d\n", code); for (i = 0; i <= 4; ++i) { - gs_setgray(pgs, i / 4.0); - fill_rect1(pgs, 100 + i * 100, 100, 50, 50); + gs_setgray(pgs, i / 4.0); + fill_rect1(pgs, 100 + i * 100, 100, 50, 50); } return 0; } @@ -892,22 +889,22 @@ test8(gs_state * pgs, gs_memory_t * mem) */ static const byte pdata[] = { - 0x7f, 0xff, 0x00, 0x03, - 0x7f, 0xff, 0x00, 0x0c, - 0x50, 0x00, 0x00, 0x30, - 0x50, 0x00, 0x00, 0xc0, - 0x50, 0x00, 0x03, 0x00, - 0x50, 0x00, 0x0c, 0x00, - 0x50, 0x00, 0x30, 0x00, - 0x50, 0x00, 0xc0, 0x00, - 0xf0, 0x00, 0xc0, 0x00, - 0xf0, 0x00, 0x30, 0x00, - 0xf0, 0x00, 0x0c, 0x00, - 0xf0, 0x00, 0x03, 0x00, - 0xf0, 0x00, 0x00, 0xc0, - 0xf0, 0x00, 0x00, 0x30, - 0xea, 0x55, 0xaa, 0x5c, - 0xea, 0x55, 0xaa, 0x57, + 0x7f, 0xff, 0x00, 0x03, + 0x7f, 0xff, 0x00, 0x0c, + 0x50, 0x00, 0x00, 0x30, + 0x50, 0x00, 0x00, 0xc0, + 0x50, 0x00, 0x03, 0x00, + 0x50, 0x00, 0x0c, 0x00, + 0x50, 0x00, 0x30, 0x00, + 0x50, 0x00, 0xc0, 0x00, + 0xf0, 0x00, 0xc0, 0x00, + 0xf0, 0x00, 0x30, 0x00, + 0xf0, 0x00, 0x0c, 0x00, + 0xf0, 0x00, 0x03, 0x00, + 0xf0, 0x00, 0x00, 0xc0, + 0xf0, 0x00, 0x00, 0x30, + 0xea, 0x55, 0xaa, 0x5c, + 0xea, 0x55, 0xaa, 0x57, }; gs_depth_bitmap ptile; gs_const_string table; @@ -918,7 +915,7 @@ test8(gs_state * pgs, gs_memory_t * mem) gs_cspace_init_DeviceRGB(mem, &rgb_cs); table.data = - (const byte *)"\377\377\377\377\000\000\000\377\000\000\000\000"; + (const byte *)"\377\377\377\377\000\000\000\377\000\000\000\000"; table.size = 12; gs_cspace_build_Indexed(&pcs, &rgb_cs, 4, &table, mem); ptile.data = pdata; @@ -928,26 +925,26 @@ test8(gs_state * pgs, gs_memory_t * mem) ptile.pix_depth = 2; ptile.num_comps = 1; gs_makepixmappattern(&ccolor, &ptile, false /*mask */ , NULL /*pmat */ , - gs_no_id, pcs, 0 /*white_index */ , pgs, mem); + gs_no_id, pcs, 0 /*white_index */ , pgs, mem); { - gs_rect r; - - r.p.x = 100; - r.p.y = 100; - r.q.x = 200; - r.q.y = 200; - gs_setrgbcolor(pgs, 1.0, 1.0, 0.0); - gs_rectfill(pgs, &r, 1); - gs_setpattern(pgs, &ccolor); - // gs_settexturetransparent(pgs, true); - gs_rectfill(pgs, &r, 1); - r.p.x += 150; - r.q.x += 150; - gs_setrgbcolor(pgs, 1.0, 1.0, 0.0); - gs_rectfill(pgs, &r, 1); - gs_setpattern(pgs, &ccolor); - // gs_settexturetransparent(pgs, false); - gs_rectfill(pgs, &r, 1); + gs_rect r; + + r.p.x = 100; + r.p.y = 100; + r.q.x = 200; + r.q.y = 200; + gs_setrgbcolor(pgs, 1.0, 1.0, 0.0); + gs_rectfill(pgs, &r, 1); + gs_setpattern(pgs, &ccolor); + // gs_settexturetransparent(pgs, true); + gs_rectfill(pgs, &r, 1); + r.p.x += 150; + r.q.x += 150; + gs_setrgbcolor(pgs, 1.0, 1.0, 0.0); + gs_rectfill(pgs, &r, 1); + gs_setpattern(pgs, &ccolor); + // gs_settexturetransparent(pgs, false); + gs_rectfill(pgs, &r, 1); } return 0; } @@ -968,25 +965,25 @@ test8(gs_state * pgs, gs_memory_t * mem) static int test9_get_int16(const byte *bptr) -{ +{ return get_int16(bptr); } static uint test9_get_uint16(const byte *bptr) -{ +{ return get_uint16(bptr); } static long test9_get_int32(const byte *bptr) -{ +{ return ((long)get_int16(bptr) << 16) | get_uint16(bptr + 2); } static ulong test9_get_uint32(const byte *bptr) -{ +{ return ((ulong)get_uint16(bptr) << 16) | get_uint16(bptr + 2); } @@ -1011,7 +1008,7 @@ test9_tt_find_table(gs_font_type42 *pfont, const char *tname, uint *plen) uint i; ulong table_dir_offset = 0; int (*string_proc)(gs_font_type42 *, ulong, uint, const byte **) = - pfont->data.string_proc; + pfont->data.string_proc; /* nb check return values */ ACCESS(pfont->memory, 0, 12, OffsetTable); @@ -1052,7 +1049,7 @@ test9_tt_glyph_name(gs_font *pf, gs_glyph glyph, gs_const_string *pstr) static int test9_tt_string_proc(gs_font *p42, ulong offset, uint length, const byte **pdata) { - + /* NB bounds check offset + length - use gs_object_size for memory buffers - if file read should fail */ *pdata = p42->client_data + offset; @@ -1071,7 +1068,7 @@ test9_tt_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont, gs_char return code; w2[0] = sbw[2], w2[1] = sbw[3]; /* don't ask me about the following, I just work here. */ - { + { #define pbfont ((gs_font_base *)pfont) const gs_rect *pbbox = &pbfont->FontBBox; @@ -1079,7 +1076,7 @@ test9_tt_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont, gs_char w2[2] = pbbox->p.x, w2[3] = pbbox->p.y; w2[4] = pbbox->q.x, w2[5] = pbbox->q.y; - if ( pfont->PaintType ) { + if ( pfont->PaintType ) { double expand = max(1.415, gs_currentmiterlimit(pgs)) * gs_currentlinewidth(pgs) / 2; @@ -1093,7 +1090,7 @@ test9_tt_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont, gs_char if ( (code = gs_setcachedevice(penum, pgs, w2)) < 0 ) return code; - + code = gs_type42_append(glyph, (gs_imager_state *)pgs, gx_current_path(pgs), @@ -1117,7 +1114,7 @@ test9_load_font_data(const char *filename, gs_memory_t * mem) size = (fseek(in, 0L, SEEK_END), ftell(in)); rewind(in); data = gs_alloc_bytes(mem, size, "test9_load_font data"); - if ( data == 0 ) { + if ( data == 0 ) { fclose(in); return NULL; } @@ -1127,7 +1124,7 @@ test9_load_font_data(const char *filename, gs_memory_t * mem) fclose(in); return data; } - + /* windows tt file name */ #define TTF_FILENAME "/windows/fonts/A028-Ext.ttf" @@ -1149,14 +1146,14 @@ test9_load_font_data(const char *filename, gs_memory_t * mem) static int test9(gs_state * pgs, gs_memory_t * mem) { - + gs_font_type42 *p42 = gs_alloc_struct(mem, gs_font_type42, &st_gs_font_type42, "new p42"); gs_font_dir *pfont_dir = gs_font_dir_alloc(mem); byte *pfont_data = test9_load_font_data(TTF_FILENAME, mem); - + if (!pfont_data || !pfont_dir || !p42) return -1; @@ -1199,7 +1196,7 @@ test9(gs_state * pgs, gs_memory_t * mem) /* Initialize Type 42 specific data. */ p42->data.string_proc = test9_tt_string_proc; gs_type42_font_init(p42); - + gs_definefont(pfont_dir, (gs_font *)p42); gs_setfont(pgs, (gs_font *)p42); { @@ -1220,7 +1217,6 @@ test9(gs_state * pgs, gs_memory_t * mem) text_params.data.bytes = mystr + i; text_params.size = 1; - gs_make_identity(&fmat); if ((gs_matrix_scale(&fmat, FontRenderingEmSize, FontRenderingEmSize, &fmat) != 0) || (gs_setcharmatrix(pgs, &fmat) != 0) || @@ -1243,19 +1239,19 @@ test9(gs_state * pgs, gs_memory_t * mem) false, &ppair); - cc = gx_lookup_cached_char(penum->current_font, - ppair, + cc = gx_lookup_cached_char(penum->current_font, + ppair, penum->returned.current_glyph, /* nb next three assume no veritcal writing '0', bitdepth '1' and no sub pixel stuff */ - 0, - 1, + 0, + 1, &sub_pix_or); - debug_dump_bitmap(cc_bits(cc), + debug_dump_bitmap(cc_bits(cc), cc_raster(cc), cc->height, ""); /* update point (device space) */ |