From d0079e669e956c6ad8bed7df559fe4ab0216f851 Mon Sep 17 00:00:00 2001 From: David Turner Date: Fri, 23 Jun 2000 00:07:06 +0000 Subject: [PATCH] improved the Type1 drivers to deal with the case where the lenIV field is set to -1 to indicate unencoded charstrings fixed some source code to prevent a compiler bug on IRIX fixed the module version's in the "type1z" driver --- src/renderer/ftrender.c | 161 ---------------------------------------- src/type1/t1gload.c | 9 ++- src/type1/t1load.c | 30 ++++++-- src/type1z/t1driver.c | 6 +- src/type1z/t1load.c | 28 +++++-- 5 files changed, 57 insertions(+), 177 deletions(-) delete mode 100644 src/renderer/ftrender.c diff --git a/src/renderer/ftrender.c b/src/renderer/ftrender.c deleted file mode 100644 index a376d50f4..000000000 --- a/src/renderer/ftrender.c +++ /dev/null @@ -1,161 +0,0 @@ -#include - - /* sets render-specific mode */ - static FT_Error ft_renderer_set_mode( FT_Renderer render, - FT_ULong mode_tag, - FT_Pointer data ) - { - /* we simply pass it to the raster */ - return render->clazz->raster_class->raster_set_mode( - render->raster, mode_tag, data ); - } - - - /* convert a slot's glyph image into a bitmap */ - static FT_Error ft_renderer_render( FT_Renderer render, - FT_GlyphSlot slot, - FT_UInt mode ) - { - FT_Error error; - FT_Outline* outline; - FT_BBox cbox; - FT_UInt width, height, pitch; - FT_Bitmap* bitmap; - FT_Memory memory; - - FT_Raster_Params params; - - /* first of all, transform the outline */ - if (slot->format != ft_glyph_format_outline) - { - error = FT_Err_Invalid_Argument; - goto Exit; - } - - outline = &slot->outline; - - FT_Outline_Transform( outline, &slot->transform_matrix ); - FT_Outline_Translate( outline, slot->transform_delta.x, - slot->transform_delta.y ); - - /* compute the control box, and grid fit it */ - FT_Outline_Get_CBox( outline, &cbox ); - - cbox.xMin &= -64; - cbox.yMin &= -64; - cbox.xMax = (cbox.xMax+63) & -64; - cbox.yMax = (cbox.yMax+63) & -64; - - width = (cbox.xMax - cbox.xMin) >> 6; - height = (cbox.yMax - cbox.yMin) >> 6; - bitmap = &slot->bitmap; - memory = slot->face->memory; - - /* release old bitmap buffer */ - if ((slot->flags & ft_glyph_own_bitmap)) - FREE(bitmap->buffer); - - /* allocate new one, depends on pixel format */ - if ( mode & ft_render_mode_antialias ) - { - pitch = width; - bitmap->pixel_mode = ft_pixel_mode_grays; - bitmap->num_grays = 256; - } - else - { - pitch = (width+7) >> 3; - bitmap->pixel_mode = ft_pixel_mode_mono; - } - - bitmap->width = width; - bitmap->rows = height; - bitmap->pitch = pitch; - - if (ALLOC( bitmap->buffer, (FT_ULong)pitch * height )) - goto Exit; - - /* translate outline to render it into the bitmap */ - FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin ); - - /* set up parameters */ - params.target = bitmap; - params.source = outline; - params.flags = 0; - - if ( bitmap->pixel_mode == ft_pixel_mode_grays ) - params.flags |= ft_raster_flag_aa; - - /* render outline into the bitmap */ - error = render->render( render->raster, ¶ms ); - if (error) goto Exit; - - slot->format = ft_glyph_format_bitmap; - slot->bitmap_left = cbox.xMin >> 6; - slot->bitmap_top = cbox.yMax >> 6; - - Exit: - return error; - } - -#ifndef FT_CONFIG_OPTION_NO_STD_RASTER - -#include - - const FT_Renderer_Class ft_standard_renderer_class = - { - { - ft_module_renderer, - sizeof( FT_RendererRec ), - - "standard renderer", - 0x10000, - 0x20000, - - 0, /* module specific interface */ - - (FT_Module_Constructor) 0, - (FT_Module_Destructor) 0, - (FT_Module_Requester) 0 - }, - - ft_glyph_format_outline, - - (FTRenderer_render) ft_renderer_render, - (FTRenderer_setMode) ft_renderer_set_mode, - - (FT_Raster_Funcs*) &ft_standard_raster - }; - -#endif /* !FT_CONFIG_OPTION_NO_STD_RASTER */ - -#ifndef FT_CONFIG_OPTION_NO_SMOOTH_RASTER - -#include - - const FT_Renderer_Class ft_smooth_renderer_class = - { - { - ft_module_renderer, - sizeof( FT_RendererRec ), - - "smooth renderer", - 0x10000, - 0x20000, - - 0, /* module specific interface */ - - (FT_Module_Constructor) 0, - (FT_Module_Destructor) 0, - (FT_Module_Requester) 0 - }, - - ft_glyph_format_outline, - - (FTRenderer_render) ft_renderer_render, - (FTRenderer_setMode) ft_renderer_set_mode, - - (FT_Raster_Funcs*) &ft_grays_raster - }; - -#endif /* !FT_CONFIG_OPTION_NO_SMOOTH_RASTER */ diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index ff06bc805..a7dbbb5f9 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -830,7 +830,14 @@ case op_div: if (top[1]) - *top++ = top[0] / top[1]; + { + /* this code was originally "*top++ = top[1]/top[0]" */ + /* however, it didn't run correctly on IRIX 6.5 using */ + /* the MISPRO 7.2 compiler suite. The following code */ + /* should run flawlessly.. */ + *top = top[0] / top[1]; + ++top; + } else { FT_ERROR(( "T1.Parse_CHarStrings : division by 0\n" )); diff --git a/src/type1/t1load.c b/src/type1/t1load.c index 7f3751a9f..0b950852c 100644 --- a/src/type1/t1load.c +++ b/src/type1/t1load.c @@ -719,11 +719,20 @@ { FT_Byte* base = tokzer->base + tokzer->cursor; - t1_decrypt( base, count, 4330 ); tokzer->cursor += count; - base += face->type1.private_dict.lenIV; - count -= face->type1.private_dict.lenIV; + /* some fonts use a value of -1 for lenIV to indicate that */ + /* the charstrings are unencoded.. */ + /* */ + /* thanks to Tom Kacvinsky for pointing this out.. */ + /* */ + if (face->type1.private_dict.lenIV >= 0) + { + t1_decrypt( base, count, 4330 ); + + base += face->type1.private_dict.lenIV; + count -= face->type1.private_dict.lenIV; + } error = T1_Add_Table( &parser->table, index, base, count ); } @@ -803,11 +812,20 @@ { FT_Byte* base = tokzer->base + tokzer->cursor; - t1_decrypt( base, count, 4330 ); tokzer->cursor += count; /* skip */ + + /* some fonts use a value of -1 for lenIV to indicate that */ + /* the charstrings are unencoded.. */ + /* */ + /* thanks to Tom Kacvinsky for pointing this out.. */ + /* */ + if (face->type1.private_dict.lenIV >= 0) + { + t1_decrypt( base, count, 4330 ); - base += face->type1.private_dict.lenIV; - count -= face->type1.private_dict.lenIV; + base += face->type1.private_dict.lenIV; + count -= face->type1.private_dict.lenIV; + } error = T1_Add_Table( &parser->table, index*2+1, base, count ); } diff --git a/src/type1z/t1driver.c b/src/type1z/t1driver.c index 12c483bb5..3601a0c2e 100644 --- a/src/type1z/t1driver.c +++ b/src/type1z/t1driver.c @@ -229,9 +229,9 @@ ft_module_font_driver | ft_module_driver_scalable, sizeof( FT_DriverRec ), - "type1", - 100, - 200, + "type1z", + 0x10000, + 0x20000, 0, /* format interface */ diff --git a/src/type1z/t1load.c b/src/type1z/t1load.c index 779c7c510..0029e4dea 100644 --- a/src/type1z/t1load.c +++ b/src/type1z/t1load.c @@ -1078,9 +1078,17 @@ index = T1_ToInt(parser); if (!read_binary_data(parser,&size,&base)) return; - T1_Decrypt( base, size, 4330 ); - size -= face->type1.private_dict.lenIV; - base += face->type1.private_dict.lenIV; + /* some fonts use a value of -1 for lenIV to indicate that */ + /* the charstrings are unencoded.. */ + /* */ + /* thanks to Tom Kacvinsky for pointing this out.. */ + /* */ + if (face->type1.private_dict.lenIV >= 0) + { + T1_Decrypt( base, size, 4330 ); + size -= face->type1.private_dict.lenIV; + base += face->type1.private_dict.lenIV; + } error = T1_Add_Table( table, index, base, size ); if (error) goto Fail; @@ -1162,9 +1170,17 @@ parser->cursor = cur2; if (!read_binary_data(parser,&size,&base)) return; - T1_Decrypt( base, size, 4330 ); - size -= face->type1.private_dict.lenIV; - base += face->type1.private_dict.lenIV; + /* some fonts use a value of -1 for lenIV to indicate that */ + /* the charstrings are unencoded.. */ + /* */ + /* thanks to Tom Kacvinsky for pointing this out.. */ + /* */ + if (face->type1.private_dict.lenIV >= 0) + { + T1_Decrypt( base, size, 4330 ); + size -= face->type1.private_dict.lenIV; + base += face->type1.private_dict.lenIV; + } error = T1_Add_Table( code_table, n, base, size ); if (error) goto Fail;