From 0f99ddda5f236479edd55f9233dd4ade1d76f646 Mon Sep 17 00:00:00 2001 From: David Turner Date: Mon, 6 Mar 2000 13:23:32 +0000 Subject: [PATCH] changed the structure of FT_Outline in order to pack all outline flags in a single integer.. Changed the rest of the library and demo programs accordingly.. --- demos/src/fttimer.c | 12 ++--- demos/src/ftview.c | 2 +- include/ftimage.h | 102 ++++++++++++++++++++++++++-------------- src/base/ftobjs.c | 12 ++--- src/base/ftoutln.c | 12 +++-- src/base/ftraster.c | 13 +++-- src/truetype/ttdriver.c | 4 +- src/truetype/ttgload.c | 14 ++++-- src/type1/t1gload.c | 7 +++ src/type1z/t1gload.c | 5 ++ 10 files changed, 123 insertions(+), 60 deletions(-) diff --git a/demos/src/fttimer.c b/demos/src/fttimer.c index 0d69c6a58..8aaf6bdc4 100644 --- a/demos/src/fttimer.c +++ b/demos/src/fttimer.c @@ -151,11 +151,11 @@ if ( error ) return error; - glyph->outline.second_pass = 0; - glyph->outline.dropout_mode = 0; + glyph->outline.outline_flags |= ft_outline_single_pass | + ft_outline_ignore_dropouts; if (force_low) - glyph->outline.high_precision = 0; + glyph->outline.outline_flags &= ~ft_outline_high_precision; /* debugging */ #if 0 @@ -176,9 +176,9 @@ &outlines[cur_glyph] ); /* copy the glyph outline into it */ - glyph->outline.second_pass = 0; + glyph->outline.outline_flags |= ft_outline_single_pass; if (force_low) - glyph->outline.high_precision = 0; + glyph->outline.outline_flags &= ~ft_outline_high_precision; FT_Copy_Outline( &glyph->outline, &outlines[cur_glyph] ); @@ -211,7 +211,7 @@ FT_Error ConvertRaster( int index ) { - outlines[index].second_pass = 0; + outlines[index].outline_flags |= ~ft_outline_single_pass; return FT_Get_Outline_Bitmap( library, &outlines[index], &Bit ); } diff --git a/demos/src/ftview.c b/demos/src/ftview.c index 49f55214d..1390b7f5a 100644 --- a/demos/src/ftview.c +++ b/demos/src/ftview.c @@ -181,7 +181,7 @@ memset( bit_buffer, 0, size ); if (low_prec) - glyph->outline.high_precision = 0; + glyph->outline.outline_flags &= ~ft_outline_high_precision; FT_Get_Outline_Bitmap( library, &glyph->outline, &bit2 ); } diff --git a/include/ftimage.h b/include/ftimage.h index 565109c05..1d5121511 100644 --- a/include/ftimage.h +++ b/include/ftimage.h @@ -250,34 +250,10 @@ /* defined by the points `contours[0]+1' to */ /* `contours[1]', etc. */ /* */ - /* owner :: This flag is a boolean which is set whenever the */ - /* outline structure/object owns the arrays it */ - /* refers to in the fields `points', `flags', and */ - /* `contours'. */ - /* */ - /* high_precision :: This flag is set automatically by the FreeType */ - /* library. It indicates that the scan-line */ - /* converter should use a higher precision when */ - /* rendering the outline. This is useful at small */ - /* pixel sizes to get adequate results, though at */ - /* the price of slower rendering. Don't try to */ - /* render large outlines with this flag set. Note */ - /* that it may be ignored in later implementations. */ - /* */ - /* second_pass :: A boolean which is set when the scan-line */ - /* converter should perform a second pass to */ - /* eliminate vertical drop-outs (only vertical */ - /* drop-outs are checked on the first pass). This */ - /* field may be ignored by later implementations. */ - /* */ - /* dropout_mode :: Specifies the drop-out control mode to use while */ - /* rendering an outline. Valid values are 0 (no */ - /* drop out check), 1, 2, 4, and 5. See the */ - /* TrueType specification for more details. A */ - /* value of 2 is usually an excellent generic */ - /* choice. This field may be ignored by some */ - /* raster implementations. */ - /* */ + /* outline_flags :: a set of bit flags used to characterize the */ + /* outline and give hints to the scan-converter */ + /* and hinter on how to convert/grid-fit it.. */ + /* see FT_Outline_Flags.. */ /* */ typedef struct FT_Outline_ { @@ -288,15 +264,71 @@ char* flags; /* the points flags */ short* contours; /* the contour end points */ - char owner; /* the outline owns the coordinates, */ - /* flags, and contours array it uses */ - - char high_precision; /* high precision rendering */ - char second_pass; /* two sweeps rendering */ - char dropout_mode; /* dropout mode */ - + int outline_flags; /* outline masks */ + } FT_Outline; + /*************************************************************************/ + /* */ + /* */ + /* FT_Outline_Flags */ + /* */ + /* */ + /* A simple type used to enumerates the flags in an outline's */ + /* "outline_flags" field. */ + /* */ + /* */ + /* ft_outline_owner :: */ + /* when set, this flag indicates that the outline's field arrays */ + /* (i.e. "points", "flags" & "contours") are "owned" by the */ + /* outline object, and should thus be freed when it is destroyed. */ + /* */ + /* ft_outline_even_odd_fill :: */ + /* by default, outlines are filled using the non-zero winding */ + /* rule. When set to 1, the outline will be filled using the */ + /* even-odd fill rule.. (XXX: unimplemented) */ + /* */ + /* ft_outline_reverse_fill :: */ + /* By default, outside contours of an outline are oriented in */ + /* clock-wise direction, as defined in the TrueType specification. */ + /* This flag is set when the outline uses the opposite direction, */ + /* (typically for Type 1 fonts). This flag is ignored by the */ + /* scan-converter. However, it is very important for the */ + /* auto-hinter.. */ + /* */ + /* ft_outline_ignore_dropouts :: */ + /* By default, the scan converter will try to detect drop-outs */ + /* in an outline and correct the glyph bitmap to ensure consistent */ + /* shape continuity. When set, this flag hints the scan-line */ + /* converter to ignore such cases. */ + /* */ + /* ft_outline_high_precision :: */ + /* this flag indicates that the scan-line converter should try */ + /* to convert this outline to bitmaps with the highest possible */ + /* quality. It is typically set for small character sizes. Note */ + /* that this is only a hint, that might be completely ignored */ + /* by a given scan-converter. */ + /* */ + /* ft_outline_single_pass :: */ + /* this flag is set to force a given scan-converter to only */ + /* use a single pass over the outline to render a bitmap glyph */ + /* image. Normally, it is set for very large character sizes. */ + /* It is only a hint, that might be completely ignored by a */ + /* given scan-converter. */ + /* */ + typedef enum FT_Outline_Flags_ + { + ft_outline_none = 0, + ft_outline_owner = 1, + ft_outline_even_odd_fill = 2, + ft_outline_reverse_fill = 4, + ft_outline_ignore_dropouts = 8, + ft_outline_high_precision = 256, + ft_outline_single_pass = 512 + + } FT_Outline_Flags; + + #define FT_CURVE_TAG( flag ) (flag & 3) diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 9e7f0b60b..9b06afc2e 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -2256,7 +2256,7 @@ static - const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 }; /*************************************************************************/ @@ -2314,14 +2314,14 @@ ALLOC_ARRAY( outline->contours, numContours, FT_UShort ) ) goto Fail; - outline->n_points = (FT_UShort)numPoints; - outline->n_contours = (FT_Short)numContours; - outline->owner = TRUE; + outline->n_points = (FT_UShort)numPoints; + outline->n_contours = (FT_Short)numContours; + outline->outline_flags |= ft_outline_owner; return FT_Err_Ok; Fail: - outline->owner = TRUE; + outline->outline_flags |= ft_outline_owner; FT_Done_Outline( library, outline ); return error; @@ -2366,7 +2366,7 @@ if ( outline ) { - if ( outline->owner ) + if ( outline->outline_flags & ft_outline_owner ) { FREE( outline->points ); FREE( outline->flags ); diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c index 20be50c34..222cf7b55 100644 --- a/src/base/ftoutln.c +++ b/src/base/ftoutln.c @@ -50,6 +50,8 @@ FT_Error FT_Copy_Outline( FT_Outline* source, FT_Outline* target ) { + FT_Int is_owner; + if ( !source || !target || source->n_points != target->n_points || source->n_contours != target->n_contours ) @@ -64,10 +66,12 @@ MEM_Copy( target->contours, source->contours, source->n_contours * sizeof ( FT_Short ) ); - target->high_precision = source->high_precision; - target->second_pass = target->second_pass; - target->dropout_mode = source->dropout_mode; - + /* copy all flags, except the "ft_outline_owner" one */ + is_owner = target->outline_flags & ft_outline_owner; + target->outline_flags = source->outline_flags; + + target->outline_flags &= ~ft_outline_owner; + target->outline_flags |= is_owner; return FT_Err_Ok; } diff --git a/src/base/ftraster.c b/src/base/ftraster.c index 99dcf353b..2a9c36c3b 100644 --- a/src/base/ftraster.c +++ b/src/base/ftraster.c @@ -4121,10 +4121,17 @@ Scan_DropOuts : ras.outline = outline; ras.target = *target_map; - + + /* Note that we always use drop-out mode 2, because it seems that */ + /* it's the only way to do to get results consistent with Windows */ + /* rendering.. */ +#if 0 ras.dropout_mode = outline->dropout_mode; - ras.second_pass = outline->second_pass; - SET_High_Precision( outline->high_precision ); +#else + ras.dropout_mode = 2; +#endif + ras.second_pass = (outline->outline_flags & ft_outline_single_pass) == 0; + SET_High_Precision( outline->outline_flags & ft_outline_high_precision ); switch ( target_map->pixel_mode ) { diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index cd96d3308..816dfe7dc 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -550,8 +550,8 @@ /* now load the glyph outline if necessary */ error = TT_Load_Glyph( size, slot, glyph_index, load_flags ); - /* force drop-out mode to 2 */ - slot->outline.dropout_mode = 2; + /* force drop-out mode to 2 - irrelevant now */ + /* slot->outline.dropout_mode = 2; */ return error; } diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 5e6624760..34888b460 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -968,7 +968,9 @@ glyph->outline.n_points = num_points; glyph->outline.n_contours = num_contours; - glyph->outline.second_pass = TRUE; + + /* glyph->outline.second_pass = TRUE; */ + glyph->outline.outline_flags &= ~ft_outline_single_pass; /* translate array so that (0,0) is the glyph's origin */ translate_array( (TT_UShort)(num_points + 2), @@ -1125,11 +1127,14 @@ glyph->metrics.horiAdvance = widths[glyph_index] << 6; } +/* drop-out mode is irrelevant, we always use mode 2 */ +#if 0 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER if (loader->exec) glyph->outline.dropout_mode = (TT_Char)loader->exec->GS.scan_type; #else glyph->outline.dropout_mode = 2; +#endif #endif /* set glyph dimensions */ @@ -1257,8 +1262,11 @@ } #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ - if (size) - glyph->outline.high_precision = ( size->root.metrics.y_ppem < 24 ); + /* clear all outline flags, except the "owner" one */ + glyph->outline.outline_flags &= ft_outline_owner; + + if (size && size->root.metrics.y_ppem < 24 ) + glyph->outline.outline_flags |= ft_outline_high_precision; /************************************************************************/ /* let's initialise the rest of our loader now */ diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index a24cfb92c..a125563e1 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -1537,9 +1537,16 @@ glyph->root.format = ft_glyph_format_outline; + glyph->root.outline.outline_flags &= ft_outline_owner; + + if ( size->root.metrics.y_ppem < 24 ) + glyph->root.outline.outline_flags |= ft_outline_high_precision; + + /* glyph->root.outline.second_pass = TRUE; glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 ); glyph->root.outline.dropout_mode = 2; + */ if ( hinting ) { diff --git a/src/type1z/t1gload.c b/src/type1z/t1gload.c index 54abf7d51..ea94980e2 100644 --- a/src/type1z/t1gload.c +++ b/src/type1z/t1gload.c @@ -1275,9 +1275,14 @@ glyph->root.format = ft_glyph_format_outline; + glyph->root.outline.outline_flags &= ft_outline_owner; + if ( size->root.metrics.y_ppem < 24 ) + glyph->root.outline.outline_flags |= ft_outline_high_precision; + /* glyph->root.outline.second_pass = TRUE; glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 ); glyph->root.outline.dropout_mode = 2; + */ if ( (load_flags & FT_LOAD_NO_SCALE) == 0 ) {