Formatting...

Applying some fixes from Tom.
This commit is contained in:
Werner Lemberg 2000-06-30 06:21:26 +00:00
parent 5ae831c101
commit cc9fc49c90
11 changed files with 171 additions and 131 deletions

View File

@ -682,6 +682,8 @@
if ( slot->flags & ft_glyph_own_bitmap )
{
FT_Memory memory = FT_FACE_MEMORY( slot->face );
FREE( slot->bitmap.buffer );
slot->flags &= ~ft_glyph_own_bitmap;
}
@ -958,31 +960,32 @@
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
/* do we need to load the glyph through the auto-hinter ?? */
/* do we need to load the glyph through the auto-hinter? */
library = driver->root.library;
hinter = library->auto_hinter;
autohint = hinter &&
!(load_flags & (FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING));
if (autohint)
!( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) );
if ( autohint )
{
if ( FT_DRIVER_HAS_HINTER( driver ) &&
!(load_flags & FT_LOAD_FORCE_AUTOHINT) )
autohint = 0;
}
!( load_flags & FT_LOAD_FORCE_AUTOHINT ) )
autohint = 0;
}
if (autohint)
if ( autohint )
{
FT_AutoHinter_Interface* hinting;
hinting = (FT_AutoHinter_Interface*)hinter->clazz->module_interface;
error = hinting->load_glyph( (FT_AutoHinter)hinter, slot, face->size,
error = hinting->load_glyph( (FT_AutoHinter)hinter, slot, face->size,
glyph_index, load_flags );
}
else
error = driver->clazz->load_glyph( slot,
face->size,
glyph_index,
load_flags );
glyph_index,
load_flags );
if ( error )
goto Exit;
@ -1013,15 +1016,17 @@
FT_Vector_Transform( &slot->advance, &face->transform_matrix );
}
/* do we need to render the image now ? */
/* do we need to render the image now? */
if ( !error &&
slot->format != ft_glyph_format_bitmap &&
slot->format != ft_glyph_format_composite &&
load_flags & FT_LOAD_RENDER )
load_flags & FT_LOAD_RENDER )
{
error = FT_Render_Glyph( slot, (load_flags & FT_LOAD_ANTI_ALIAS) ?
ft_render_mode_antialias : 0 );
}
error = FT_Render_Glyph( slot,
( load_flags & FT_LOAD_ANTI_ALIAS )
? ft_render_mode_antialias
: 0 );
}
Exit:
return error;
@ -2773,8 +2778,8 @@
goto Fail;
}
/* is the module a auto-hinter ? */
if ( FT_MODULE_IS_HINTER(module) )
/* is the module a auto-hinter? */
if ( FT_MODULE_IS_HINTER( module ) )
library->auto_hinter = module;
/* if the module is a font driver */

View File

@ -144,7 +144,6 @@
#undef PAIR_TAG
/*************************************************************************/
/* */
/* <Function> */
@ -203,6 +202,7 @@
/* force drop-out mode to 2 - irrelevant now */
/* slot->outline.dropout_mode = 2; */
return error;
}

View File

