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..
This commit is contained in:
David Turner 2000-03-06 13:23:32 +00:00
parent 9d76a8d67a
commit 0f99ddda5f
10 changed files with 123 additions and 60 deletions

View File

@ -151,11 +151,11 @@
if ( error ) if ( error )
return error; return error;
glyph->outline.second_pass = 0; glyph->outline.outline_flags |= ft_outline_single_pass |
glyph->outline.dropout_mode = 0; ft_outline_ignore_dropouts;
if (force_low) if (force_low)
glyph->outline.high_precision = 0; glyph->outline.outline_flags &= ~ft_outline_high_precision;
/* debugging */ /* debugging */
#if 0 #if 0
@ -176,9 +176,9 @@
&outlines[cur_glyph] ); &outlines[cur_glyph] );
/* copy the glyph outline into it */ /* copy the glyph outline into it */
glyph->outline.second_pass = 0; glyph->outline.outline_flags |= ft_outline_single_pass;
if (force_low) if (force_low)
glyph->outline.high_precision = 0; glyph->outline.outline_flags &= ~ft_outline_high_precision;
FT_Copy_Outline( &glyph->outline, &outlines[cur_glyph] ); FT_Copy_Outline( &glyph->outline, &outlines[cur_glyph] );
@ -211,7 +211,7 @@
FT_Error ConvertRaster( int index ) 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 ); return FT_Get_Outline_Bitmap( library, &outlines[index], &Bit );
} }

View File

@ -181,7 +181,7 @@
memset( bit_buffer, 0, size ); memset( bit_buffer, 0, size );
if (low_prec) if (low_prec)
glyph->outline.high_precision = 0; glyph->outline.outline_flags &= ~ft_outline_high_precision;
FT_Get_Outline_Bitmap( library, &glyph->outline, &bit2 ); FT_Get_Outline_Bitmap( library, &glyph->outline, &bit2 );
} }

View File

@ -250,34 +250,10 @@
/* defined by the points `contours[0]+1' to */ /* defined by the points `contours[0]+1' to */
/* `contours[1]', etc. */ /* `contours[1]', etc. */
/* */ /* */
/* owner :: This flag is a boolean which is set whenever the */ /* outline_flags :: a set of bit flags used to characterize the */
/* outline structure/object owns the arrays it */ /* outline and give hints to the scan-converter */
/* refers to in the fields `points', `flags', and */ /* and hinter on how to convert/grid-fit it.. */
/* `contours'. */ /* see FT_Outline_Flags.. */
/* */
/* 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. */
/* */
/* */ /* */
typedef struct FT_Outline_ typedef struct FT_Outline_
{ {
@ -288,15 +264,71 @@
char* flags; /* the points flags */ char* flags; /* the points flags */
short* contours; /* the contour end points */ short* contours; /* the contour end points */
char owner; /* the outline owns the coordinates, */ int outline_flags; /* outline masks */
/* flags, and contours array it uses */
char high_precision; /* high precision rendering */
char second_pass; /* two sweeps rendering */
char dropout_mode; /* dropout mode */
} FT_Outline; } FT_Outline;
/*************************************************************************/
/* */
/* <Enum> */
/* FT_Outline_Flags */
/* */
/* <Description> */
/* A simple type used to enumerates the flags in an outline's */
/* "outline_flags" field. */
/* */
/* <Fields> */
/* 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) #define FT_CURVE_TAG( flag ) (flag & 3)

View File

@ -2256,7 +2256,7 @@
static 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 ) ) ALLOC_ARRAY( outline->contours, numContours, FT_UShort ) )
goto Fail; goto Fail;
outline->n_points = (FT_UShort)numPoints; outline->n_points = (FT_UShort)numPoints;
outline->n_contours = (FT_Short)numContours; outline->n_contours = (FT_Short)numContours;
outline->owner = TRUE; outline->outline_flags |= ft_outline_owner;
return FT_Err_Ok; return FT_Err_Ok;
Fail: Fail:
outline->owner = TRUE; outline->outline_flags |= ft_outline_owner;
FT_Done_Outline( library, outline ); FT_Done_Outline( library, outline );
return error; return error;
@ -2366,7 +2366,7 @@
if ( outline ) if ( outline )
{ {
if ( outline->owner ) if ( outline->outline_flags & ft_outline_owner )
{ {
FREE( outline->points ); FREE( outline->points );
FREE( outline->flags ); FREE( outline->flags );

View File

@ -50,6 +50,8 @@
FT_Error FT_Copy_Outline( FT_Outline* source, FT_Error FT_Copy_Outline( FT_Outline* source,
FT_Outline* target ) FT_Outline* target )
{ {
FT_Int is_owner;
if ( !source || !target || if ( !source || !target ||
source->n_points != target->n_points || source->n_points != target->n_points ||
source->n_contours != target->n_contours ) source->n_contours != target->n_contours )
@ -64,10 +66,12 @@
MEM_Copy( target->contours, source->contours, MEM_Copy( target->contours, source->contours,
source->n_contours * sizeof ( FT_Short ) ); source->n_contours * sizeof ( FT_Short ) );
target->high_precision = source->high_precision; /* copy all flags, except the "ft_outline_owner" one */
target->second_pass = target->second_pass; is_owner = target->outline_flags & ft_outline_owner;
target->dropout_mode = source->dropout_mode; target->outline_flags = source->outline_flags;
target->outline_flags &= ~ft_outline_owner;
target->outline_flags |= is_owner;
return FT_Err_Ok; return FT_Err_Ok;
} }

