summaryrefslogtreecommitdiff
path: root/src/sfnt/ttsbit0.c
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2005-03-01 02:13:50 +0000
committerWerner Lemberg <wl@gnu.org>2005-03-01 02:13:50 +0000
commite793092d0a9f4d4d383315bcefd485dcbe4804b3 (patch)
treeeb8ca59af95da475b0985b803340d36ef73dd8de /src/sfnt/ttsbit0.c
parent7305f62767eacd6b58d1c6d5dcf8eda1b209c457 (diff)
downloadfreetype2-e793092d0a9f4d4d383315bcefd485dcbe4804b3.tar.gz
Formatting.
* src/truetype/ttpload.c (tt_face_load_loca): Fix typo. * src/sfnt/ttkern.c: Include `ttkern.h'. (FT_COMPONENT): Updated. * include/freetype/internal/fttrace.h: Add entry for `ttkern'. * src/sfnt/ttsbit0.c: s/FT_Err_/SFNT_Err_/. Decorate constants with `U' and `L' where necessary. * src/sfnt/ttcmap.c (tt_cmap4_next): Remove unused variable.
Diffstat (limited to 'src/sfnt/ttsbit0.c')
-rw-r--r--src/sfnt/ttsbit0.c472
1 files changed, 246 insertions, 226 deletions
diff --git a/src/sfnt/ttsbit0.c b/src/sfnt/ttsbit0.c
index 2f7095c5e..74bb7892a 100644
--- a/src/sfnt/ttsbit0.c
+++ b/src/sfnt/ttsbit0.c
@@ -1,10 +1,11 @@
/***************************************************************************/
/* */
-/* ttsbit.c */
+/* ttsbit0.c */
/* */
/* TrueType and OpenType embedded bitmap support (body). */
+/* This is a heap-optimized version. */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004 by */
+/* Copyright 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -84,12 +85,11 @@
};
-
FT_LOCAL_DEF( FT_Error )
tt_face_load_sbit_strikes( TT_Face face,
FT_Stream stream )
{
- FT_Error error = 0;
+ FT_Error error = SFNT_Err_Ok;
FT_Memory memory = stream->memory;
FT_Fixed version;
FT_ULong num_strikes, table_size;
@@ -98,6 +98,7 @@
FT_Byte* p_limit;
FT_UInt nn, count;
+
face->sbit_num_strikes = 0;
/* this table is optional */
@@ -109,7 +110,7 @@
if ( table_size < 8 )
{
- FT_ERROR(( "%s: table too short !\n", "tt_face_load_sbit_strikes" ));
+ FT_ERROR(( "%s: table too short!\n", "tt_face_load_sbit_strikes" ));
error = SFNT_Err_Invalid_File_Format;
goto Exit;
}
@@ -122,30 +123,32 @@
p = face->sbit_table;
p_limit = p + table_size;
- version = FT_NEXT_ULONG(p);
- num_strikes = FT_NEXT_ULONG(p);
+ version = FT_NEXT_ULONG( p );
+ num_strikes = FT_NEXT_ULONG( p );
- if ( version != 0x00020000 || num_strikes >= 0x10000UL )
+ if ( version != 0x00020000UL || num_strikes >= 0x10000UL )
{
- FT_ERROR(( "%s: invalid table version !\n", "tt_face_load_sbit_strikes" ));
+ FT_ERROR(( "%s: invalid table version!\n",
+ "tt_face_load_sbit_strikes" ));
error = SFNT_Err_Invalid_File_Format;
goto Fail;
}
- /* count the number of strikes available in the table. we're a bit
- * paranoid there and don't trust the data.
- */
+ /*
+ * Count the number of strikes available in the table. We are a bit
+ * paranoid there and don't trust the data.
+ */
count = (FT_UInt)num_strikes;
- if ( 8+48UL*count > table_size )
- count = (FT_UInt)( (p_limit - p)/48 );
+ if ( 8 +48UL * count > table_size )
+ count = (FT_UInt)( ( p_limit - p ) / 48 );
face->sbit_num_strikes = count;
- /* now allocate the root array of F_Bitmap_Size records,
- * populate them, and that's all there is to it. Unfortunately,
- * it's not possible to indicate bit depths in the FT_Bitmap_Size
- * record. What were we thinking ?
- */
+ /*
+ * Now allocate the root array of FT_Bitmap_Size records and
+ * populate them. Unfortunately, it isn't possible to indicate bit
+ * depths in the FT_Bitmap_Size record. This is a design error.
+ */
{
FT_Memory memory = face->root.stream->memory;
FT_UInt em_size = (FT_UInt) face->header.Units_Per_EM;
@@ -155,6 +158,7 @@
FT_Short avgwidth = face->os2.xAvgCharWidth;
+
if ( FT_NEW_ARRAY( face->root.available_sizes, count ) )
goto Fail;
@@ -163,14 +167,15 @@
FT_Bitmap_Size* bsize = face->root.available_sizes + nn;
FT_UInt x_ppem, y_ppem;
+
x_ppem = p[44];
y_ppem = p[45];
bsize->x_ppem = (FT_Pos)(x_ppem << 6);
bsize->y_ppem = (FT_Pos)(y_ppem << 6);
- bsize->height = (FT_Short)( height*y_ppem + em_size/2 ) / em_size;
- bsize->width = (FT_Short)( avgwidth*y_ppem + em_size/2 ) / em_size;
+ bsize->height = (FT_Short)( height*y_ppem + em_size / 2 ) / em_size;
+ bsize->width = (FT_Short)( avgwidth*y_ppem + em_size / 2 ) / em_size;
bsize->size = bsize->y_ppem;
p += 48;
@@ -178,7 +183,6 @@
face->root.face_flags |= FT_FACE_FLAG_FIXED_SIZES;
face->root.num_fixed_sizes = count;
-
}
Exit:
@@ -196,6 +200,7 @@
{
FT_Stream stream = face->root.stream;
+
FT_FRAME_RELEASE( face->sbit_table );
face->sbit_table_size = 0;
face->sbit_num_strikes = 0;
@@ -212,13 +217,15 @@
FT_Byte* p;
FT_Byte* p_limit;
- if ( x_ppem > 255 ||
+
+ if ( x_ppem > 255 ||
y_ppem < 1 || y_ppem > 255 )
return SFNT_Err_Invalid_PPem;
p = face->sbit_table + 8;
p_limit = p + face->sbit_table_size;
count = face->sbit_num_strikes;
+
for ( nn = 0; nn < count; nn++ )
{
if ( x_ppem == (FT_UInt)p[44] && y_ppem == (FT_UInt)p[45] )
@@ -233,7 +240,6 @@
}
-
typedef struct
{
TT_Face face;
@@ -265,16 +271,17 @@
FT_Stream stream = face->root.stream;
FT_ULong ebdt_size;
+
error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
if ( error )
error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
- if (error)
+ if ( error )
goto Exit;
- decoder->face = face;
- decoder->stream = stream;
- decoder->bitmap = &face->root.glyph->bitmap;
- decoder->metrics = metrics;
+ decoder->face = face;
+ decoder->stream = stream;
+ decoder->bitmap = &face->root.glyph->bitmap;
+ decoder->metrics = metrics;
decoder->metrics_loaded = 0;
decoder->bitmap_allocated = 0;
@@ -285,14 +292,14 @@
decoder->eblc_base = face->sbit_table;
decoder->eblc_limit = face->sbit_table + face->sbit_table_size;
- /* now find the strike corresponding to the index
- */
+ /* now find the strike corresponding to the index */
{
- FT_Byte* p = decoder->eblc_base + 8 + 48*strike_index;
+ FT_Byte* p = decoder->eblc_base + 8 + 48 * strike_index;
+
- decoder->strike_index_array = FT_NEXT_ULONG(p);
+ decoder->strike_index_array = FT_NEXT_ULONG( p );
p += 4;
- decoder->strike_index_count = FT_NEXT_ULONG(p);
+ decoder->strike_index_count = FT_NEXT_ULONG( p );
p += 34;
decoder->bit_depth = *p;
}
@@ -305,52 +312,52 @@
static void
tt_sbit_decoder_done( TT_SBitDecoder decoder )
{
- FT_UNUSED(decoder);
+ FT_UNUSED( decoder );
}
-
static FT_Error
tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder )
{
- FT_Error error = 0;
+ FT_Error error = SFNT_Err_Ok;
FT_UInt width, height;
FT_Bitmap* map = decoder->bitmap;
FT_Long size;
+
if ( !decoder->metrics_loaded )
{
- error = FT_Err_Invalid_Argument;
+ error = SFNT_Err_Invalid_Argument;
goto Exit;
}
width = decoder->metrics->width;
height = decoder->metrics->height;
- map->width = (int) width;
- map->rows = (int) height;
+ map->width = (int)width;
+ map->rows = (int)height;
switch ( decoder->bit_depth )
{
case 1:
- map->pixel_mode = FT_PIXEL_MODE_MONO;
- map->pitch = ( map->width + 7 ) >> 3;
- break;
+ map->pixel_mode = FT_PIXEL_MODE_MONO;
+ map->pitch = ( map->width + 7 ) >> 3;
+ break;
case 2:
- map->pixel_mode = FT_PIXEL_MODE_GRAY2;
- map->pitch = ( map->width + 3 ) >> 2;
- break;
+ map->pixel_mode = FT_PIXEL_MODE_GRAY2;
+ map->pitch = ( map->width + 3 ) >> 2;
+ break;
case 4:
- map->pixel_mode = FT_PIXEL_MODE_GRAY4;
- map->pitch = ( map->width + 1 ) >> 1;
- break;
+ map->pixel_mode = FT_PIXEL_MODE_GRAY4;
+ map->pitch = ( map->width + 1 ) >> 1;
+ break;
case 8:
- map->pixel_mode = FT_PIXEL_MODE_GRAY;
- map->pitch = map->width;
- break;
+ map->pixel_mode = FT_PIXEL_MODE_GRAY;
+ map->pitch = map->width;
+ break;
default:
error = SFNT_Err_Invalid_File_Format;
@@ -364,7 +371,7 @@
goto Exit; /* exit successfully! */
error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size );
- if (error)
+ if ( error )
goto Exit;
decoder->bitmap_allocated = 1;
@@ -383,28 +390,29 @@
FT_Byte* p = *pp;
TT_SBit_Metrics metrics = decoder->metrics;
- if ( p+5 > limit )
+
+ if ( p + 5 > limit )
goto Fail;
if ( !decoder->metrics_loaded )
{
metrics->height = p[0];
metrics->width = p[1];
- metrics->horiBearingX = (FT_Char) p[2];
- metrics->horiBearingY = (FT_Char) p[3];
+ metrics->horiBearingX = (FT_Char)p[2];
+ metrics->horiBearingY = (FT_Char)p[3];
metrics->horiAdvance = p[4];
}
p += 5;
if ( big )
{
- if ( p+3 > limit )
+ if ( p + 3 > limit )
goto Fail;
if ( !decoder->metrics_loaded )
{
- metrics->vertBearingX = (FT_Char) p[0];
- metrics->vertBearingY = (FT_Char) p[1];
+ metrics->vertBearingX = (FT_Char)p[0];
+ metrics->vertBearingY = (FT_Char)p[1];
metrics->vertAdvance = p[2];
}
@@ -416,14 +424,11 @@
return 0;
Fail:
- return FT_Err_Invalid_Argument;
+ return SFNT_Err_Invalid_Argument;
}
-
-
-
- /* forward declaration */
+ /* forward declaration */
static FT_Error
tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
FT_UInt glyph_index,
@@ -437,8 +442,6 @@
FT_Int y_pos );
-
-
static FT_Error
tt_sbit_decoder_load_byte_aligned( TT_SBitDecoder decoder,
FT_Byte* p,
@@ -446,21 +449,21 @@
FT_Int x_pos,
FT_Int y_pos )
{
- FT_Error error = 0;
+ FT_Error error = SFNT_Err_Ok;
FT_Byte* line;
FT_Int bit_height, bit_width, pitch, width, height, h;
FT_Bitmap* bitmap;
FT_UInt rval;
+
if ( !decoder->bitmap_allocated )
{
error = tt_sbit_decoder_alloc_bitmap( decoder );
- if (error)
+ if ( error )
goto Exit;
}
- /* check that we can write the glyph into the bitmap
- */
+ /* check that we can write the glyph into the bitmap */
bitmap = decoder->bitmap;
bit_width = bitmap->width;
bit_height = bitmap->rows;
@@ -469,22 +472,21 @@
width = decoder->metrics->width;
height = decoder->metrics->height;
- if ( x_pos < 0 || x_pos+width > bit_width ||
- y_pos < 0 || y_pos+height > bit_height )
+ if ( x_pos < 0 || x_pos + width > bit_width ||
+ y_pos < 0 || y_pos + height > bit_height )
{
- error = FT_Err_Invalid_File_Format;
+ error = SFNT_Err_Invalid_File_Format;
goto Exit;
}
- if ( p+((width+7)>>3)*height > limit )
+ if ( p + ( ( width + 7 ) >> 3 ) * height > limit )
{
- error = FT_Err_Invalid_File_Format;
+ error = SFNT_Err_Invalid_File_Format;
goto Exit;
}
- /* now do the blit
- */
- line += y_pos*pitch + (x_pos >> 3);
+ /* now do the blit */
+ line += y_pos * pitch + ( x_pos >> 3 );
x_pos &= 7;
if ( x_pos == 0 ) /* the easy one */
@@ -494,14 +496,15 @@
FT_Byte* write = line;
FT_Int w;
+
for ( w = width; w >= 8; w -= 8 )
{
- write[0] = (FT_Byte)(write[0] | *p++);
+ write[0] = (FT_Byte)( write[0] | *p++ );
write += 1;
}
if ( w > 0 )
- write[0] = (FT_Byte)(write[0] | (*p++ & (0xFF00 >> w)));
+ write[0] = (FT_Byte)( write[0] | ( *p++ & ( 0xFF00U >> w ) ) );
}
}
else /* x_pos > 0 */
@@ -512,18 +515,19 @@
FT_Int w;
FT_UInt wval = 0;
+
for ( w = width; w >= 8; w -= 8 )
{
- wval = (FT_UInt)(wval | *p++);
- write[0] = (FT_Byte)(write[0] | (wval >> x_pos));
+ wval = (FT_UInt)( wval | *p++ );
+ write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
write += 1;
wval <<= 8;
}
if ( w > 0 )
- wval = (FT_UInt)(wval | (*p++ & (0xFF00 >> w)));
+ wval = (FT_UInt)(wval | ( *p++ & ( 0xFF00U >> w ) ) );
- write[0] = (FT_Byte)(write[0] | (wval >> x_pos));
+ write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
}
}
@@ -539,21 +543,21 @@
FT_Int x_pos,
FT_Int y_pos )
{
- FT_Error error = 0;
+ FT_Error error = SFNT_Err_Ok;
FT_Byte* line;
FT_Int bit_height, bit_width, pitch, width, height, h;
FT_Bitmap* bitmap;
FT_UInt32 rval;
+
if ( !decoder->bitmap_allocated )
{
error = tt_sbit_decoder_alloc_bitmap( decoder );
- if (error)
+ if ( error )
goto Exit;
}
- /* check that we can write the glyph into the bitmap
- */
+ /* check that we can write the glyph into the bitmap */
bitmap = decoder->bitmap;
bit_width = bitmap->width;
bit_height = bitmap->rows;
@@ -562,24 +566,23 @@
width = decoder->metrics->width;
height = decoder->metrics->height;
- if ( x_pos < 0 || x_pos+width > bit_width ||
- y_pos < 0 || y_pos+height > bit_height )
+ if ( x_pos < 0 || x_pos + width > bit_width ||
+ y_pos < 0 || y_pos + height > bit_height )
{
- error = FT_Err_Invalid_File_Format;
+ error = SFNT_Err_Invalid_File_Format;
goto Exit;
}
- if ( p+((width+7)>>3)*height > limit )
+ if ( p + ( ( width + 7 ) >> 3 ) * height > limit )
{
- error = FT_Err_Invalid_File_Format;
+ error = SFNT_Err_Invalid_File_Format;
goto Exit;
}
- /* now do the blit
- */
- line += y_pos*pitch + (x_pos >> 3);
+ /* now do the blit */
+ line += y_pos * pitch + ( x_pos >> 3 );
x_pos &= 7;
- rval = 0x10000;
+ rval = 0x10000UL;
for ( h = height; h > 0; h--, line += pitch )
{
@@ -587,19 +590,20 @@
FT_UInt32 wval = 0x100 << x_pos;
FT_Int w;
+
for ( w = width; w >= 8; w -= 8 )
{
- if ( rval & 0x10000 )
+ if ( rval & 0x10000UL )
rval = 0x100 | *p++;
- wval |= (rval & 0x80);
+ wval |= rval & 0x80;
wval <<= 1;
rval <<= 1;
- if ( wval & 0x10000 )
+ if ( wval & 0x10000UL )
{
- write[0] = (FT_Byte)(write[0] | (wval >> 8));
+ write[0] = (FT_Byte)( write[0] | ( wval >> 8 ) );
write += 1;
wval = 0x100;
}
@@ -610,7 +614,7 @@
while ( wval > 0x1FF )
wval >>= 1;
- write[0] = (FT_Byte)(write[0] | wval);
+ write[0] = (FT_Byte)( write[0] | wval );
}
}
@@ -630,21 +634,23 @@
FT_UInt num_components, nn;
- if ( p+2 > limit )
+ if ( p + 2 > limit )
goto Fail;
- num_components = FT_NEXT_USHORT(p);
- if ( p+4*num_components > limit )
+ num_components = FT_NEXT_USHORT( p );
+ if ( p + 4 * num_components > limit )
goto Fail;
for ( nn = 0; nn < num_components; nn++ )
{
- FT_UInt gindex = FT_NEXT_USHORT(p);
- FT_Byte dx = FT_NEXT_BYTE(p);
- FT_Byte dy = FT_NEXT_BYTE(p);
+ FT_UInt gindex = FT_NEXT_USHORT( p );
+ FT_Byte dx = FT_NEXT_BYTE( p );
+ FT_Byte dy = FT_NEXT_BYTE( p );
+
/* NB: a recursive call */
- error = tt_sbit_decoder_load_image( decoder, gindex, x_pos+dx, y_pos+dy );
+ error = tt_sbit_decoder_load_image( decoder, gindex,
+ x_pos + dx, y_pos + dy );
if ( error )
break;
}
@@ -653,7 +659,7 @@
return error;
Fail:
- error = FT_Err_Invalid_File_Format;
+ error = SFNT_Err_Invalid_File_Format;
goto Exit;
}
@@ -672,35 +678,38 @@
FT_Byte* p_limit;
FT_Byte* data;
- /* seek into the EBDT table now
- */
+
+ /* seek into the EBDT table now */
if ( glyph_start + glyph_size > decoder->ebdt_size )
{
- error = FT_Err_Invalid_Argument;
+ error = SFNT_Err_Invalid_Argument;
goto Exit;
}
if ( FT_STREAM_SEEK( decoder->ebdt_start + glyph_start ) ||
- FT_FRAME_EXTRACT( glyph_size, data ) )
+ FT_FRAME_EXTRACT( glyph_size, data ) )
goto Exit;
p = data;
p_limit = p + glyph_size;
- /* read the data, depending on the glyph format
- */
+ /* read the data, depending on the glyph format */
switch ( glyph_format )
{
- case 1: case 2: case 8:
+ case 1:
+ case 2:
+ case 8:
error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 0 );
break;
- case 6: case 7: case 9:
+ case 6:
+ case 7:
+ case 9:
error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 );
break;
default:
- error = 0;
+ error = SFNT_Err_Ok;
}
if ( error )
@@ -709,29 +718,33 @@
{
TT_SBitDecoder_LoadFunc loader;
+
switch ( glyph_format )
{
- case 1: case 6:
- loader = tt_sbit_decoder_load_byte_aligned;
- break;
+ case 1:
+ case 6:
+ loader = tt_sbit_decoder_load_byte_aligned;
+ break;
- case 2: case 5: case 7:
- loader = tt_sbit_decoder_load_bit_aligned;
- break;
+ case 2:
+ case 5:
+ case 7:
+ loader = tt_sbit_decoder_load_bit_aligned;
+ break;
case 8:
- if ( p+1 > p_limit )
- goto Fail;
+ if ( p + 1 > p_limit )
+ goto Fail;
- p += 1; /* skip padding */
- /* fall-through */
+ p += 1; /* skip padding */
+ /* fall-through */
case 9:
- loader = tt_sbit_decoder_load_compound;
- break;
+ loader = tt_sbit_decoder_load_compound;
+ break;
default:
- goto Fail;
+ goto Fail;
}
error = loader( decoder, p, p_limit, x_pos, y_pos );
@@ -751,22 +764,25 @@
FT_Int x_pos,
FT_Int y_pos )
{
- /* first, we find the correct strike range that applies to this
- * glyph index.
- */
+ /*
+ * First, we find the correct strike range that applies to this
+ * glyph index.
+ */
+
FT_Byte* p = decoder->eblc_base + decoder->strike_index_array;
FT_Byte* p_limit = decoder->eblc_limit;
FT_ULong num_ranges = decoder->strike_index_count;
FT_UInt start, end, offset, index_format, image_format;
FT_ULong image_start, image_end, image_offset;
- if ( p+8*num_ranges > p_limit )
+
+ if ( p + 8 * num_ranges > p_limit )
goto NoBitmap;
for ( ; num_ranges > 0; num_ranges-- )
{
- start = FT_NEXT_USHORT(p);
- end = FT_NEXT_USHORT(p);
+ start = FT_NEXT_USHORT( p );
+ end = FT_NEXT_USHORT( p );
if ( glyph_index >= start && glyph_index <= end )
goto FoundRange;
@@ -776,128 +792,131 @@
goto NoBitmap;
FoundRange:
- p = decoder->eblc_base + decoder->strike_index_array + FT_NEXT_ULONG(p);
- if ( p+8 > p_limit )
+ p = decoder->eblc_base + decoder->strike_index_array + FT_NEXT_ULONG( p );
+ if ( p + 8 > p_limit )
goto NoBitmap;
- /* now, we're going to find the glyph's location and extend within
- * the ebdt table
- */
- index_format = FT_NEXT_USHORT(p);
- image_format = FT_NEXT_USHORT(p);
- image_offset = FT_NEXT_ULONG(p);
+ /* now find the glyph's location and extend within the ebdt table */
+ index_format = FT_NEXT_USHORT( p );
+ image_format = FT_NEXT_USHORT( p );
+ image_offset = FT_NEXT_ULONG ( p );
switch ( index_format )
{
- case 1: /* 4-byte offsets relative to 'image_offset' */
- {
- p += 4*(glyph_index-start);
- if ( p+8 > p_limit )
- goto NoBitmap;
+ case 1: /* 4-byte offsets relative to `image_offset' */
+ {
+ p += 4 * ( glyph_index - start );
+ if ( p + 8 > p_limit )
+ goto NoBitmap;
- image_start = FT_NEXT_ULONG(p);
- image_end = FT_NEXT_ULONG(p);
+ image_start = FT_NEXT_ULONG( p );
+ image_end = FT_NEXT_ULONG( p );
- if ( image_start == image_end ) /* missing glyph */
- goto NoBitmap;
- }
- break;
+ if ( image_start == image_end ) /* missing glyph */
+ goto NoBitmap;
+ }
+ break;
case 2: /* big metrics, constant image size */
- {
- FT_ULong image_size;
+ {
+ FT_ULong image_size;
- if ( p+12 > p_limit )
- goto NoBitmap;
- image_size = FT_NEXT_ULONG(p);
+ if ( p + 12 > p_limit )
+ goto NoBitmap;
- if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
- goto NoBitmap;
+ image_size = FT_NEXT_ULONG( p );
- image_start = image_offset + image_size*(glyph_index-start);
- image_end = image_start + image_size;
- }
- break;
+ if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
+ goto NoBitmap;
+
+ image_start = image_offset + image_size * ( glyph_index - start );
+ image_end = image_start + image_size;
+ }
+ break;
case 3: /* 2-byte offsets relative to 'image_offset' */
- {
- p += 2*(glyph_index-start);
- if ( p+4 > p_limit )
- goto NoBitmap;
+ {
+ p += 2 * ( glyph_index - start );
+ if ( p + 4 > p_limit )
+ goto NoBitmap;
- image_start = FT_NEXT_USHORT(p);
- image_end = FT_NEXT_USHORT(p);
+ image_start = FT_NEXT_USHORT( p );
+ image_end = FT_NEXT_USHORT( p );
- if ( image_start == image_end ) /* missing glyph */
- goto NoBitmap;
- }
- break;
+ if ( image_start == image_end ) /* missing glyph */
+ goto NoBitmap;
+ }
+ break;
case 4: /* sparse glyph array with (glyph,offset) pairs */
- {
- FT_ULong mm, num_glyphs;
+ {
+ FT_ULong mm, num_glyphs;
+
- if ( p+4 > p_limit )
- goto NoBitmap;
+ if ( p + 4 > p_limit )
+ goto NoBitmap;
- num_glyphs = FT_NEXT_ULONG(p);
- if ( p+(num_glyphs+1)*4 > p_limit )
- goto NoBitmap;
+ num_glyphs = FT_NEXT_ULONG( p );
+ if ( p + ( num_glyphs + 1 ) * 4 > p_limit )
+ goto NoBitmap;
- for ( mm = 0; mm < num_glyphs; mm++ )
+ for ( mm = 0; mm < num_glyphs; mm++ )
+ {
+ FT_UInt gindex = FT_NEXT_USHORT( p );
+
+
+ if ( gindex == glyph_index )
{
- FT_UInt gindex = FT_NEXT_USHORT(p);
-
- if ( gindex == glyph_index )
- {
- image_start = FT_NEXT_USHORT(p);
- p += 2;
- image_end = FT_PEEK_USHORT(p);
- break;
- }
- p += 2;
+ image_start = FT_NEXT_USHORT( p );
+ p += 2;
+ image_end = FT_PEEK_USHORT( p );
+ break;
}
-
- if ( mm >= num_glyphs )
- goto NoBitmap;
+ p += 2;
}
- break;
+
+ if ( mm >= num_glyphs )
+ goto NoBitmap;
+ }
+ break;
case 5: /* constant metrics with sparse glyph codes */
- {
- FT_ULong image_size, mm, num_glyphs;
+ {
+ FT_ULong image_size, mm, num_glyphs;
- if ( p+16 > p_limit )
- goto NoBitmap;
- image_size = FT_NEXT_ULONG(p);
+ if ( p + 16 > p_limit )
+ goto NoBitmap;
- if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
- goto NoBitmap;
+ image_size = FT_NEXT_ULONG( p );
- num_glyphs = FT_NEXT_ULONG(p);
- if ( p + 2*num_glyphs > p_limit )
- goto NoBitmap;
+ if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
+ goto NoBitmap;
- for ( mm = 0; mm < num_glyphs; mm++ )
- {
- FT_UInt gindex = FT_NEXT_USHORT(p);
+ num_glyphs = FT_NEXT_ULONG( p );
+ if ( p + 2 * num_glyphs > p_limit )
+ goto NoBitmap;
- if ( gindex == glyph_index )
- break;
- }
+ for ( mm = 0; mm < num_glyphs; mm++ )
+ {
+ FT_UInt gindex = FT_NEXT_USHORT( p );
- if ( mm >= num_glyphs )
- goto NoBitmap;
- image_start = image_offset + image_size*mm;
- image_end = image_start + image_size;
+ if ( gindex == glyph_index )
+ break;
}
- break;
+
+ if ( mm >= num_glyphs )
+ goto NoBitmap;
+
+ image_start = image_offset + image_size*mm;
+ image_end = image_start + image_size;
+ }
+ break;
default:
- goto NoBitmap;
+ goto NoBitmap;
}
if ( image_start > image_end )
@@ -906,20 +925,18 @@
image_end -= image_start;
image_start = image_offset + image_start;
-
return tt_sbit_decoder_load_bitmap( decoder,
image_format,
image_offset + image_start,
image_end,
x_pos,
y_pos );
+
NoBitmap:
- return FT_Err_Invalid_Argument;
+ return SFNT_Err_Invalid_Argument;
}
-
-
FT_LOCAL( FT_Error )
tt_face_load_sbit_image( TT_Face face,
FT_ULong strike_index,
@@ -932,6 +949,7 @@
TT_SBitDecoderRec decoder[1];
FT_Error error;
+
error = tt_sbit_decoder_init( decoder, face, strike_index, metrics );
if ( !error )
{
@@ -941,3 +959,5 @@
return error;
}
+
+/* EOF */