@ -413,7 +413,7 @@
}
/* check room for a new on-curve point, then add it */
/* check space for a new on-curve point, then add it */
static
FT_Error add_point1( T2_Builder* builder,
FT_Pos x,
@ -485,17 +485,17 @@
{
FT_Outline* outline = builder->current;
/* XXXX : we must not include the last point in the path if it */
/* is located on the first point.. */
if (outline->n_points > 1)
/* XXXX: We must not include the last point in the path if it */
/* is located on the first point. */
if ( outline->n_points > 1 )
{
FT_Int first = 0;
FT_Vector* p1 = outline->points + first;
FT_Vector* p2 = outline->points + outline->n_points-1;
FT_Vector* p2 = outline->points + outline->n_points - 1;
if (outline->n_contours > 1)
if ( outline->n_contours > 1 )
{
first = outline->contours[outline->n_contours-2]+1;
first = outline->contours[outline->n_contours - 2] + 1;
p1 = outline->points + first;
}
@ -508,9 +508,12 @@
}
#define USE_ARGS( n ) top -= n; \
if ( top < decoder->stack ) \
goto Stack_Underflow
#define USE_ARGS( n ) do \
{ \
top -= n; \
if ( top < decoder->stack ) \
goto Stack_Underflow; \
} while ( 0 )
/*************************************************************************/
@ -522,12 +525,12 @@
/* Parses a given Type 2 charstrings program. */
/* */
/* <InOut> */
/* decoder :: The current Type 1 decoder. */
/* decoder :: The current Type 1 decoder. */
/* */
/* <Input> */
/* charstring_base :: The base of the charstring stream. */
/* charstring_base :: The base of the charstring stream. */
/* */
/* charstring_len :: The length in bytes of the charstring stream. */
/* charstring_len :: The length in bytes of the charstring stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@ -537,15 +540,15 @@
FT_Byte* charstring_base,
FT_Int charstring_len )
{
FT_Error error;
T2_Decoder_Zone* zone;
FT_Byte* ip;
FT_Byte* limit;
T2_Builder* builder = &decoder->builder;
FT_Outline* outline;
FT_Pos x, y;
FT_Fixed seed;
FT_Fixed* stack;
FT_Error error;
T2_Decoder_Zone* zone;
FT_Byte* ip;
FT_Byte* limit;
T2_Builder* builder = &decoder->builder;
FT_Outline* outline;
FT_Pos x, y;
FT_Fixed seed;
FT_Fixed* stack;
/* set default width */
@ -611,7 +614,7 @@
{
if ( ip >= limit )
goto Syntax_Error;
val = (v - 247) * 256 + *ip++ + 108;
val = ( v - 247 ) * 256 + *ip++ + 108;
}
else if ( v < 255 )
{
@ -625,7 +628,8 @@
goto Syntax_Error;
val = ( (FT_Long)ip[0] << 24 ) |
( (FT_Long)ip[1] << 16 ) |
( (FT_Long)ip[2] << 8 ) | ip[3];
( (FT_Long)ip[2] << 8 ) |
ip[3];
ip += 4;
shift = 0;
}
@ -652,6 +656,7 @@
/* find operator */
op = t2_op_unknown;
switch ( v )
{
case 1:
@ -852,8 +857,8 @@
case t2_op_vstem:
case t2_op_hstemhm:
case t2_op_vstemhm:
/* if the number of arguments is no even, the first one */
/* is simply the glyph width.. encoded as the difference */
/* if the number of arguments is not even, the first one */
/* is simply the glyph width, encoded as the difference */
/* to nominalWidthX */
FT_TRACE4(( op == t2_op_hstem ? " hstem" :
op == t2_op_vstem ? " vstem" :
@ -865,8 +870,8 @@
case t2_op_hintmask:
case t2_op_cntrmask:
FT_TRACE4(( op == t2_op_hintmask ? " hintmask" :
" cntrmask" ));
FT_TRACE4(( op == t2_op_hintmask ? " hintmask"
: " cntrmask" ));
decoder->num_hints += num_args / 2;
ip += ( decoder->num_hints + 7 ) >> 3;
@ -930,8 +935,8 @@
FT_Int phase = ( op == t2_op_hlineto );
FT_TRACE4(( op == t2_op_hlineto ? " hlineto" :
" vlineto" ));
FT_TRACE4(( op == t2_op_hlineto ? " hlineto"
: " vlineto" ));
if ( start_point ( builder, x, y ) ||
check_points( builder, num_args ) )
@ -958,7 +963,7 @@
case t2_op_rrcurveto:
FT_TRACE4(( " rrcurveto" ));
/* check number of arguments, must be a multiple of 6 */
/* check number of arguments; must be a multiple of 6 */
if ( num_args % 6 != 0 )
goto Stack_Underflow;
@ -1057,8 +1062,8 @@
FT_Int phase;
FT_TRACE4(( op == t2_op_vhcurveto ? " vhcurveto" :
" hvcurveto" ));
FT_TRACE4(( op == t2_op_vhcurveto ? " vhcurveto"
: " hvcurveto" ));
if ( start_point ( builder, x, y ) )
goto Memory_Error;
@ -1071,6 +1076,7 @@
goto Stack_Underflow;
phase = ( op == t2_op_hvcurveto );
while ( num_args >= 4 )
{
num_args -= 4;
@ -1286,6 +1292,7 @@
case t2_op_drop:
/* nothing */
FT_TRACE4(( " drop" ));
break;
case t2_op_exch:
@ -1349,7 +1356,7 @@
}
else
{
while (index < 0)
while ( index < 0 )
{
FT_Fixed tmp = args[0];
FT_Int i;
@ -1379,6 +1386,7 @@
FT_TRACE4(( " put" ));
if ( index >= 0 && index < decoder->len_buildchar )
decoder->buildchar[index] = val;
}
@ -1406,7 +1414,7 @@
goto Unimplemented;
case t2_op_load:
FT_TRACE4(( " load" ));
FT_TRACE4(( " load" ));
goto Unimplemented;
@ -1469,7 +1477,8 @@
if ( index >= decoder->num_locals )
{
FT_ERROR(( "T2_Parse_Charstrings: invalid local subr index\n" ));
FT_ERROR(( "T2_Parse_CharStrings:" ));
FT_ERROR(( " invalid local subr index\n" ));
goto Syntax_Error;
}
@ -1482,9 +1491,9 @@
zone->cursor = ip; /* save current instruction pointer */
zone++;
zone->base = decoder->locals[index];
zone->limit = decoder->locals[index+1];
zone->cursor = zone->base;
zone->base = decoder->locals[index];
zone->limit = decoder->locals[index+1];
zone->cursor = zone->base;
if ( !zone->base )
{
@ -1508,7 +1517,8 @@
if ( index >= decoder->num_globals )
{
FT_ERROR(( "T2_Parse_Charstrings: invalid global subr index\n" ));
FT_ERROR(( "T2_Parse_CharStrings:" ));
FT_ERROR(( " invalid global subr index\n" ));
goto Syntax_Error;
}
@ -1559,6 +1569,7 @@
if ( ip[-1] == 12 )
FT_ERROR(( " %d", ip[0] ));
FT_ERROR(( "\n" ));
return T2_Err_Unimplemented_Feature;
}
@ -1693,9 +1704,9 @@
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
glyph->x_scale = 0x10000;
glyph->y_scale = 0x10000;
if (size)
glyph->x_scale = 0x10000L;
glyph->y_scale = 0x10000L;
if ( size )
{
glyph->x_scale = size->metrics.x_scale;
glyph->y_scale = size->metrics.y_scale;
@ -1717,7 +1728,7 @@
T2_Init_Decoder( &decoder, face, size, glyph );
decoder.builder.no_recurse =
(FT_Bool)( (load_flags & FT_LOAD_NO_RECURSE) != 0 );
(FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
/* now load the unscaled outline */
error = T2_Access_Element( &cff->charstrings_index, glyph_index,
@ -1734,13 +1745,13 @@
T2_Done_Builder( &decoder.builder );
}
/* Now, set the metrics - this is rather simple, as */
/* Now, set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax. */
if ( !error )
{
/* for composite glyphs, return only the left side bearing and the */
/* advance width.. */
/* for composite glyphs, return only left side bearing and */
/* advance width */
if ( glyph->root.format == ft_glyph_format_composite )
{
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
@ -1748,12 +1759,12 @@
}
else
{
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
/* copy the _unscaled_ advance width */
metrics->horiAdvance = decoder.glyph_width;
metrics->horiAdvance = decoder.glyph_width;
/* make up vertical metrics */
metrics->vertBearingX = 0;
@ -1795,8 +1806,8 @@
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, x_scale );
}
/* apply the font matrix */
#if 0
/* apply the font matrix */
FT_Outline_Transform( &glyph->root.outline, cff->font_matrix );
#endif
@ -1808,8 +1819,8 @@
{
cbox.xMin &= -64;
cbox.yMin &= -64;
cbox.xMax = ( cbox.xMax + 63 ) & -64;
cbox.yMax = ( cbox.yMax + 63 ) & -64;
cbox.xMax = ( cbox.xMax + 63 ) & -64;
cbox.yMax = ( cbox.yMax + 63 ) & -64;
}
metrics->width = cbox.xMax - cbox.xMin;

View File

@ -177,9 +177,8 @@
FT_Error T2_Compute_Max_Advance( TT_Face face,
FT_Int* max_advance );
#endif
#endif /* 0 */
/* This function is exported, because it is used by the T1Dump utility */
LOCAL_DEF
FT_Error T2_Parse_CharStrings( T2_Decoder* decoder,
FT_Byte* charstring_base,

View File

@ -46,7 +46,10 @@
for ( result = 0; off_size > 0; off_size-- )
result = ( result <<= 8 ) | *p++;
{
result <<= 8;
result |= *p++;
}
return result;
}
@ -66,7 +69,7 @@
index->stream = stream;
if ( !READ_UShort( count ) &&
count > 0 )
count > 0 )
{
FT_Byte* p;
FT_Byte offsize;
@ -74,7 +77,7 @@
FT_ULong* poff;
/* there is at least one element; read the offset size */
/* there is at least one element; read the offset size, */
/* then access the offset table to compute the index's total size */
if ( READ_Byte( offsize ) )
goto Exit;
@ -196,8 +199,8 @@
{
element++;
off2 = index->offsets[element];
}
while ( off2 == 0 && element < index->count );
} while ( off2 == 0 && element < index->count );
if ( !off2 )
off1 = 0;
@ -362,26 +365,22 @@
switch ( format )
{
case 0: /* format 0, that's simple */
{
select->data_size = num_glyphs;
goto Load_Data;
}
select->data_size = num_glyphs;
goto Load_Data;
case 3: /* format 3, a tad more complex */
{
if ( READ_UShort( num_ranges ) )
goto Exit;
if ( READ_UShort( num_ranges ) )
goto Exit;
select->data_size = num_ranges * 3 + 2;
select->data_size = num_ranges * 3 + 2;
Load_Data:
if ( EXTRACT_Frame( select->data_size, select->data ) )
goto Exit;
}
Load_Data:
if ( EXTRACT_Frame( select->data_size, select->data ) )
goto Exit;
break;
default: /* humm... that's wrong */
default: /* hmm... that's wrong */
error = FT_Err_Invalid_File_Format;
}
@ -439,6 +438,7 @@
break;
}
first = limit;
} while ( p < p_limit );
}
break;
@ -495,7 +495,7 @@
if ( error )
goto Exit;
/* if it's a CID font, we stop there */
/* if it is a CID font, we stop there */
if ( top->cid_registry )
goto Exit;

View File

@ -80,6 +80,7 @@
FT_Error error;
SFNT_Interface* sfnt;
sfnt = (SFNT_Interface*)FT_Get_Module_Interface(
face->root.driver->root.library, "sfnt" );
if ( !sfnt )
@ -94,7 +95,7 @@
if ( error )
goto Exit;
if ( face->format_tag != 0x4f54544fL ) /* OpenType/CFF font */
if ( face->format_tag != 0x4F54544FL ) /* `OTTO'; OpenType/CFF font */
{
FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
goto Bad_Format;
@ -109,7 +110,7 @@
if ( error )
goto Exit;
/* now, load the CFF part of the file.. */
/* now, load the CFF part of the file */
error = face->goto_table( face, TTAG_CFF, stream, 0 );
if ( error )
goto Exit;
@ -129,7 +130,7 @@
goto Exit;
/* Complement the root flags with some interesting information. */
/* note that for OpenType/CFF, there is no need to do this, but */
/* Note that for OpenType/CFF, there is no need to do this, but */
/* this will be necessary for pure CFF fonts through. */
root = &face->root;
}
@ -157,9 +158,9 @@
LOCAL_DEF
void T2_Done_Face( T2_Face face )
{
FT_Memory memory = face->root.memory;
FT_Memory memory = face->root.memory;
SFNT_Interface* sfnt = face->sfnt;
SFNT_Interface* sfnt = face->sfnt;
if ( sfnt )
sfnt->done_face( face );
@ -195,11 +196,17 @@
FT_Error T2_Init_Driver( T2_Driver driver )
{
/* init extension registry if needed */
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
return TT_Init_Extensions( driver );
#else
UNUSED( driver );
return T2_Err_Ok;
#endif
}
@ -219,10 +226,15 @@
void T2_Done_Driver( T2_Driver driver )
{
/* destroy extensions registry if needed */
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
TT_Done_Extensions( driver );
#else
UNUSED( driver );
#endif
}

View File

@ -95,9 +95,9 @@
/* */
typedef struct T2_DriverRec_
{
FT_DriverRec root;
FT_DriverRec root;
void* extension_component;
void* extension_component;
} T2_DriverRec;

View File

@ -102,7 +102,8 @@
val = ( (FT_Long)p[0] << 24 ) |
( (FT_Long)p[1] << 16 ) |
( (FT_Long)p[2] << 8 ) | p[3];
( (FT_Long)p[2] << 8 ) |
p[3];
p += 4;
}
else if ( v < 247 )
@ -135,7 +136,7 @@
}
/* reads a real */
/* read a real */
static
FT_Fixed parse_t2_real( FT_Byte* start,
FT_Byte* limit,
@ -258,7 +259,7 @@
}
/* reads a number, either integer or real */
/* read a number, either integer or real */
static
FT_Long t2_parse_num( FT_Byte** d )
{
@ -293,7 +294,7 @@
matrix->yx = t2_parse_fixed( data++ );
matrix->xy = t2_parse_fixed( data++ );
matrix->yy = t2_parse_fixed( data );
error = 0;
error = T2_Err_Ok;
}
return error;
@ -303,9 +304,9 @@
static
FT_Error parse_font_bbox( T2_Parser* parser )
{
CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object;
FT_BBox* bbox = &dict->font_bbox;
FT_Byte** data = parser->stack;
CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object;
FT_BBox* bbox = &dict->font_bbox;
FT_Byte** data = parser->stack;
FT_Error error;
@ -317,7 +318,7 @@
bbox->yMin = t2_parse_num( data++ );
bbox->xMax = t2_parse_num( data++ );
bbox->yMax = t2_parse_num( data );
error = 0;
error = T2_Err_Ok;
}
return error;
@ -338,7 +339,7 @@
{
dict->private_size = t2_parse_num( data++ );
dict->private_offset = t2_parse_num( data );
error = 0;
error = T2_Err_Ok;
}
return error;
@ -360,7 +361,7 @@
dict->cid_registry = (FT_UInt)t2_parse_num( data++ );
dict->cid_ordering = (FT_UInt)t2_parse_num( data++ );
dict->cid_supplement = (FT_ULong)t2_parse_num( data );
error = 0;
error = T2_Err_Ok;
}
return error;
@ -386,7 +387,8 @@
code | T2CODE, \
0, 0, \
parse_ ## name, \
0, 0 },
0, 0 \
},
#undef T2_FIELD
#define T2_FIELD( code, name, kind ) \
@ -426,7 +428,7 @@
FT_Byte* limit )
{
FT_Byte* p = start;
FT_Error error = 0;
FT_Error error = T2_Err_Ok;
parser->top = parser->stack;
@ -474,7 +476,7 @@
}
else
{
/* this is not a number, hence it's an operator. Compute its code */
/* This is not a number, hence it's an operator. Compute its code */
/* and look for it in our current list. */
FT_UInt code;
@ -551,11 +553,11 @@
case t2_kind_delta:
{
FT_Byte* qcount = (FT_Byte*)parser->object +
field->count_offset;
FT_Byte* qcount = (FT_Byte*)parser->object +
field->count_offset;
FT_Long val;
FT_Byte** data = parser->stack;
FT_Long val;
FT_Byte** data = parser->stack;
if ( num_args > field->array_max )
@ -576,6 +578,12 @@
case 2:
*(FT_Short*)q = (FT_Short)val;
break;
#if SIZEOF_INT == 4
case 4:
*(FT_Int*)q = (FT_Int)val;
break;
#endif
default:
*(FT_Long*)q = val;
}

View File

@ -335,17 +335,18 @@
{
FT_Outline* outline = builder->current;
/* XXXX : we must not include the last point in the path if it */
/* is located on the first point.. */
if (outline->n_points > 1)
/* XXXX: We must not include the last point in the path if it */
/* is located on the first point. */
if ( outline->n_points > 1 )
{
FT_Int first = 0;
FT_Vector* p1 = outline->points + first;
FT_Vector* p2 = outline->points + outline->n_points-1;
FT_Vector* p2 = outline->points + outline->n_points - 1;
if (outline->n_contours > 1)
if ( outline->n_contours > 1 )
{
first = outline->contours[outline->n_contours-2]+1;
first = outline->contours[outline->n_contours - 2] + 1;
p1 = outline->points + first;
}
@ -1121,7 +1122,10 @@
FT_TRACE4(( " div" ));
if ( top[1] )
*top++ = top[0] / top[1];
{
*top = top[0] / top[1];
top++;
}
else
{
FT_ERROR(( "CID_Parse_CharStrings: division by 0\n" ));

View File

@ -276,7 +276,7 @@
if ( LOAD_( hdmx ) ||
LOAD_( gasp ) ||
LOAD_( kerning ) ||
LOAD_( pclt ) )
LOAD_( pclt ) )
goto Exit;
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE

View File

@ -1236,17 +1236,18 @@
{
FT_Outline* cur = builder->current;
/* XXXX : we must not include the last point in the path if it */
/* is located on the first point.. */
if (cur->n_points > 1)
/* XXXX: We must not include the last point in the path if it */
/* is located on the first point. */
if ( cur->n_points > 1 )
{
FT_Int first = 0;
FT_Vector* p1 = cur->points + first;
FT_Vector* p2 = cur->points + cur->n_points-1;
FT_Vector* p2 = cur->points + cur->n_points - 1;
if (cur->n_contours > 1)
if ( cur->n_contours > 1 )
{
first = cur->contours[cur->n_contours-2]+1;
first = cur->contours[cur->n_contours - 2] + 1;
p1 = cur->points + first;
}
@ -1259,7 +1260,7 @@
cur->contours[cur->n_contours - 1] = cur->n_points - 1;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
/* hint latest points if needed - this is not strictly required */
/* hint latest points if needed -- this is not strictly required */
/* there, but it helps for debugging, and doesn't affect performance */
if ( builder->pass == 1 )
T1_Hint_Points( builder );