View File

@ -4121,10 +4121,17 @@ Scan_DropOuts :
ras.outline = outline; ras.outline = outline;
ras.target = *target_map; 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.dropout_mode = outline->dropout_mode;
ras.second_pass = outline->second_pass; #else
SET_High_Precision( outline->high_precision ); 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 ) switch ( target_map->pixel_mode )
{ {

View File

@ -550,8 +550,8 @@
/* now load the glyph outline if necessary */ /* now load the glyph outline if necessary */
error = TT_Load_Glyph( size, slot, glyph_index, load_flags ); error = TT_Load_Glyph( size, slot, glyph_index, load_flags );
/* force drop-out mode to 2 */ /* force drop-out mode to 2 - irrelevant now */
slot->outline.dropout_mode = 2; /* slot->outline.dropout_mode = 2; */
return error; return error;
} }

View File

@ -968,7 +968,9 @@
glyph->outline.n_points = num_points; glyph->outline.n_points = num_points;
glyph->outline.n_contours = num_contours; 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 so that (0,0) is the glyph's origin */
translate_array( (TT_UShort)(num_points + 2), translate_array( (TT_UShort)(num_points + 2),
@ -1125,11 +1127,14 @@
glyph->metrics.horiAdvance = widths[glyph_index] << 6; 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 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
if (loader->exec) if (loader->exec)
glyph->outline.dropout_mode = (TT_Char)loader->exec->GS.scan_type; glyph->outline.dropout_mode = (TT_Char)loader->exec->GS.scan_type;
#else #else
glyph->outline.dropout_mode = 2; glyph->outline.dropout_mode = 2;
#endif
#endif #endif
/* set glyph dimensions */ /* set glyph dimensions */
@ -1257,8 +1262,11 @@
} }
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
if (size) /* clear all outline flags, except the "owner" one */
glyph->outline.high_precision = ( size->root.metrics.y_ppem < 24 ); 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 */ /* let's initialise the rest of our loader now */

View File

@ -1537,9 +1537,16 @@
glyph->root.format = ft_glyph_format_outline; 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.second_pass = TRUE;
glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 ); glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 );
glyph->root.outline.dropout_mode = 2; glyph->root.outline.dropout_mode = 2;
*/
if ( hinting ) if ( hinting )
{ {

View File

@ -1275,9 +1275,14 @@
glyph->root.format = ft_glyph_format_outline; 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.second_pass = TRUE;
glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 ); glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 );
glyph->root.outline.dropout_mode = 2; glyph->root.outline.dropout_mode = 2;
*/
if ( (load_flags & FT_LOAD_NO_SCALE) == 0 ) if ( (load_flags & FT_LOAD_NO_SCALE) == 0 )
{ {