From 3475e7fba3bc57acde8ff0ec8091ea02ba1dd774 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 17 May 2000 20:56:01 +0000 Subject: [PATCH] removed TT_MAX_SUBGLYPHS macro, there is no static limit on the number of subglyphs in a TrueType font.. changed the default number of gray levels used by the smooth renderer to 256 (instead of 128). Of course, the human eye can't tell a difference ;-) --- CHANGES | 12 ++++++- demos/graph/grobjs.c | 4 +-- demos/src/ftstring.c | 6 ++-- demos/src/ftview.c | 6 ++-- include/freetype/config/ftoption.h | 2 -- src/base/ftgrays.c | 4 +-- src/base/ftraster.c | 2 +- src/truetype/ttgload.c | 58 ++++++++++++++++-------------- 8 files changed, 53 insertions(+), 41 deletions(-) diff --git a/CHANGES b/CHANGES index f1d4389e5..665c6a893 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,14 @@ -LATEST CHANGES - +LATEST_CHANGES + + - changed the default number of gray levels of the smooth renderer to + 256 (instead of the previous 128). Of course, the human eye can't + see any difference ;-) + + - removed TT_MAX_SUBGLYPHS, there is no static limit on the number of + subglyphs in a TrueType font now.. + +============================================================================= +OLD CHANGES 16 May 2000 - tagged "BETA-6" in the CVS tree. This one is a serious release candidate even though it doesn't incorporate the auto-hinter yet.. diff --git a/demos/graph/grobjs.c b/demos/graph/grobjs.c index ae106dd9b..df8512f91 100644 --- a/demos/graph/grobjs.c +++ b/demos/graph/grobjs.c @@ -98,8 +98,8 @@ pixel_mode >= gr_pixel_mode_max ) goto Fail; - if ( pixel_mode != gr_pixel_mode_gray || - ( num_grays >= 2 && num_grays < 256 ) ) + if ( pixel_mode != gr_pixel_mode_gray || + ( num_grays >= 2 && num_grays <= 256 ) ) return 0; Fail: diff --git a/demos/src/ftstring.c b/demos/src/ftstring.c index c0c13493e..502d527be 100644 --- a/demos/src/ftstring.c +++ b/demos/src/ftstring.c @@ -57,7 +57,7 @@ static int res = 72; /* default resolution in dpi */ - static grColor fore_color = { 127 }; + static grColor fore_color = { 255 }; static int graph_init = 0; static int render_mode = 1; @@ -158,7 +158,7 @@ bit.mode = gr_pixel_mode_gray; bit.width = DIM_X; bit.rows = DIM_Y; - bit.grays = 128; + bit.grays = 256; surface = grNewSurface( 0, &bit ); if (!surface) @@ -254,7 +254,7 @@ if( !hinted ) load_flags |= FT_LOAD_NO_HINTING; - num_grays = 128; + num_grays = 256; if (!antialias) num_grays = 0; diff --git a/demos/src/ftview.c b/demos/src/ftview.c index dca3a69aa..c3613cab5 100644 --- a/demos/src/ftview.c +++ b/demos/src/ftview.c @@ -66,7 +66,7 @@ $\243^\250*\265\371%!\247:/;.,?<>"; int res = 72; - static grColor fore_color = { 127 }; + static grColor fore_color = { 255 }; int Fail; unsigned char autorun; @@ -127,7 +127,7 @@ $\243^\250*\265\371%!\247:/;.,?<>"; bit.mode = gr_pixel_mode_gray; bit.width = DIM_X; bit.rows = DIM_Y; - bit.grays = 128; + bit.grays = 256; surface = grNewSurface( 0, &bit ); if (!surface) @@ -185,7 +185,7 @@ $\243^\250*\265\371%!\247:/;.,?<>"; bit3.pitch = bit2.pitch; bit3.mode = antialias ? bit.mode : gr_pixel_mode_mono; bit3.buffer = bit_buffer; - bit3.grays = 128; + bit3.grays = 256; FT_Outline_Translate( &glyph->outline, -left, -bottom ); memset( bit_buffer, 0, size ); diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index 45e2cd01c..579254c02 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -349,8 +349,6 @@ /* */ #define TT_CONFIG_OPTION_INTERPRETER_SWITCH - /* The maximum number of sub-glyphs in a TrueType composite glyph */ -#define TT_MAX_SUBGLYPHS 96 /*************************************************************************/ /*************************************************************************/ diff --git a/src/base/ftgrays.c b/src/base/ftgrays.c index 95550cef9..14535b754 100644 --- a/src/base/ftgrays.c +++ b/src/base/ftgrays.c @@ -1016,13 +1016,13 @@ int check_sort( PCell cells, int count ) { if (spans->coverage) #if 1 - memset( p + spans->x, (spans->coverage+1) >> 1, spans->len ); + memset( p + spans->x, (unsigned char)spans->coverage, spans->len ); #else { q = p + spans->x; limit = q + spans->len; for ( ; q < limit; q++ ) - q[0] = (spans->coverage+1) >> 1; + q[0] = (unsigned char)spans->coverage; } #endif } diff --git a/src/base/ftraster.c b/src/base/ftraster.c index 26a9a2b88..3cbba416d 100644 --- a/src/base/ftraster.c +++ b/src/base/ftraster.c @@ -2866,7 +2866,7 @@ Scan_DropOuts : /* set default 5-levels gray palette */ for ( n = 0; n < 5; n++ ) - raster->grays[n] = (n*127/4); + raster->grays[n] = (n*255/4); raster->gray_width = RASTER_GRAY_LINES/2; } diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 2413066cd..c388a6c55 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -467,7 +467,6 @@ TT_Error error; TT_Face face = loader->face; TT_ULong offset; - FT_SubGlyph subglyphs[ TT_MAX_SUBGLYPHS ]; TT_Int num_subglyphs = 0, contours_count; TT_UInt index, num_points, num_contours, count; TT_Fixed x_scale, y_scale; @@ -632,7 +631,8 @@ else /* otherwise, load a composite !! */ { /* for each subglyph, read composite header */ - FT_SubGlyph* subglyph = subglyphs; + TT_GlyphSlot glyph = loader->glyph; + FT_SubGlyph* subglyph = glyph->subglyphs + glyph->num_subglyphs; if (ACCESS_Frame(count)) goto Fail; @@ -640,6 +640,25 @@ do { TT_Fixed xx, xy, yy, yx; + FT_UInt total_subglyphs; + + /* grow the 'glyph->subglyphs' table if necessary */ + total_subglyphs = glyph->num_subglyphs + num_subglyphs; + if ( total_subglyphs >= glyph->max_subglyphs ) + { + FT_UInt new_max = glyph->max_subglyphs; + FT_Memory memory = loader->face->root.memory; + + while (new_max <= total_subglyphs) + new_max += 4; + + if ( REALLOC_ARRAY( glyph->subglyphs, glyph->max_subglyphs, + new_max, FT_SubGlyph ) ) + goto Fail; + + glyph->max_subglyphs = new_max; + subglyph = glyph->subglyphs + glyph->num_subglyphs + num_subglyphs; + } subglyph->arg1 = subglyph->arg2 = 0; @@ -687,8 +706,6 @@ subglyph++; num_subglyphs++; - if (num_subglyphs >= TT_MAX_SUBGLYPHS) - break; } while (subglyph[-1].flags & MORE_COMPONENTS); @@ -707,27 +724,9 @@ /* responsible for interpreting this data..) */ if ( loader->load_flags & FT_LOAD_NO_RECURSE ) { - FT_GlyphSlot glyph = loader->glyph; - - /* reallocate subglyph array if necessary */ - if (glyph->max_subglyphs < num_subglyphs) - { - FT_Memory memory = loader->face->root.memory; - - if ( REALLOC_ARRAY( glyph->subglyphs, glyph->max_subglyphs, - num_subglyphs, FT_SubGlyph ) ) - goto Fail; - - glyph->max_subglyphs = num_subglyphs; - } - - /* copy subglyph array */ - MEM_Copy( glyph->subglyphs, subglyphs, - num_subglyphs*sizeof(FT_SubGlyph)); - /* set up remaining glyph fields */ - glyph->num_subglyphs = num_subglyphs; - glyph->format = ft_glyph_format_composite; + glyph->num_subglyphs += num_subglyphs; + glyph->format = ft_glyph_format_composite; goto Load_End; } @@ -741,7 +740,9 @@ { TT_Int n, num_base_points, num_new_points; - subglyph = subglyphs; + subglyph = glyph->subglyphs + glyph->num_subglyphs; + glyph->num_subglyphs += num_subglyphs; + for ( n = 0; n < num_subglyphs; n++, subglyph++ ) { TT_Vector pp1, pp2; @@ -753,6 +754,8 @@ num_base_points = loader->base.n_points; error = load_truetype_glyph( loader, subglyph->index ); + if (error) goto Fail; + if ( subglyph->flags & USE_MY_METRICS ) { pp1 = loader->pp1; @@ -935,8 +938,8 @@ loader->pp2 = pp1[1]; } #endif - } + /* end of composite loading */ } /*************************************************************************/ @@ -1326,7 +1329,8 @@ #endif /* Main loading loop */ - glyph->format = ft_glyph_format_outline; + glyph->format = ft_glyph_format_outline; + glyph->num_subglyphs = 0; error = load_truetype_glyph( &loader, glyph_index ); if (!error) compute_glyph_metrics( &loader, glyph_index );