static FT_Pointer
_hb_ftglue_qalloc( FT_Memory memory,
FT_ULong size,
- FT_Error *perror )
+ HB_Error *perror )
{
- FT_Error error = 0;
+ HB_Error error = 0;
FT_Pointer block = NULL;
if ( size > 0 )
{
block = memory->alloc( memory, size );
if ( !block )
- error = FT_Err_Out_Of_Memory;
+ error = HB_Err_Out_Of_Memory;
}
*perror = error;
FTGLUE_APIDEF( FT_Pointer )
_hb_ftglue_alloc( FT_Memory memory,
FT_ULong size,
- FT_Error *perror )
+ HB_Error *perror )
{
- FT_Error error = 0;
+ HB_Error error = 0;
FT_Pointer block = NULL;
if ( size > 0 )
{
block = memory->alloc( memory, size );
if ( !block )
- error = FT_Err_Out_Of_Memory;
+ error = HB_Err_Out_Of_Memory;
else
memset( (char*)block, 0, (size_t)size );
}
FT_Pointer block,
FT_ULong old_size,
FT_ULong new_size,
- FT_Error *perror )
+ HB_Error *perror )
{
FT_Pointer block2 = NULL;
- FT_Error error = 0;
+ HB_Error error = 0;
if ( old_size == 0 || block == NULL )
{
{
block2 = memory->realloc( memory, old_size, new_size, block );
if ( block2 == NULL )
- error = FT_Err_Out_Of_Memory;
+ error = HB_Err_Out_Of_Memory;
else if ( new_size > old_size )
memset( (char*)block2 + old_size, 0, (size_t)(new_size - old_size) );
}
}
-FTGLUE_APIDEF( FT_Error )
+FTGLUE_APIDEF( HB_Error )
_hb_ftglue_stream_seek( FT_Stream stream,
FT_Long pos )
{
- FT_Error error = 0;
+ HB_Error error = 0;
stream->pos = pos;
if ( stream->read )
{
if ( stream->read( stream, pos, NULL, 0 ) )
- error = FT_Err_Invalid_Stream_Operation;
+ error = HB_Err_Invalid_Stream_Operation;
}
else if ( pos > (FT_Long)stream->size )
- error = FT_Err_Invalid_Stream_Operation;
+ error = HB_Err_Invalid_Stream_Operation;
LOG(( "ftglue:stream:seek(%ld) -> %d\n", pos, error ));
return error;
}
-FTGLUE_APIDEF( FT_Error )
+FTGLUE_APIDEF( HB_Error )
_hb_ftglue_stream_frame_enter( FT_Stream stream,
FT_ULong count )
{
- FT_Error error = FT_Err_Ok;
+ HB_Error error = HB_Err_Ok;
FT_ULong read_bytes;
if ( stream->read )
if ( read_bytes < count )
{
FREE( stream->base );
- error = FT_Err_Invalid_Stream_Operation;
+ error = HB_Err_Invalid_Stream_Operation;
}
stream->cursor = stream->base;
stream->limit = stream->cursor + count;
if ( stream->pos >= stream->size ||
stream->pos + count > stream->size )
{
- error = FT_Err_Invalid_Stream_Operation;
+ error = HB_Err_Invalid_Stream_Operation;
goto Exit;
}
}
-FTGLUE_APIDEF( FT_Error )
+FTGLUE_APIDEF( HB_Error )
_hb_ftglue_face_goto_table( FT_Face face,
FT_ULong the_tag,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
LOG(( "_hb_ftglue_face_goto_table( %p, %c%c%c%c, %p )\n",
face,
if ( !FT_IS_SFNT(face) )
{
LOG(( "not a SFNT face !!\n" ));
- error = FT_Err_Invalid_Face_Handle;
+ error = HB_Err_Invalid_Face_Handle;
}
else
{
goto FoundIt;
}
}
- error = FT_Err_Table_Missing;
+ error = HB_Err_Table_Missing;
FoundIt:
FORGET_Frame();
}
#undef QALLOC
+
+/* abuse these private header/source files */
+
+/* helper func to set a breakpoint on */
+HB_Error
+_hb_err (HB_Error code)
+{
+ return code;
+}
#include <ft2build.h>
#include FT_FREETYPE_H
+#include "harfbuzz-open.h"
+
FT_BEGIN_HEADER
/* utility macros */
+#ifndef HB_Error
+#define HB_Error FT_Error
+#endif
+
#define SET_ERR(c) ( (error = (c)) != 0 )
#ifndef FTGLUE_API
FTGLUE_API( FT_Long )
_hb_ftglue_stream_pos( FT_Stream stream );
-FTGLUE_API( FT_Error )
+FTGLUE_API( HB_Error )
_hb_ftglue_stream_seek( FT_Stream stream,
FT_Long pos );
-FTGLUE_API( FT_Error )
+FTGLUE_API( HB_Error )
_hb_ftglue_stream_frame_enter( FT_Stream stream,
FT_ULong size );
FTGLUE_API( void )
_hb_ftglue_stream_frame_exit( FT_Stream stream );
-FTGLUE_API( FT_Error )
+FTGLUE_API( HB_Error )
_hb_ftglue_face_goto_table( FT_Face face,
FT_ULong tag,
FT_Stream stream );
FTGLUE_API( FT_Pointer )
_hb_ftglue_alloc( FT_Memory memory,
FT_ULong size,
- FT_Error *perror_ );
+ HB_Error *perror_ );
FTGLUE_API( FT_Pointer )
_hb_ftglue_realloc( FT_Memory memory,
FT_Pointer block,
FT_ULong old_size,
FT_ULong new_size,
- FT_Error *perror_ );
+ HB_Error *perror_ );
FTGLUE_API( void )
_hb_ftglue_free( FT_Memory memory,
FT_Pointer block );
+/* abuse these private header/source files */
+
+/* helper func to set a breakpoint on */
+HB_Error _hb_err (HB_Error code);
+
FT_END_HEADER
#endif /* FTGLUE_H */
/* harfbuzz-buffer.c: Buffer of glyphs for substitution/positioning
*
- * Copyright 2004 Red Hat Software
+ * Copyright 2004,2007 Red Hat Software
*
* Portions Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
#include "harfbuzz-gsub-private.h"
#include "harfbuzz-gpos-private.h"
-static FT_Error
+/* Here is how the buffer works internally:
+ *
+ * There are two string pointers: in_string and out_string. They
+ * always have same allocated size, but different length and positions.
+ *
+ * As an optimization, both in_string and out_string may point to the
+ * same piece of memory, which is owned by in_string. This remains the
+ * case as long as:
+ *
+ * - copy_glyph() is called
+ * - replace_glyph() is called with inplace=TRUE
+ * - add_output_glyph() and add_output_glyphs() are not called
+ *
+ * In that case swap(), and copy_glyph(), and replace_glyph() are all
+ * mostly no-op.
+ *
+ * As soon an add_output_glyph[s]() or replace_glyph() with inplace=FALSE is
+ * called, out_string is moved over to an alternate buffer (alt_string), and
+ * its current contents (out_length entries) are copied to the alt buffer.
+ * This should all remain transparent to the user. swap() then switches
+ * in_string and alt_string. alt_string is not allocated until its needed,
+ * but after that it's grown with in_string unconditionally.
+ *
+ * The buffer->inplace boolean keeps status of whether out_string points to
+ * in_string or alt_string.
+ */
+
+static HB_Error
hb_buffer_ensure( HB_Buffer buffer,
FT_ULong size )
{
if (size > new_allocated)
{
- FT_Error error;
+ HB_Error error;
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if ( REALLOC_ARRAY( buffer->in_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) )
- return error;
- if ( REALLOC_ARRAY( buffer->out_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) )
- return error;
if ( REALLOC_ARRAY( buffer->positions, buffer->allocated, new_allocated, HB_PositionRec ) )
return error;
+ if ( REALLOC_ARRAY( buffer->in_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) )
+ return error;
+ if ( buffer->inplace )
+ {
+ buffer->out_string = buffer->in_string;
+
+ if ( buffer->alt_string )
+ {
+ if ( REALLOC_ARRAY( buffer->alt_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) )
+ return error;
+ }
+ }
+ else
+ {
+ if ( REALLOC_ARRAY( buffer->alt_string, buffer->allocated, new_allocated, HB_GlyphItemRec ) )
+ return error;
+
+ buffer->out_string = buffer->alt_string;
+ }
buffer->allocated = new_allocated;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error
+static HB_Error
+hb_buffer_duplicate_out_buffer( HB_Buffer buffer )
+{
+ if ( !buffer->alt_string )
+ {
+ FT_Memory memory = buffer->memory;
+ HB_Error error;
+
+ if ( ALLOC_ARRAY( buffer->alt_string, buffer->allocated, HB_GlyphItemRec ) )
+ return error;
+ }
+
+ buffer->out_string = buffer->alt_string;
+ memcpy( buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]) );
+ buffer->inplace = FALSE;
+
+ return HB_Err_Ok;
+}
+
+HB_Error
hb_buffer_new( FT_Memory memory,
HB_Buffer *buffer )
{
- FT_Error error;
+ HB_Error error;
if ( ALLOC( *buffer, sizeof( HB_BufferRec ) ) )
return error;
(*buffer)->in_string = NULL;
(*buffer)->out_string = NULL;
+ (*buffer)->alt_string = NULL;
(*buffer)->positions = NULL;
(*buffer)->max_ligID = 0;
+ (*buffer)->inplace = TRUE;
+
+ return HB_Err_Ok;
+}
- return FT_Err_Ok;
+void
+hb_buffer_clear_output( HB_Buffer buffer )
+{
+ buffer->out_length = 0;
+ buffer->out_pos = 0;
+ buffer->out_string = buffer->in_string;
+ buffer->inplace = TRUE;
}
-FT_Error
+void
hb_buffer_swap( HB_Buffer buffer )
{
HB_GlyphItem tmp_string;
+ int tmp_length;
+ int tmp_pos;
- tmp_string = buffer->in_string;
- buffer->in_string = buffer->out_string;
- buffer->out_string = tmp_string;
+ if ( ! buffer->inplace )
+ {
+ tmp_string = buffer->in_string;
+ buffer->in_string = buffer->out_string;
+ buffer->out_string = tmp_string;
+ buffer->alt_string = buffer->out_string;
+ }
+ tmp_length = buffer->in_length;
buffer->in_length = buffer->out_length;
- buffer->out_length = 0;
-
- buffer->in_pos = 0;
- buffer->out_pos = 0;
+ buffer->out_length = tmp_length;
- return FT_Err_Ok;
+ tmp_pos = buffer->in_pos;
+ buffer->in_pos = buffer->out_pos;
+ buffer->out_pos = tmp_pos;
}
-FT_Error
+void
hb_buffer_free( HB_Buffer buffer )
{
FT_Memory memory = buffer->memory;
FREE( buffer->in_string );
- FREE( buffer->out_string );
+ FREE( buffer->alt_string );
+ buffer->out_string = NULL;
FREE( buffer->positions );
FREE( buffer );
-
- return FT_Err_Ok;
}
-FT_Error
+void
hb_buffer_clear( HB_Buffer buffer )
{
buffer->in_length = 0;
buffer->out_length = 0;
buffer->in_pos = 0;
buffer->out_pos = 0;
-
- return FT_Err_Ok;
+ buffer->out_string = buffer->in_string;
+ buffer->inplace = TRUE;
}
-FT_Error
+HB_Error
hb_buffer_add_glyph( HB_Buffer buffer,
FT_UInt glyph_index,
FT_UInt properties,
FT_UInt cluster )
{
- FT_Error error;
+ HB_Error error;
HB_GlyphItem glyph;
error = hb_buffer_ensure( buffer, buffer->in_length + 1 );
buffer->in_length++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* The following function copies `num_out' elements from `glyph_data'
The cluster value for the glyph at position buffer->in_pos is used
for all replacement glyphs */
-FT_Error
+HB_Error
hb_buffer_add_output_glyphs( HB_Buffer buffer,
FT_UShort num_in,
FT_UShort num_out,
FT_UShort component,
FT_UShort ligID )
{
- FT_Error error;
+ HB_Error error;
FT_UShort i;
FT_UInt properties;
FT_UInt cluster;
if ( error )
return error;
+ if ( buffer->inplace )
+ {
+ error = hb_buffer_duplicate_out_buffer( buffer );
+ if ( error )
+ return error;
+ }
+
properties = buffer->in_string[buffer->in_pos].properties;
cluster = buffer->in_string[buffer->in_pos].cluster;
if ( component == 0xFFFF )
buffer->out_length = buffer->out_pos;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error
+HB_Error
hb_buffer_add_output_glyph( HB_Buffer buffer,
FT_UInt glyph_index,
FT_UShort component,
&glyph_data, component, ligID );
}
-FT_Error
+HB_Error
hb_buffer_copy_output_glyph ( HB_Buffer buffer )
{
- FT_Error error;
+ HB_Error error;
error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );
if ( error )
return error;
- buffer->out_string[buffer->out_pos++] = buffer->in_string[buffer->in_pos++];
+ if ( ! buffer->inplace )
+ {
+ buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
+ }
+
+ buffer->in_pos++;
+ buffer->out_pos++;
buffer->out_length = buffer->out_pos;
- return FT_Err_Ok;
+ return HB_Err_Ok;
+}
+
+HB_Error
+hb_buffer_replace_output_glyph( HB_Buffer buffer,
+ FT_UInt glyph_index,
+ FT_Bool inplace )
+{
+
+ HB_Error error;
+
+ if ( inplace )
+ {
+ error = hb_buffer_copy_output_glyph ( buffer );
+ if ( error )
+ return error;
+
+ buffer->out_string[buffer->out_pos-1].gindex = glyph_index;
+ }
+ else
+ {
+ return hb_buffer_add_output_glyph( buffer, glyph_index, 0xFFFF, 0xFFFF );
+ }
+
+ return HB_Err_Ok;
}
FT_UShort
FT_ULong in_pos;
FT_ULong out_pos;
+ FT_Bool inplace;
HB_GlyphItem in_string;
HB_GlyphItem out_string;
+ HB_GlyphItem alt_string;
HB_Position positions;
FT_UShort max_ligID;
} HB_BufferRec, *HB_Buffer;
-FT_Error
+HB_Error
hb_buffer_new( FT_Memory memory,
HB_Buffer *buffer );
-FT_Error
+void
hb_buffer_swap( HB_Buffer buffer );
-FT_Error
+void
hb_buffer_free( HB_Buffer buffer );
-FT_Error
+void
hb_buffer_clear( HB_Buffer buffer );
-FT_Error
+void
+hb_buffer_clear_output( HB_Buffer buffer );
+
+HB_Error
hb_buffer_add_glyph( HB_Buffer buffer,
FT_UInt glyph_index,
FT_UInt properties,
FT_UInt cluster );
-FT_Error
+HB_Error
hb_buffer_add_output_glyphs( HB_Buffer buffer,
FT_UShort num_in,
FT_UShort num_out,
FT_UShort component,
FT_UShort ligID );
-FT_Error
+HB_Error
hb_buffer_add_output_glyph ( HB_Buffer buffer,
FT_UInt glyph_index,
FT_UShort component,
FT_UShort ligID );
-FT_Error
+HB_Error
hb_buffer_copy_output_glyph ( HB_Buffer buffer );
+HB_Error
+hb_buffer_replace_output_glyph ( HB_Buffer buffer,
+ FT_UInt glyph_index,
+ FT_Bool inplace );
+
FT_UShort
hb_buffer_allocate_ligid( HB_Buffer buffer );
#define N_ELEMENTS(arr) (sizeof(arr)/ sizeof((arr)[0]))
static int
-croak (const char *situation, FT_Error error)
+croak (const char *situation, HB_Error error)
{
fprintf (stderr, "%s: Error %d\n", situation, error);
FT_ULong tag,
FT_UShort property)
{
- FT_Error error;
+ HB_Error error;
FT_UShort feature_index;
/* 0xffff == default language system */
static void
add_features (HB_GSUB gsub)
{
- FT_Error error;
+ HB_Error error;
FT_ULong tag = FT_MAKE_TAG ('a', 'r', 'a', 'b');
FT_UShort script_index;
FT_Face face,
HB_GSUB gsub)
{
- FT_Error error;
+ HB_Error error;
HB_GSUB_String *in_str;
HB_GSUB_String *out_str;
FT_ULong i;
int
main (int argc, char **argv)
{
- FT_Error error;
+ HB_Error error;
FT_Library library;
FT_Face face;
HB_GSUB gsub;
if ((error = HB_Done_GSUB_Table (gsub)))
croak ("HB_Done_GSUB_Table", error);
}
- else if (error != FT_Err_Table_Missing)
+ else if (error != HB_Err_Table_Missing)
fprintf (stderr, "HB_Load_GSUB_Table %x\n", error);
if (!(error = HB_Load_GPOS_Table (face, &gpos, NULL)))
if ((error = HB_Done_GPOS_Table (gpos)))
croak ("HB_Done_GPOS_Table", error);
}
- else if (error != FT_Err_Table_Missing)
+ else if (error != HB_Err_Table_Missing)
fprintf (stderr, "HB_Load_GPOS_Table %x\n", error);
printf ("</OpenType>\n");
Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
{
int i;
- int bits = 0;
+ int bits;
int n_per;
unsigned int mask;
case 3:
bits = 8;
break;
+ default:
+ bits = 0;
+ break;
}
DUMP ("<DeltaValue>");
DEF_DUMP (Lookup)
{
int i;
- const char *lookup_name = NULL;
+ const char *lookup_name;
void (*lookup_func) (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type) = NULL;
if (hb_type == HB_Type_GSUB)
lookup_name = "CHAIN";
lookup_func = Dump_GSUB_Lookup_Chain;
break;
+ default:
+ lookup_name = "(unknown)";
+ lookup_func = NULL;
+ break;
}
}
else
case HB_GPOS_LOOKUP_CHAIN:
lookup_name = "CHAIN";
break;
+ default:
+ lookup_name = "(unknown)";
+ lookup_func = NULL;
+ break;
}
}
};
-FT_Error _HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
+HB_Error _HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
FT_UShort glyphID,
FT_UShort property );
-FT_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
+HB_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
HB_GlyphItem item,
FT_UShort flags,
FT_UShort* property );
#include "harfbuzz-gdef-private.h"
#include "harfbuzz-open-private.h"
-static FT_Error Load_AttachList( HB_AttachList* al,
+static HB_Error Load_AttachList( HB_AttachList* al,
FT_Stream stream );
-static FT_Error Load_LigCaretList( HB_LigCaretList* lcl,
+static HB_Error Load_LigCaretList( HB_LigCaretList* lcl,
FT_Stream stream );
static void Free_AttachList( HB_AttachList* al,
#define GDEF_ID Build_Extension_ID( 'G', 'D', 'E', 'F' )
-static FT_Error GDEF_Create( void* ext,
+static HB_Error GDEF_Create( void* ext,
PFace face )
{
DEFINE_LOAD_LOCALS( face->stream );
/* by convention */
if ( !gdef )
- return FT_Err_Ok;
+ return HB_Err_Ok;
/* a null offset indicates that there is no GDEF table */
table = HB_LookUp_Table( face, TTAG_GDEF );
if ( table < 0 )
- return FT_Err_Ok; /* The table is optional */
+ return HB_Err_Ok; /* The table is optional */
if ( FILE_Seek( face->dirTables[table].Offset ) ||
ACCESS_Frame( 4L ) )
gdef->loaded = FALSE;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-static FT_Error GDEF_Destroy( void* ext,
+static HB_Error GDEF_Destroy( void* ext,
PFace face )
{
HB_GDEFHeader* gdef = (HB_GDEFHeader*)ext;
/* by convention */
if ( !gdef )
- return FT_Err_Ok;
+ return HB_Err_Ok;
if ( gdef->loaded )
{
Free_NewGlyphClasses( gdef, memory );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_Init_GDEF_Extension( HB_Engine engine )
+HB_Error HB_Init_GDEF_Extension( HB_Engine engine )
{
PEngine_Instance _engine = HANDLE_Engine( engine );
if ( !_engine )
- return FT_Err_Invalid_Engine;
+ return HB_Err_Invalid_Engine;
return HB_Register_Extension( _engine,
GDEF_ID,
-FT_Error HB_New_GDEF_Table( FT_Face face,
+HB_Error HB_New_GDEF_Table( FT_Face face,
HB_GDEFHeader** retptr )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = face->memory;
HB_GDEFHeader* gdef;
if ( !retptr )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
if ( ALLOC( gdef, sizeof( *gdef ) ) )
return error;
*retptr = gdef;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_Load_GDEF_Table( FT_Face face,
+HB_Error HB_Load_GDEF_Table( FT_Face face,
HB_GDEFHeader** retptr )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = face->memory;
FT_Stream stream = face->stream;
FT_ULong cur_offset, new_offset, base_offset;
if ( !retptr )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
if (( error = _hb_ftglue_face_goto_table( face, TTAG_GDEF, stream ) ))
return error;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_ClassDefinition( &gdef->GlyphClassDef, 5,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail0;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_AttachList( &gdef->AttachList,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_LigCaretList( &gdef->LigCaretList,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
}
*retptr = gdef;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail3:
Free_LigCaretList( &gdef->LigCaretList, memory );
}
-FT_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef )
+HB_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef )
{
FT_Memory memory = gdef->memory;
FREE( gdef );
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* AttachPoint */
-static FT_Error Load_AttachPoint( HB_AttachPoint* ap,
+static HB_Error Load_AttachPoint( HB_AttachPoint* ap,
FT_Stream stream )
{
FT_Memory memory = stream->memory;
- FT_Error error;
+ HB_Error error;
FT_UShort n, count;
FT_UShort* pi;
FORGET_Frame();
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* AttachList */
-static FT_Error Load_AttachList( HB_AttachList* al,
+static HB_Error Load_AttachList( HB_AttachList* al,
FT_Stream stream )
{
FT_Memory memory = stream->memory;
- FT_Error error;
+ HB_Error error;
FT_UShort n, m, count;
FT_ULong cur_offset, new_offset, base_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &al->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &al->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_AttachPoint( &ap[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_AttachPoint( &ap[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
al->loaded = TRUE;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* CaretValueFormat3 */
/* CaretValueFormat4 */
-static FT_Error Load_CaretValue( HB_CaretValue* cv,
+static HB_Error Load_CaretValue( HB_CaretValue* cv,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_ULong cur_offset, new_offset, base_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &cv->cvf.cvf3.Device,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
break;
default:
- return HB_Err_Invalid_GDEF_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GDEF_SubTable_Format);
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* LigGlyph */
-static FT_Error Load_LigGlyph( HB_LigGlyph* lg,
+static HB_Error Load_LigGlyph( HB_LigGlyph* lg,
FT_Stream stream )
{
FT_Memory memory = stream->memory;
- FT_Error error;
+ HB_Error error;
FT_UShort n, m, count;
FT_ULong cur_offset, new_offset, base_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_CaretValue( &cv[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_CaretValue( &cv[n], stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* LigCaretList */
-static FT_Error Load_LigCaretList( HB_LigCaretList* lcl,
+static HB_Error Load_LigCaretList( HB_LigCaretList* lcl,
FT_Stream stream )
{
FT_Memory memory = stream->memory;
- FT_Error error;
+ HB_Error error;
FT_UShort m, n, count;
FT_ULong cur_offset, new_offset, base_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &lcl->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &lcl->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_LigGlyph( &lg[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_LigGlyph( &lg[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
lcl->loaded = TRUE;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
-FT_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
+HB_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
FT_UShort glyphID,
FT_UShort* property )
{
FT_UShort class, index;
- FT_Error error;
+ HB_Error error;
if ( !gdef || !property )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
/* first, we check for mark attach classes */
if ( !error )
{
*property = class << 8;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
}
switch ( class )
{
+ default:
case UNCLASSIFIED_GLYPH:
*property = 0;
break;
break;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-static FT_Error Make_ClassRange( HB_ClassDefinition* cd,
+static HB_Error Make_ClassRange( HB_ClassDefinition* cd,
FT_UShort start,
FT_UShort end,
FT_UShort class,
FT_Memory memory )
{
- FT_Error error;
+ HB_Error error;
FT_UShort index;
HB_ClassDefFormat2* cdf2;
cd->Defined[class] = TRUE;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
+HB_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
FT_UShort num_glyphs,
FT_UShort glyph_count,
FT_UShort* glyph_array,
{
FT_UShort start, curr_glyph, curr_class;
FT_UShort n, m, count;
- FT_Error error;
+ HB_Error error;
FT_Memory memory;
HB_ClassDefinition* gcd;
if ( !gdef || !glyph_array || !class_array )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gdef->memory;
gcd = &gdef->GlyphClassDef;
if ( curr_class >= 5 )
{
- error = FT_Err_Invalid_Argument;
+ error = HB_Err_Invalid_Argument;
goto Fail4;
}
glyph_count--;
- for ( n = 0; n <= glyph_count; n++ )
+ for ( n = 0; n < glyph_count + 1; n++ )
{
if ( curr_glyph == glyph_array[n] && curr_class == class_array[n] )
{
if ( ( error = Make_ClassRange( gcd, start,
curr_glyph,
curr_class,
- memory ) ) != FT_Err_Ok )
+ memory ) ) != HB_Err_Ok )
goto Fail3;
}
else
{
if ( curr_glyph == 0xFFFF )
{
- error = FT_Err_Invalid_Argument;
+ error = HB_Err_Invalid_Argument;
goto Fail3;
}
else
if ( ( error = Make_ClassRange( gcd, start,
curr_glyph - 1,
curr_class,
- memory ) ) != FT_Err_Ok )
+ memory ) ) != HB_Err_Ok )
goto Fail3;
if ( curr_glyph > glyph_array[n] )
{
- error = FT_Err_Invalid_Argument;
+ error = HB_Err_Invalid_Argument;
goto Fail3;
}
if ( curr_class >= 5 )
{
- error = FT_Err_Invalid_Argument;
+ error = HB_Err_Invalid_Argument;
goto Fail3;
}
if ( ( error = Make_ClassRange( gcd, start,
curr_glyph,
curr_class,
- memory ) ) != FT_Err_Ok )
+ memory ) ) != HB_Err_Ok )
goto Fail3;
}
else
{
if ( curr_glyph == 0xFFFF )
{
- error = FT_Err_Invalid_Argument;
+ error = HB_Err_Invalid_Argument;
goto Fail3;
}
else
gcd->loaded = TRUE;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
}
-FT_Error _HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
+HB_Error _HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
FT_UShort glyphID,
FT_UShort property )
{
- FT_Error error;
+ HB_Error error;
FT_UShort class, new_class, index;
FT_UShort byte, bits, mask;
FT_UShort array_index, glyph_index, count;
break;
default:
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
}
count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount;
ngc[array_index][glyph_index / 4] |= bits;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
+HB_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
HB_GlyphItem gitem,
FT_UShort flags,
FT_UShort* property )
{
- FT_Error error;
+ HB_Error error;
if ( gdef )
{
*property = 0;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
typedef struct HB_GDEFHeader_* HB_GDEF;
-FT_Error HB_New_GDEF_Table( FT_Face face,
+HB_Error HB_New_GDEF_Table( FT_Face face,
HB_GDEFHeader** retptr );
-FT_Error HB_Load_GDEF_Table( FT_Face face,
+HB_Error HB_Load_GDEF_Table( FT_Face face,
HB_GDEFHeader** gdef );
-FT_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );
+HB_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef );
-FT_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
+HB_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
FT_UShort glyphID,
FT_UShort* property );
-FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
+HB_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
FT_UShort num_glyphs,
FT_UShort glyph_count,
FT_UShort* glyph_array,
-FT_Error _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
+HB_Error _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
FT_Stream stream,
FT_UShort lookup_type );
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
+ * Copyright 2007 Red Hat Software
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
typedef struct GPOS_Instance_ GPOS_Instance;
-static FT_Error GPOS_Do_Glyph_Lookup( GPOS_Instance* gpi,
+static HB_Error GPOS_Do_Glyph_Lookup( GPOS_Instance* gpi,
FT_UShort lookup_index,
HB_Buffer buffer,
FT_UShort context_length,
/* the client application must replace this with something more
meaningful if multiple master fonts are to be supported. */
-static FT_Error default_mmfunc( FT_Face face,
+static HB_Error default_mmfunc( FT_Face face,
FT_UShort metric_id,
FT_Pos* metric_value,
void* data )
FT_UNUSED(metric_id);
FT_UNUSED(metric_value);
FT_UNUSED(data);
- return HB_Err_No_MM_Interpreter;
+ return _hb_err(HB_Err_No_MM_Interpreter);
}
-FT_Error HB_Load_GPOS_Table( FT_Face face,
+HB_Error HB_Load_GPOS_Table( FT_Face face,
HB_GPOSHeader** retptr,
HB_GDEFHeader* gdef )
{
HB_Lookup* lo;
FT_Stream stream = face->stream;
- FT_Error error;
+ HB_Error error;
FT_Memory memory = face->memory;
if ( !retptr )
- return FT_Err_Invalid_Argument;
-
- if ( !stream )
- return FT_Err_Invalid_Face_Handle;
+ return HB_Err_Invalid_Argument;
if (( error = _hb_ftglue_face_goto_table( face, TTAG_GPOS, stream ) ))
return error;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_ScriptList( &gpos->ScriptList,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail4;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_FeatureList( &gpos->FeatureList,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_LookupList( &gpos->LookupList,
- stream, HB_Type_GPOS ) ) != FT_Err_Ok )
+ stream, HB_Type_GPOS ) ) != HB_Err_Ok )
goto Fail2;
gpos->gdef = gdef; /* can be NULL */
{
if ( FILE_Seek( gdef->MarkAttachClassDef_offset ) ||
( error = _HB_OPEN_Load_ClassDefinition( &gdef->MarkAttachClassDef,
- 256, stream ) ) != FT_Err_Ok )
+ 256, stream ) ) != HB_Err_Ok )
goto Fail1;
break;
*retptr = gpos;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
_HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS, memory );
}
-FT_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos )
+HB_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos )
{
FT_Memory memory = gpos->memory;
FREE( gpos );
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
`record' -- offsets for device tables in ValueRecords are taken from
the parent table and not the parent record. */
-static FT_Error Load_ValueRecord( HB_ValueRecord* vr,
+static HB_Error Load_ValueRecord( HB_ValueRecord* vr,
FT_UShort format,
FT_ULong base_offset,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_ULong cur_offset, new_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &vr->XPlacementDevice,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &vr->YPlacementDevice,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &vr->XAdvanceDevice,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &vr->YAdvanceDevice,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
else
vr->YIdAdvance = 0;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
_HB_OPEN_Free_Device( &vr->YAdvanceDevice, memory );
}
-static FT_Error Get_ValueRecord( GPOS_Instance* gpi,
+static HB_Error Get_ValueRecord( GPOS_Instance* gpi,
HB_ValueRecord* vr,
FT_UShort format,
HB_Position gd )
{
FT_Pos value;
FT_Short pixel_value;
- FT_Error error = FT_Err_Ok;
+ HB_Error error = HB_Err_Ok;
HB_GPOSHeader* gpos = gpi->gpos;
FT_UShort x_ppem, y_ppem;
if ( !format )
- return FT_Err_Ok;
+ return HB_Err_Ok;
x_ppem = gpi->face->size->metrics.x_ppem;
y_ppem = gpi->face->size->metrics.y_ppem;
/* AnchorFormat3 */
/* AnchorFormat4 */
-static FT_Error Load_Anchor( HB_Anchor* an,
+static HB_Error Load_Anchor( HB_Anchor* an,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_ULong cur_offset, new_offset, base_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &an->af.af3.XDeviceTable,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Device( &an->af.af3.YDeviceTable,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
break;
default:
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
_HB_OPEN_Free_Device( &an->af.af3.XDeviceTable, memory );
}
-static FT_Error Get_Anchor( GPOS_Instance* gpi,
+static HB_Error Get_Anchor( GPOS_Instance* gpi,
HB_Anchor* an,
FT_UShort glyph_index,
FT_Pos* x_value,
FT_Pos* y_value )
{
- FT_Error error = FT_Err_Ok;
+ HB_Error error = HB_Err_Ok;
FT_Outline outline;
HB_GPOSHeader* gpos = gpi->gpos;
{
case 0:
/* The special case of an empty AnchorTable */
+ default:
return HB_Err_Not_Covered;
return error;
if ( gpi->face->glyph->format != ft_glyph_format_outline )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
ap = an->af.af2.AnchorPoint;
goto no_contour_point;
if ( ap >= outline.n_points )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
*x_value = outline.points[ap].x;
*y_value = outline.points[ap].y;
/* MarkArray */
-static FT_Error Load_MarkArray ( HB_MarkArray* ma,
+static HB_Error Load_MarkArray ( HB_MarkArray* ma,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_Anchor( &mr[n].MarkAnchor, stream ) ) != FT_Err_Ok )
+ ( error = Load_Anchor( &mr[n].MarkAnchor, stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* SinglePosFormat1 */
/* SinglePosFormat2 */
-static FT_Error Load_SinglePos( HB_GPOS_SubTable* st,
+static HB_Error Load_SinglePos( HB_GPOS_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_SinglePos* sp = &st->single;
FORGET_Frame();
if ( !format )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &sp->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &sp->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
break;
default:
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
FREE( v );
}
break;
+ default:
+ break;
}
_HB_OPEN_Free_Coverage( &sp->Coverage, memory );
}
-static FT_Error Lookup_DefaultPos( GPOS_Instance* gpi,
- HB_GPOS_SubTable* st,
- HB_Buffer buffer,
- FT_UShort flags,
- FT_UShort context_length,
- int nesting_level )
-{
- FT_UNUSED(gpi);
- FT_UNUSED(st);
- FT_UNUSED(buffer);
- FT_UNUSED(flags);
- FT_UNUSED(context_length);
- FT_UNUSED(nesting_level);
- return HB_Err_Not_Covered;
-}
-
-static FT_Error Lookup_SinglePos( GPOS_Instance* gpi,
+static HB_Error Lookup_SinglePos( GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
int nesting_level )
{
FT_UShort index, property;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_SinglePos* sp = &st->single;
case 2:
if ( index >= sp->spf.spf2.ValueCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
error = Get_ValueRecord( gpi, &sp->spf.spf2.Value[index],
sp->ValueFormat, POSITION( buffer->in_pos ) );
if ( error )
break;
default:
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
}
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* PairSet */
-static FT_Error Load_PairSet ( HB_PairSet* ps,
+static HB_Error Load_PairSet ( HB_PairSet* ps,
FT_UShort format1,
FT_UShort format2,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* PairPosFormat1 */
-static FT_Error Load_PairPos1( HB_PairPosFormat1* ppf1,
+static HB_Error Load_PairPos1( HB_PairPosFormat1* ppf1,
FT_UShort format1,
FT_UShort format2,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_PairSet( &ps[n], format1,
- format2, stream ) ) != FT_Err_Ok )
+ format2, stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* PairPosFormat2 */
-static FT_Error Load_PairPos2( HB_PairPosFormat2* ppf2,
+static HB_Error Load_PairPos2( HB_PairPosFormat2* ppf2,
FT_UShort format1,
FT_UShort format2,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort m, n, k, count1, count2;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset1 ) ||
( error = _HB_OPEN_Load_ClassDefinition( &ppf2->ClassDef1, count1,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
return error;
if ( FILE_Seek( new_offset2 ) ||
( error = _HB_OPEN_Load_ClassDefinition( &ppf2->ClassDef2, count2,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
goto Fail1;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( k = 0; k < m; k++ )
}
-static FT_Error Load_PairPos( HB_GPOS_SubTable* st,
+static HB_Error Load_PairPos( HB_GPOS_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_PairPos* pp = &st->pair;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &pp->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &pp->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
break;
default:
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
_HB_OPEN_Free_Coverage( &pp->Coverage, memory );
case 2:
Free_PairPos2( &pp->ppf.ppf2, format1, format2, memory );
break;
+
+ default:
+ break;
}
_HB_OPEN_Free_Coverage( &pp->Coverage, memory );
}
-static FT_Error Lookup_PairPos1( GPOS_Instance* gpi,
+static HB_Error Lookup_PairPos1( GPOS_Instance* gpi,
HB_PairPosFormat1* ppf1,
HB_Buffer buffer,
FT_ULong first_pos,
FT_UShort format1,
FT_UShort format2 )
{
- FT_Error error;
+ HB_Error error;
FT_UShort numpvr, glyph2;
HB_PairValueRecord* pvr;
if ( index >= ppf1->PairSetCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
pvr = ppf1->PairSet[index].PairValueRecord;
if ( !pvr )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
glyph2 = IN_CURGLYPH();
}
-static FT_Error Lookup_PairPos2( GPOS_Instance* gpi,
+static HB_Error Lookup_PairPos2( GPOS_Instance* gpi,
HB_PairPosFormat2* ppf2,
HB_Buffer buffer,
FT_ULong first_pos,
FT_UShort format1,
FT_UShort format2 )
{
- FT_Error error;
+ HB_Error error;
FT_UShort cl1, cl2;
HB_Class1Record* c1r;
c1r = &ppf2->Class1Record[cl1];
if ( !c1r )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
c2r = &c1r->Class2Record[cl2];
error = Get_ValueRecord( gpi, &c2r->Value1, format1, POSITION( first_pos ) );
}
-static FT_Error Lookup_PairPos( GPOS_Instance* gpi,
+static HB_Error Lookup_PairPos( GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
- FT_Error error;
+ HB_Error error;
FT_UShort index, property;
FT_ULong first_pos;
HB_GPOSHeader* gpos = gpi->gpos;
break;
default:
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
/* if we don't have coverage for the second glyph don't skip it for
/* CursivePosFormat1 */
-static FT_Error Load_CursivePos( HB_GPOS_SubTable* st,
+static HB_Error Load_CursivePos( HB_GPOS_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_CursivePos* cp = &st->cursive;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &cp->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &cp->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_Anchor( &eer[n].EntryAnchor,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_Anchor( &eer[n].ExitAnchor,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
{
if ( entry_offset )
Free_Anchor( &eer[n].EntryAnchor, memory );
eer[n].ExitAnchor.PosFormat = 0;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
}
-static FT_Error Lookup_CursivePos( GPOS_Instance* gpi,
+static HB_Error Lookup_CursivePos( GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
int nesting_level )
{
FT_UShort index, property;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_CursivePos* cp = &st->cursive;
}
if ( index >= cp->EntryExitCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
eer = &cp->EntryExitRecord[index];
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* BaseArray */
-static FT_Error Load_BaseArray( HB_BaseArray* ba,
+static HB_Error Load_BaseArray( HB_BaseArray* ba,
FT_UShort num_classes,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort m, n, k, count;
FORGET_Frame();
if (new_offset == base_offset) {
- /* Doulos SIL Regular is buggy and has zer offsets here. Skip */
+ /* XXX
+ * Doulos SIL Regular is buggy and has zero offsets here.
+ * Skip it
+ */
ban[n].PosFormat = 0;
continue;
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_Anchor( &ban[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_Anchor( &ban[n], stream ) ) != HB_Err_Ok )
goto Fail0;
(void)FILE_Seek( cur_offset );
}
goto Fail;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( k = 0; k < m; k++ )
/* MarkBasePosFormat1 */
-static FT_Error Load_MarkBasePos( HB_GPOS_SubTable* st,
+static HB_Error Load_MarkBasePos( HB_GPOS_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_MarkBasePos* mbp = &st->markbase;
FORGET_Frame();
if (mbp->PosFormat != 1)
- return HB_Err_Invalid_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_SubTable_Format);
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &mbp->MarkCoverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &mbp->MarkCoverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &mbp->BaseCoverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &mbp->BaseCoverage, stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_MarkArray( &mbp->MarkArray, stream ) ) != FT_Err_Ok )
+ ( error = Load_MarkArray( &mbp->MarkArray, stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_BaseArray( &mbp->BaseArray, mbp->ClassCount,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
Free_MarkArray( &mbp->MarkArray, memory );
}
-static FT_Error Lookup_MarkBasePos( GPOS_Instance* gpi,
+static HB_Error Lookup_MarkBasePos( GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
{
FT_UShort i, j, mark_index, base_index, property, class;
FT_Pos x_mark_value, y_mark_value, x_base_value, y_base_value;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_MarkBasePos* mbp = &st->markbase;
ma = &mbp->MarkArray;
if ( mark_index >= ma->MarkCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
class = ma->MarkRecord[mark_index].Class;
mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor;
if ( class >= mbp->ClassCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
ba = &mbp->BaseArray;
if ( base_index >= ba->BaseCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
br = &ba->BaseRecord[base_index];
base_anchor = &br->BaseAnchor[class];
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* LigatureAttach */
-static FT_Error Load_LigatureAttach( HB_LigatureAttach* lat,
+static HB_Error Load_LigatureAttach( HB_LigatureAttach* lat,
FT_UShort num_classes,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort m, n, k, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_Anchor( &lan[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_Anchor( &lan[n], stream ) ) != HB_Err_Ok )
goto Fail0;
(void)FILE_Seek( cur_offset );
}
goto Fail;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( k = 0; k < m; k++ )
/* LigatureArray */
-static FT_Error Load_LigatureArray( HB_LigatureArray* la,
+static HB_Error Load_LigatureArray( HB_LigatureArray* la,
FT_UShort num_classes,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_LigatureAttach( &lat[n], num_classes,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* MarkLigPosFormat1 */
-static FT_Error Load_MarkLigPos( HB_GPOS_SubTable* st,
+static HB_Error Load_MarkLigPos( HB_GPOS_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_MarkLigPos* mlp = &st->marklig;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &mlp->MarkCoverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &mlp->MarkCoverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Coverage( &mlp->LigatureCoverage,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_MarkArray( &mlp->MarkArray, stream ) ) != FT_Err_Ok )
+ ( error = Load_MarkArray( &mlp->MarkArray, stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_LigatureArray( &mlp->LigatureArray, mlp->ClassCount,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
Free_MarkArray( &mlp->MarkArray, memory );
}
-static FT_Error Lookup_MarkLigPos( GPOS_Instance* gpi,
+static HB_Error Lookup_MarkLigPos( GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
FT_UShort i, j, mark_index, lig_index, property, class;
FT_UShort mark_glyph;
FT_Pos x_mark_value, y_mark_value, x_lig_value, y_lig_value;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_MarkLigPos* mlp = &st->marklig;
ma = &mlp->MarkArray;
if ( mark_index >= ma->MarkCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
class = ma->MarkRecord[mark_index].Class;
mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor;
if ( class >= mlp->ClassCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
la = &mlp->LigatureArray;
if ( lig_index >= la->LigatureCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
lat = &la->LigatureAttach[lig_index];
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* Mark2Array */
-static FT_Error Load_Mark2Array( HB_Mark2Array* m2a,
+static HB_Error Load_Mark2Array( HB_Mark2Array* m2a,
FT_UShort num_classes,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort k, m, n, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_Anchor( &m2an[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_Anchor( &m2an[n], stream ) ) != HB_Err_Ok )
goto Fail0;
(void)FILE_Seek( cur_offset );
}
goto Fail;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( k = 0; k < m; k++ )
/* MarkMarkPosFormat1 */
-static FT_Error Load_MarkMarkPos( HB_GPOS_SubTable* st,
+static HB_Error Load_MarkMarkPos( HB_GPOS_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_MarkMarkPos* mmp = &st->markmark;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Coverage( &mmp->Mark1Coverage,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_Coverage( &mmp->Mark2Coverage,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_MarkArray( &mmp->Mark1Array, stream ) ) != FT_Err_Ok )
+ ( error = Load_MarkArray( &mmp->Mark1Array, stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_Mark2Array( &mmp->Mark2Array, mmp->ClassCount,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
Free_MarkArray( &mmp->Mark1Array, memory );
}
-static FT_Error Lookup_MarkMarkPos( GPOS_Instance* gpi,
+static HB_Error Lookup_MarkMarkPos( GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
FT_UShort i, j, mark1_index, mark2_index, property, class;
FT_Pos x_mark1_value, y_mark1_value,
x_mark2_value, y_mark2_value;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_MarkMarkPos* mmp = &st->markmark;
ma1 = &mmp->Mark1Array;
if ( mark1_index >= ma1->MarkCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
class = ma1->MarkRecord[mark1_index].Class;
mark1_anchor = &ma1->MarkRecord[mark1_index].MarkAnchor;
if ( class >= mmp->ClassCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
ma2 = &mmp->Mark2Array;
if ( mark2_index >= ma2->Mark2Count )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
m2r = &ma2->Mark2Record[mark2_index];
mark2_anchor = &m2r->Mark2Anchor[class];
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
7 or 8). This is only called after we've determined that the stream
matches the subrule. */
-static FT_Error Do_ContextPos( GPOS_Instance* gpi,
+static HB_Error Do_ContextPos( GPOS_Instance* gpi,
FT_UShort GlyphCount,
FT_UShort PosCount,
HB_PosLookupRecord* pos,
HB_Buffer buffer,
int nesting_level )
{
- FT_Error error;
+ HB_Error error;
FT_ULong i, old_pos;
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* PosRule */
-static FT_Error Load_PosRule( HB_PosRule* pr,
+static HB_Error Load_PosRule( HB_PosRule* pr,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
/* PosRuleSet */
-static FT_Error Load_PosRuleSet( HB_PosRuleSet* prs,
+static HB_Error Load_PosRuleSet( HB_PosRuleSet* prs,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_PosRule( &pr[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_PosRule( &pr[n], stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* ContextPosFormat1 */
-static FT_Error Load_ContextPos1( HB_ContextPosFormat1* cpf1,
+static HB_Error Load_ContextPos1( HB_ContextPosFormat1* cpf1,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &cpf1->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &cpf1->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_PosRuleSet( &prs[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_PosRuleSet( &prs[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* PosClassRule */
-static FT_Error Load_PosClassRule( HB_ContextPosFormat2* cpf2,
+static HB_Error Load_PosClassRule( HB_ContextPosFormat2* cpf2,
HB_PosClassRule* pcr,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
/* PosClassSet */
-static FT_Error Load_PosClassSet( HB_ContextPosFormat2* cpf2,
+static HB_Error Load_PosClassSet( HB_ContextPosFormat2* cpf2,
HB_PosClassSet* pcs,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_PosClassRule( cpf2, &pcr[n],
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* ContextPosFormat2 */
-static FT_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2,
+static HB_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &cpf2->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &cpf2->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_ClassDefinition( &cpf2->ClassDef, count,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_PosClassSet( cpf2, &pcs[n],
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; n++ )
/* ContextPosFormat3 */
-static FT_Error Load_ContextPos3( HB_ContextPosFormat3* cpf3,
+static HB_Error Load_ContextPos3( HB_ContextPosFormat3* cpf3,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &c[n], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &c[n], stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
}
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
/* ContextPos */
-static FT_Error Load_ContextPos( HB_GPOS_SubTable* st,
+static HB_Error Load_ContextPos( HB_GPOS_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
HB_ContextPos* cp = &st->context;
return Load_ContextPos3( &cp->cpf.cpf3, stream );
default:
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
switch ( cp->PosFormat )
{
- case 1:
- Free_ContextPos1( &cp->cpf.cpf1, memory );
- break;
-
- case 2:
- Free_ContextPos2( &cp->cpf.cpf2, memory );
- break;
-
- case 3:
- Free_ContextPos3( &cp->cpf.cpf3, memory );
- break;
+ case 1: Free_ContextPos1( &cp->cpf.cpf1, memory ); break;
+ case 2: Free_ContextPos2( &cp->cpf.cpf2, memory ); break;
+ case 3: Free_ContextPos3( &cp->cpf.cpf3, memory ); break;
+ default: break;
}
}
-static FT_Error Lookup_ContextPos1( GPOS_Instance* gpi,
+static HB_Error Lookup_ContextPos1( GPOS_Instance* gpi,
HB_ContextPosFormat1* cpf1,
HB_Buffer buffer,
FT_UShort flags,
{
FT_UShort index, property;
FT_UShort i, j, k, numpr;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_PosRule* pr;
}
-static FT_Error Lookup_ContextPos2( GPOS_Instance* gpi,
+static HB_Error Lookup_ContextPos2( GPOS_Instance* gpi,
HB_ContextPosFormat2* cpf2,
HB_Buffer buffer,
FT_UShort flags,
int nesting_level )
{
FT_UShort index, property;
- FT_Error error;
+ HB_Error error;
FT_Memory memory = gpi->face->memory;
FT_UShort i, j, k, known_classes;
pcs = &cpf2->PosClassSet[classes[0]];
if ( !pcs )
{
- error = HB_Err_Invalid_GPOS_SubTable;
+ error = _hb_err(HB_Err_Invalid_GPOS_SubTable);
goto End;
}
}
-static FT_Error Lookup_ContextPos3( GPOS_Instance* gpi,
+static HB_Error Lookup_ContextPos3( GPOS_Instance* gpi,
HB_ContextPosFormat3* cpf3,
HB_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
- FT_Error error;
+ HB_Error error;
FT_UShort index, i, j, property;
HB_GPOSHeader* gpos = gpi->gpos;
}
-static FT_Error Lookup_ContextPos( GPOS_Instance* gpi,
+static HB_Error Lookup_ContextPos( GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
flags, context_length, nesting_level );
default:
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
/* ChainPosRule */
-static FT_Error Load_ChainPosRule( HB_ChainPosRule* cpr,
+static HB_Error Load_ChainPosRule( HB_ChainPosRule* cpr,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
/* ChainPosRuleSet */
-static FT_Error Load_ChainPosRuleSet( HB_ChainPosRuleSet* cprs,
+static HB_Error Load_ChainPosRuleSet( HB_ChainPosRuleSet* cprs,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_ChainPosRule( &cpr[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_ChainPosRule( &cpr[n], stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* ChainContextPosFormat1 */
-static FT_Error Load_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1,
+static HB_Error Load_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &ccpf1->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &ccpf1->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_ChainPosRuleSet( &cprs[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_ChainPosRuleSet( &cprs[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* ChainPosClassRule */
-static FT_Error Load_ChainPosClassRule(
+static HB_Error Load_ChainPosClassRule(
HB_ChainContextPosFormat2* ccpf2,
HB_ChainPosClassRule* cpcr,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
/* PosClassSet */
-static FT_Error Load_ChainPosClassSet(
+static HB_Error Load_ChainPosClassSet(
HB_ChainContextPosFormat2* ccpf2,
HB_ChainPosClassSet* cpcs,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_ChainPosClassRule( ccpf2, &cpcr[n],
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
}
-static FT_Error GPOS_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
+static HB_Error GPOS_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
FT_UShort limit,
FT_ULong class_offset,
FT_ULong base_offset,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_ULong cur_offset;
cur_offset = FILE_Pos();
else
error = _HB_OPEN_Load_EmptyClassDefinition ( cd, stream );
- if (error == FT_Err_Ok)
+ if (error == HB_Err_Ok)
(void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */
return error;
/* ChainContextPosFormat2 */
-static FT_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2,
+static HB_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &ccpf2->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &ccpf2->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
if ( ( error = GPOS_Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, 65535,
backtrack_offset, base_offset,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail5;
if ( ( error = GPOS_Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count,
input_offset, base_offset,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail4;
if ( ( error = GPOS_Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, 65535,
lookahead_offset, base_offset,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
ccpf2->ChainPosClassSet = NULL;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_ChainPosClassSet( ccpf2, &cpcs[n],
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* ChainContextPosFormat3 */
-static FT_Error Load_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3,
+static HB_Error Load_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, nb, ni, nl, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )
goto Fail4;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
}
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
/* ChainContextPos */
-static FT_Error Load_ChainContextPos( HB_GPOS_SubTable* st,
+static HB_Error Load_ChainContextPos( HB_GPOS_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
HB_ChainContextPos* ccp = &st->chain;
return Load_ChainContextPos3( &ccp->ccpf.ccpf3, stream );
default:
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
switch ( ccp->PosFormat )
{
- case 1:
- Free_ChainContextPos1( &ccp->ccpf.ccpf1, memory );
- break;
-
- case 2:
- Free_ChainContextPos2( &ccp->ccpf.ccpf2, memory );
- break;
-
- case 3:
- Free_ChainContextPos3( &ccp->ccpf.ccpf3, memory );
- break;
+ case 1: Free_ChainContextPos1( &ccp->ccpf.ccpf1, memory ); break;
+ case 2: Free_ChainContextPos2( &ccp->ccpf.ccpf2, memory ); break;
+ case 3: Free_ChainContextPos3( &ccp->ccpf.ccpf3, memory ); break;
+ default: break;
}
}
-static FT_Error Lookup_ChainContextPos1(
+static HB_Error Lookup_ChainContextPos1(
GPOS_Instance* gpi,
HB_ChainContextPosFormat1* ccpf1,
HB_Buffer buffer,
FT_UShort index, property;
FT_UShort i, j, k, num_cpr;
FT_UShort bgc, igc, lgc;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_ChainPosRule* cpr;
}
-static FT_Error Lookup_ChainContextPos2(
+static HB_Error Lookup_ChainContextPos2(
GPOS_Instance* gpi,
HB_ChainContextPosFormat2* ccpf2,
HB_Buffer buffer,
{
FT_UShort index, property;
FT_Memory memory = gpi->face->memory;
- FT_Error error;
+ HB_Error error;
FT_UShort i, j, k;
FT_UShort bgc, igc, lgc;
FT_UShort known_backtrack_classes,
cpcs = &ccpf2->ChainPosClassSet[input_classes[0]];
if ( !cpcs )
{
- error = HB_Err_Invalid_GPOS_SubTable;
+ error = _hb_err(HB_Err_Invalid_GPOS_SubTable);
goto End1;
}
}
-static FT_Error Lookup_ChainContextPos3(
+static HB_Error Lookup_ChainContextPos3(
GPOS_Instance* gpi,
HB_ChainContextPosFormat3* ccpf3,
HB_Buffer buffer,
{
FT_UShort index, i, j, property;
FT_UShort bgc, igc, lgc;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_Coverage* bc;
}
-static FT_Error Lookup_ChainContextPos(
+static HB_Error Lookup_ChainContextPos(
GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
nesting_level );
default:
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
-FT_Error HB_GPOS_Select_Script( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Select_Script( HB_GPOSHeader* gpos,
FT_ULong script_tag,
FT_UShort* script_index )
{
if ( !gpos || !script_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gpos->ScriptList;
sr = sl->ScriptRecord;
{
*script_index = n;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
return HB_Err_Not_Covered;
-FT_Error HB_GPOS_Select_Language( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Select_Language( HB_GPOSHeader* gpos,
FT_ULong language_tag,
FT_UShort script_index,
FT_UShort* language_index,
if ( !gpos || !language_index || !req_feature_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gpos->ScriptList;
sr = sl->ScriptRecord;
if ( script_index >= sl->ScriptCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
s = &sr[script_index].Script;
lsr = s->LangSysRecord;
*language_index = n;
*req_feature_index = lsr[n].LangSys.ReqFeatureIndex;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
return HB_Err_Not_Covered;
default language (DefaultLangSys) */
-FT_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
FT_ULong feature_tag,
FT_UShort script_index,
FT_UShort language_index,
if ( !gpos || !feature_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gpos->ScriptList;
sr = sl->ScriptRecord;
fr = fl->FeatureRecord;
if ( script_index >= sl->ScriptCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
s = &sr[script_index].Script;
lsr = s->LangSysRecord;
else
{
if ( language_index >= s->LangSysCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
ls = &lsr[language_index].LangSys;
}
for ( n = 0; n < ls->FeatureCount; n++ )
{
if ( fi[n] >= fl->FeatureCount )
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
if ( feature_tag == fr[fi[n]].FeatureTag )
{
*feature_index = fi[n];
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
}
/* The next three functions return a null-terminated list */
-FT_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos,
FT_ULong** script_tag_list )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory;
FT_UShort n;
FT_ULong* stl;
if ( !gpos || !script_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gpos->memory;
sl = &gpos->ScriptList;
*script_tag_list = stl;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos,
FT_UShort script_index,
FT_ULong** language_tag_list )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory;
FT_UShort n;
FT_ULong* ltl;
if ( !gpos || !language_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gpos->memory;
sl = &gpos->ScriptList;
sr = sl->ScriptRecord;
if ( script_index >= sl->ScriptCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
s = &sr[script_index].Script;
lsr = s->LangSysRecord;
*language_tag_list = ltl;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
default language (DefaultLangSys) */
-FT_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
FT_UShort script_index,
FT_UShort language_index,
FT_ULong** feature_tag_list )
{
FT_UShort n;
- FT_Error error;
+ HB_Error error;
FT_Memory memory;
FT_ULong* ftl;
if ( !gpos || !feature_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gpos->memory;
sl = &gpos->ScriptList;
fr = fl->FeatureRecord;
if ( script_index >= sl->ScriptCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
s = &sr[script_index].Script;
lsr = s->LangSysRecord;
else
{
if ( language_index >= s->LangSysCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
ls = &lsr[language_index].LangSys;
}
if ( fi[n] >= fl->FeatureCount )
{
FREE( ftl );
- return HB_Err_Invalid_GPOS_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
}
ftl[n] = fr[fi[n]].FeatureTag;
}
*feature_tag_list = ftl;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-typedef FT_Error (*Lookup_Pos_Func_Type) ( GPOS_Instance* gpi,
- HB_GPOS_SubTable* st,
- HB_Buffer buffer,
- FT_UShort flags,
- FT_UShort context_length,
- int nesting_level );
-static const Lookup_Pos_Func_Type Lookup_Pos_Call_Table[] = {
- Lookup_DefaultPos,
- Lookup_SinglePos, /* HB_GPOS_LOOKUP_SINGLE 1 */
- Lookup_PairPos, /* HB_GPOS_LOOKUP_PAIR 2 */
- Lookup_CursivePos, /* HB_GPOS_LOOKUP_CURSIVE 3 */
- Lookup_MarkBasePos, /* HB_GPOS_LOOKUP_MARKBASE 4 */
- Lookup_MarkLigPos, /* HB_GPOS_LOOKUP_MARKLIG 5 */
- Lookup_MarkMarkPos, /* HB_GPOS_LOOKUP_MARKMARK 6 */
- Lookup_ContextPos, /* HB_GPOS_LOOKUP_CONTEXT 7 */
- Lookup_ChainContextPos, /* HB_GPOS_LOOKUP_CHAIN 8 */
- Lookup_DefaultPos, /* HB_GPOS_LOOKUP_EXTENSION 9 */
-};
-
-/* Do an individual subtable lookup. Returns FT_Err_Ok if positioning
+/* Do an individual subtable lookup. Returns HB_Err_Ok if positioning
has been done, or HB_Err_Not_Covered if not. */
-static FT_Error GPOS_Do_Glyph_Lookup( GPOS_Instance* gpi,
+static HB_Error GPOS_Do_Glyph_Lookup( GPOS_Instance* gpi,
FT_UShort lookup_index,
HB_Buffer buffer,
FT_UShort context_length,
int nesting_level )
{
- FT_Error error = HB_Err_Not_Covered;
+ HB_Error error = HB_Err_Not_Covered;
FT_UShort i, flags, lookup_count;
HB_GPOSHeader* gpos = gpi->gpos;
HB_Lookup* lo;
int lookup_type;
- Lookup_Pos_Func_Type Func;
nesting_level++;
if ( nesting_level > HB_MAX_NESTING_LEVEL )
- return HB_Err_Too_Many_Nested_Contexts;
+ return _hb_err(HB_Err_Too_Many_Nested_Contexts);
lookup_count = gpos->LookupList.LookupCount;
if (lookup_index >= lookup_count)
lo = &gpos->LookupList.Lookup[lookup_index];
flags = lo->LookupFlag;
lookup_type = lo->LookupType;
- if (lookup_type >= ARRAY_LEN (Lookup_Pos_Call_Table))
- lookup_type = 0;
- Func = Lookup_Pos_Call_Table[lookup_type];
for ( i = 0; i < lo->SubTableCount; i++ )
{
- error = Func ( gpi,
- &lo->SubTable[i].st.gpos,
- buffer,
- flags, context_length,
- nesting_level );
+ HB_GPOS_SubTable *st = &lo->SubTable[i].st.gpos;
+
+ switch (lookup_type) {
+ case HB_GPOS_LOOKUP_SINGLE:
+ error = Lookup_SinglePos ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GPOS_LOOKUP_PAIR:
+ error = Lookup_PairPos ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GPOS_LOOKUP_CURSIVE:
+ error = Lookup_CursivePos ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GPOS_LOOKUP_MARKBASE:
+ error = Lookup_MarkBasePos ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GPOS_LOOKUP_MARKLIG:
+ error = Lookup_MarkLigPos ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GPOS_LOOKUP_MARKMARK:
+ error = Lookup_MarkMarkPos ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GPOS_LOOKUP_CONTEXT:
+ error = Lookup_ContextPos ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GPOS_LOOKUP_CHAIN:
+ error = Lookup_ChainContextPos ( gpi, st, buffer, flags, context_length, nesting_level ); break;
+ /*case HB_GPOS_LOOKUP_EXTENSION:
+ error = Lookup_ExtensionPos ( gpi, st, buffer, flags, context_length, nesting_level ); break;*/
+ default:
+ error = HB_Err_Not_Covered;
+ }
/* Check whether we have a successful positioning or an error other
than HB_Err_Not_Covered */
-
if ( error != HB_Err_Not_Covered )
return error;
}
}
-static FT_Error Load_DefaultPos( HB_GPOS_SubTable* st,
- FT_Stream stream )
-{
- FT_UNUSED(st);
- FT_UNUSED(stream);
- return HB_Err_Invalid_GPOS_SubTable_Format;
-}
-
-typedef FT_Error (*Load_Pos_Func_Type)( HB_GPOS_SubTable* st,
- FT_Stream stream );
-static const Load_Pos_Func_Type Load_Pos_Call_Table[] = {
- Load_DefaultPos,
- Load_SinglePos, /* HB_GPOS_LOOKUP_SINGLE 1 */
- Load_PairPos, /* HB_GPOS_LOOKUP_PAIR 2 */
- Load_CursivePos, /* HB_GPOS_LOOKUP_CURSIVE 3 */
- Load_MarkBasePos, /* HB_GPOS_LOOKUP_MARKBASE 4 */
- Load_MarkLigPos, /* HB_GPOS_LOOKUP_MARKLIG 5 */
- Load_MarkMarkPos, /* HB_GPOS_LOOKUP_MARKMARK 6 */
- Load_ContextPos, /* HB_GPOS_LOOKUP_CONTEXT 7 */
- Load_ChainContextPos, /* HB_GPOS_LOOKUP_CHAIN 8 */
- Load_DefaultPos, /* HB_GPOS_LOOKUP_EXTENSION 9 */
-};
-
-FT_Error _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
+HB_Error _HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
FT_Stream stream,
FT_UShort lookup_type )
{
- Load_Pos_Func_Type Func;
-
- if (lookup_type >= ARRAY_LEN (Load_Pos_Call_Table))
- lookup_type = 0;
-
- Func = Load_Pos_Call_Table[lookup_type];
-
- return Func ( st, stream );
-}
-
-
-static void Free_DefaultPos( HB_GPOS_SubTable* st,
- FT_Memory memory )
-{
- FT_UNUSED(st);
- FT_UNUSED(memory);
+ switch ( lookup_type ) {
+ case HB_GPOS_LOOKUP_SINGLE: return Load_SinglePos ( st, stream );
+ case HB_GPOS_LOOKUP_PAIR: return Load_PairPos ( st, stream );
+ case HB_GPOS_LOOKUP_CURSIVE: return Load_CursivePos ( st, stream );
+ case HB_GPOS_LOOKUP_MARKBASE: return Load_MarkBasePos ( st, stream );
+ case HB_GPOS_LOOKUP_MARKLIG: return Load_MarkLigPos ( st, stream );
+ case HB_GPOS_LOOKUP_MARKMARK: return Load_MarkMarkPos ( st, stream );
+ case HB_GPOS_LOOKUP_CONTEXT: return Load_ContextPos ( st, stream );
+ case HB_GPOS_LOOKUP_CHAIN: return Load_ChainContextPos ( st, stream );
+ /*case HB_GPOS_LOOKUP_EXTENSION: return Load_ExtensionPos ( st, stream );*/
+ default: return _hb_err(HB_Err_Invalid_GPOS_SubTable_Format);
+ }
}
-typedef void (*Free_Pos_Func_Type)( HB_GPOS_SubTable* st,
- FT_Memory memory );
-static const Free_Pos_Func_Type Free_Pos_Call_Table[] = {
- Free_DefaultPos,
- Free_SinglePos, /* HB_GPOS_LOOKUP_SINGLE 1 */
- Free_PairPos, /* HB_GPOS_LOOKUP_PAIR 2 */
- Free_CursivePos, /* HB_GPOS_LOOKUP_CURSIVE 3 */
- Free_MarkBasePos, /* HB_GPOS_LOOKUP_MARKBASE 4 */
- Free_MarkLigPos, /* HB_GPOS_LOOKUP_MARKLIG 5 */
- Free_MarkMarkPos, /* HB_GPOS_LOOKUP_MARKMARK 6 */
- Free_ContextPos, /* HB_GPOS_LOOKUP_CONTEXT 7 */
- Free_ChainContextPos, /* HB_GPOS_LOOKUP_CHAIN 8 */
- Free_DefaultPos, /* HB_GPOS_LOOKUP_EXTENSION 9 */
-};
void _HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st,
FT_Memory memory,
FT_UShort lookup_type )
{
- Free_Pos_Func_Type Func;
-
- if (lookup_type >= ARRAY_LEN (Free_Pos_Call_Table))
- lookup_type = 0;
-
- Func = Free_Pos_Call_Table[lookup_type];
-
- Func ( st, memory );
+ switch ( lookup_type ) {
+ case HB_GPOS_LOOKUP_SINGLE: Free_SinglePos ( st, memory ); return;
+ case HB_GPOS_LOOKUP_PAIR: Free_PairPos ( st, memory ); return;
+ case HB_GPOS_LOOKUP_CURSIVE: Free_CursivePos ( st, memory ); return;
+ case HB_GPOS_LOOKUP_MARKBASE: Free_MarkBasePos ( st, memory ); return;
+ case HB_GPOS_LOOKUP_MARKLIG: Free_MarkLigPos ( st, memory ); return;
+ case HB_GPOS_LOOKUP_MARKMARK: Free_MarkMarkPos ( st, memory ); return;
+ case HB_GPOS_LOOKUP_CONTEXT: Free_ContextPos ( st, memory ); return;
+ case HB_GPOS_LOOKUP_CHAIN: Free_ChainContextPos ( st, memory ); return;
+ /*case HB_GPOS_LOOKUP_EXTENSION: Free_ExtensionPos ( st, memory ); return;*/
+ default: return;
+ }
}
-
/* apply one lookup to the input string object */
-static FT_Error GPOS_Do_String_Lookup( GPOS_Instance* gpi,
+static HB_Error GPOS_Do_String_Lookup( GPOS_Instance* gpi,
FT_UShort lookup_index,
HB_Buffer buffer )
{
- FT_Error error, retError = HB_Err_Not_Covered;
+ HB_Error error, retError = HB_Err_Not_Covered;
HB_GPOSHeader* gpos = gpi->gpos;
FT_UInt* properties = gpos->LookupList.Properties;
- int nesting_level = 0;
+ const int nesting_level = 0;
+ /* 0xFFFF indicates that we don't have a context length yet */
+ const FT_UShort context_length = 0xFFFF;
gpi->last = 0xFFFF; /* no last valid glyph for cursive pos. */
buffer->in_pos = 0;
-
while ( buffer->in_pos < buffer->in_length )
{
if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )
{
- /* 0xFFFF indicates that we don't have a context length yet. */
-
/* Note that the connection between mark and base glyphs hold
exactly one (string) lookup. For example, it would be possible
that in the first lookup, mark glyph X is attached to base
It is up to the font designer to provide meaningful lookups and
lookup order. */
- error = GPOS_Do_Glyph_Lookup( gpi, lookup_index, buffer,
- 0xFFFF, nesting_level );
+ error = GPOS_Do_Glyph_Lookup( gpi, lookup_index, buffer, context_length, nesting_level );
if ( error && error != HB_Err_Not_Covered )
return error;
}
}
-static FT_Error Position_CursiveChain ( HB_Buffer buffer )
+static HB_Error Position_CursiveChain ( HB_Buffer buffer )
{
FT_ULong i, j;
HB_Position positions = buffer->positions;
positions[j].y_pos += positions[j - positions[j].cursive_chain].y_pos;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GPOS_Add_Feature( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Add_Feature( HB_GPOSHeader* gpos,
FT_UShort feature_index,
FT_UInt property )
{
if ( !gpos ||
feature_index >= gpos->FeatureList.FeatureCount ||
gpos->FeatureList.ApplyCount == gpos->FeatureList.FeatureCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gpos->FeatureList.ApplyOrder[gpos->FeatureList.ApplyCount++] = feature_index;
properties[lookup_index] |= property;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GPOS_Clear_Features( HB_GPOSHeader* gpos )
+HB_Error HB_GPOS_Clear_Features( HB_GPOSHeader* gpos )
{
FT_UShort i;
if ( !gpos )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gpos->FeatureList.ApplyCount = 0;
for ( i = 0; i < gpos->LookupList.LookupCount; i++ )
properties[i] = 0;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GPOS_Register_Glyph_Function( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Register_Glyph_Function( HB_GPOSHeader* gpos,
HB_GlyphFunction gfunc )
{
if ( !gpos )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gpos->gfunc = gfunc;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GPOS_Register_MM_Function( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Register_MM_Function( HB_GPOSHeader* gpos,
HB_MMFunction mmfunc,
void* data )
{
if ( !gpos )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gpos->mmfunc = mmfunc;
gpos->data = data;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* If `dvi' is TRUE, glyph contour points for anchor points and device
tables are ignored -- you will get device independent values. */
-FT_Error HB_GPOS_Apply_String( FT_Face face,
+HB_Error HB_GPOS_Apply_String( FT_Face face,
HB_GPOSHeader* gpos,
- FT_UShort load_flags,
+ FT_UShort load_flags,
HB_Buffer buffer,
- FT_Bool dvi,
- FT_Bool r2l )
+ FT_Bool dvi,
+ FT_Bool r2l )
{
- FT_Error error, retError = HB_Err_Not_Covered;
+ HB_Error error, retError = HB_Err_Not_Covered;
GPOS_Instance gpi;
- FT_UShort i, j, feature_index, lookup_count;
- HB_Feature feature;
+ FT_UShort i, j, lookup_count;
+
+ if ( !face || !gpos || !buffer )
+ return HB_Err_Invalid_Argument;
- if ( !face || !gpos ||
- !buffer || buffer->in_length == 0 || buffer->in_pos >= buffer->in_length )
- return FT_Err_Invalid_Argument;
+ if ( buffer->in_length == 0 )
+ return HB_Err_Not_Covered;
gpi.face = face;
gpi.gpos = gpos;
for ( i = 0; i < gpos->FeatureList.ApplyCount; i++ )
{
- /* index of i'th feature */
- feature_index = gpos->FeatureList.ApplyOrder[i];
- feature = gpos->FeatureList.FeatureRecord[feature_index].Feature;
+ FT_UShort feature_index = gpos->FeatureList.ApplyOrder[i];
+ HB_Feature feature = gpos->FeatureList.FeatureRecord[feature_index].Feature;
for ( j = 0; j < feature.LookupListCount; j++ )
{
_glyph = HANDLE_Glyph( glyph ) */
-typedef FT_Error (*HB_GlyphFunction)(FT_Face face,
+typedef HB_Error (*HB_GlyphFunction)(FT_Face face,
FT_UInt glyphIndex,
FT_Int loadFlags );
`metric_value' must be returned as a scaled value (but shouldn't
be rounded). */
-typedef FT_Error (*HB_MMFunction)(FT_Face face,
+typedef HB_Error (*HB_MMFunction)(FT_Face face,
FT_UShort metric_id,
FT_Pos* metric_value,
void* data );
typedef HB_GPOSHeader* HB_GPOS;
-FT_Error HB_Load_GPOS_Table( FT_Face face,
+HB_Error HB_Load_GPOS_Table( FT_Face face,
HB_GPOSHeader** gpos,
HB_GDEFHeader* gdef );
-FT_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos );
+HB_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos );
-FT_Error HB_GPOS_Select_Script( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Select_Script( HB_GPOSHeader* gpos,
FT_ULong script_tag,
FT_UShort* script_index );
-FT_Error HB_GPOS_Select_Language( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Select_Language( HB_GPOSHeader* gpos,
FT_ULong language_tag,
FT_UShort script_index,
FT_UShort* language_index,
FT_UShort* req_feature_index );
-FT_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
FT_ULong feature_tag,
FT_UShort script_index,
FT_UShort language_index,
FT_UShort* feature_index );
-FT_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos,
FT_ULong** script_tag_list );
-FT_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos,
FT_UShort script_index,
FT_ULong** language_tag_list );
-FT_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
FT_UShort script_index,
FT_UShort language_index,
FT_ULong** feature_tag_list );
-FT_Error HB_GPOS_Add_Feature( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Add_Feature( HB_GPOSHeader* gpos,
FT_UShort feature_index,
FT_UInt property );
-FT_Error HB_GPOS_Clear_Features( HB_GPOSHeader* gpos );
+HB_Error HB_GPOS_Clear_Features( HB_GPOSHeader* gpos );
-FT_Error HB_GPOS_Register_Glyph_Function( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Register_Glyph_Function( HB_GPOSHeader* gpos,
HB_GlyphFunction gfunc );
-FT_Error HB_GPOS_Register_MM_Function( HB_GPOSHeader* gpos,
+HB_Error HB_GPOS_Register_MM_Function( HB_GPOSHeader* gpos,
HB_MMFunction mmfunc,
void* data );
tables are ignored -- you will get device independent values. */
-FT_Error HB_GPOS_Apply_String( FT_Face face,
+HB_Error HB_GPOS_Apply_String( FT_Face face,
HB_GPOSHeader* gpos,
FT_UShort load_flags,
HB_Buffer buffer,
-FT_Error _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
+HB_Error _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
FT_Stream stream,
FT_UShort lookup_type );
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* Copyright 2006 Behdad Esfahbod
+ * Copyright 2007 Red Hat Software
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
#include "harfbuzz-open-private.h"
#include "harfbuzz-gdef-private.h"
-static FT_Error GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
+static HB_Error GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
FT_UShort lookup_index,
HB_Buffer buffer,
FT_UShort context_length,
-FT_Error HB_Load_GSUB_Table( FT_Face face,
+HB_Error HB_Load_GSUB_Table( FT_Face face,
HB_GSUBHeader** retptr,
HB_GDEFHeader* gdef )
{
FT_Stream stream = face->stream;
FT_Memory memory = face->memory;
- FT_Error error;
+ HB_Error error;
FT_ULong cur_offset, new_offset, base_offset;
FT_UShort i, num_lookups;
HB_Lookup* lo;
if ( !retptr )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
if (( error = _hb_ftglue_face_goto_table( face, TTAG_GSUB, stream ) ))
return error;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_ScriptList( &gsub->ScriptList,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail4;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_FeatureList( &gsub->FeatureList,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_LookupList( &gsub->LookupList,
- stream, HB_Type_GSUB ) ) != FT_Err_Ok )
+ stream, HB_Type_GSUB ) ) != HB_Err_Ok )
goto Fail2;
gsub->gdef = gdef; /* can be NULL */
{
if ( FILE_Seek( gdef->MarkAttachClassDef_offset ) ||
( error = _HB_OPEN_Load_ClassDefinition( &gdef->MarkAttachClassDef,
- 256, stream ) ) != FT_Err_Ok )
+ 256, stream ) ) != HB_Err_Ok )
goto Fail1;
break;
*retptr = gsub;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
_HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB, memory );
}
-FT_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub )
+HB_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub )
{
FT_Memory memory = gsub->memory;
FREE( gsub );
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/*****************************
* SubTable related functions
*****************************/
-static FT_Error Lookup_DefaultSubst( HB_GSUBHeader* gsub,
- HB_GSUB_SubTable* st,
- HB_Buffer buffer,
- FT_UShort flags,
- FT_UShort context_length,
- int nesting_level )
-{
- FT_UNUSED(gsub);
- FT_UNUSED(st);
- FT_UNUSED(buffer);
- FT_UNUSED(flags);
- FT_UNUSED(context_length);
- FT_UNUSED(nesting_level);
- return HB_Err_Not_Covered;
-}
-
/* LookupType 1 */
/* SingleSubstFormat1 */
/* SingleSubstFormat2 */
-static FT_Error Load_SingleSubst( HB_GSUB_SubTable* st,
+static HB_Error Load_SingleSubst( HB_GSUB_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_SingleSubst* ss = &st->single;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &ss->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &ss->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
break;
default:
- return HB_Err_Invalid_GSUB_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( s );
case 2:
FREE( ss->ssf.ssf2.Substitute );
break;
+
+ default:
+ break;
}
_HB_OPEN_Free_Coverage( &ss->Coverage, memory );
}
-static FT_Error Lookup_SingleSubst( HB_GSUBHeader* gsub,
+static HB_Error Lookup_SingleSubst( HB_GSUBHeader* gsub,
HB_GSUB_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
int nesting_level )
{
FT_UShort index, value, property;
- FT_Error error;
+ HB_Error error;
HB_SingleSubst* ss = &st->single;
HB_GDEFHeader* gdef = gsub->gdef;
FT_UNUSED(nesting_level);
-
if ( context_length != 0xFFFF && context_length < 1 )
return HB_Err_Not_Covered;
switch ( ss->SubstFormat )
{
case 1:
- value = ( IN_CURGLYPH() + ss->ssf.ssf1.DeltaGlyphID ) & 0xFFFF;
- if ( ADD_Glyph( buffer, value, 0xFFFF, 0xFFFF ) )
+ value = (IN_CURGLYPH() + ss->ssf.ssf1.DeltaGlyphID ) & 0xFFFF;
+ if ( REPLACE_Glyph( buffer, value, nesting_level ) )
return error;
break;
case 2:
if ( index >= ss->ssf.ssf2.GlyphCount )
- return HB_Err_Invalid_GSUB_SubTable;
+ return _hb_err(HB_Err_Invalid_GSUB_SubTable);
value = ss->ssf.ssf2.Substitute[index];
- if ( ADD_Glyph( buffer, value, 0xFFFF, 0xFFFF ) )
+ if ( REPLACE_Glyph( buffer, value, nesting_level ) )
return error;
break;
default:
- return HB_Err_Invalid_GSUB_SubTable;
+ return _hb_err(HB_Err_Invalid_GSUB_SubTable);
}
if ( gdef && gdef->NewGlyphClasses )
return error;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* Sequence */
-static FT_Error Load_Sequence( HB_Sequence* s,
+static HB_Error Load_Sequence( HB_Sequence* s,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* MultipleSubstFormat1 */
-static FT_Error Load_MultipleSubst( HB_GSUB_SubTable* st,
+static HB_Error Load_MultipleSubst( HB_GSUB_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_MultipleSubst* ms = &st->multiple;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &ms->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &ms->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_Sequence( &s[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_Sequence( &s[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
}
-static FT_Error Lookup_MultipleSubst( HB_GSUBHeader* gsub,
+static HB_Error Lookup_MultipleSubst( HB_GSUBHeader* gsub,
HB_GSUB_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
- FT_Error error;
+ HB_Error error;
FT_UShort index, property, n, count;
FT_UShort*s;
HB_MultipleSubst* ms = &st->multiple;
return error;
if ( index >= ms->SequenceCount )
- return HB_Err_Invalid_GSUB_SubTable;
+ return _hb_err(HB_Err_Invalid_GSUB_SubTable);
count = ms->Sequence[index].GlyphCount;
s = ms->Sequence[index].Substitute;
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* AlternateSet */
-static FT_Error Load_AlternateSet( HB_AlternateSet* as,
+static HB_Error Load_AlternateSet( HB_AlternateSet* as,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* AlternateSubstFormat1 */
-static FT_Error Load_AlternateSubst( HB_GSUB_SubTable* st,
+static HB_Error Load_AlternateSubst( HB_GSUB_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_AlternateSubst* as = &st->alternate;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &as->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &as->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_AlternateSet( &aset[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_AlternateSet( &aset[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
}
-static FT_Error Lookup_AlternateSubst( HB_GSUBHeader* gsub,
+static HB_Error Lookup_AlternateSubst( HB_GSUBHeader* gsub,
HB_GSUB_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
- FT_Error error;
- FT_UShort index, alt_index, property;
+ HB_Error error;
+ FT_UShort index, value, alt_index, property;
HB_AlternateSubst* as = &st->alternate;
HB_GDEFHeader* gdef = gsub->gdef;
HB_AlternateSet aset;
else
alt_index = 0;
- if ( ADD_Glyph( buffer, aset.Alternate[alt_index],
- 0xFFFF, 0xFFFF ) )
+ value = aset.Alternate[alt_index];
+ if ( REPLACE_Glyph( buffer, value, nesting_level ) )
return error;
if ( gdef && gdef->NewGlyphClasses )
{
/* we inherit the old glyph class to the substituted glyph */
- error = _HB_GDEF_Add_Glyph_Property( gdef, aset.Alternate[alt_index],
- property );
+ error = _HB_GDEF_Add_Glyph_Property( gdef, value, property );
if ( error && error != HB_Err_Not_Covered )
return error;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* Ligature */
-static FT_Error Load_Ligature( HB_Ligature* l,
+static HB_Error Load_Ligature( HB_Ligature* l,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* LigatureSet */
-static FT_Error Load_LigatureSet( HB_LigatureSet* ls,
+static HB_Error Load_LigatureSet( HB_LigatureSet* ls,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_Ligature( &l[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_Ligature( &l[n], stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* LigatureSubstFormat1 */
-static FT_Error Load_LigatureSubst( HB_GSUB_SubTable* st,
+static HB_Error Load_LigatureSubst( HB_GSUB_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_LigatureSubst* ls = &st->ligature;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &ls->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &ls->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_LigatureSet( &lset[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_LigatureSet( &lset[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
}
-static FT_Error Lookup_LigatureSubst( HB_GSUBHeader* gsub,
+static HB_Error Lookup_LigatureSubst( HB_GSUBHeader* gsub,
HB_GSUB_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
int nesting_level )
{
FT_UShort index, property;
- FT_Error error;
+ HB_Error error;
FT_UShort numlig, i, j, is_mark, first_is_mark = FALSE;
FT_UShort* c;
HB_LigatureSubst* ls = &st->ligature;
return error;
if ( index >= ls->LigatureSetCount )
- return HB_Err_Invalid_GSUB_SubTable;
+ return _hb_err(HB_Err_Invalid_GSUB_SubTable);
lig = ls->LigatureSet[index].Ligature;
else
{
FT_UShort ligID = hb_buffer_allocate_ligid( buffer );
- if ( ADD_Glyph( buffer, lig->LigGlyph,
- 0xFFFF, ligID ) )
+ if ( ADD_Glyph( buffer, lig->LigGlyph, 0xFFFF, ligID ) )
return error;
/* Now we must do a second loop to copy the skipped glyphs to
{
while ( CHECK_Property( gdef, IN_CURITEM(),
flags, &property ) )
- if ( ADD_Glyph( buffer, IN_CURGLYPH(),
- i, ligID ) )
+ if ( ADD_Glyph( buffer, IN_CURGLYPH(), i, ligID ) )
return error;
(buffer->in_pos)++;
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
next_ligature:
;
5 or 6). This is only called after we've determined that the input
matches the subrule. */
-static FT_Error Do_ContextSubst( HB_GSUBHeader* gsub,
+static HB_Error Do_ContextSubst( HB_GSUBHeader* gsub,
FT_UShort GlyphCount,
FT_UShort SubstCount,
HB_SubstLookupRecord* subst,
HB_Buffer buffer,
int nesting_level )
{
- FT_Error error;
+ HB_Error error;
FT_ULong i, old_pos;
if ( error == HB_Err_Not_Covered )
{
- /* XXX "can't happen" -- but don't count on it */
-
- if ( ADD_Glyph( buffer, IN_CURGLYPH(),
- 0xFFFF, 0xFFFF ) )
+ if ( COPY_Glyph( buffer ) )
return error;
i++;
}
{
/* No substitution for this index */
- if ( ADD_Glyph( buffer, IN_CURGLYPH(),
- 0xFFFF, 0xFFFF ) )
+ if ( COPY_Glyph( buffer ) )
return error;
i++;
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* SubRule */
-static FT_Error Load_SubRule( HB_SubRule* sr,
+static HB_Error Load_SubRule( HB_SubRule* sr,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
/* SubRuleSet */
-static FT_Error Load_SubRuleSet( HB_SubRuleSet* srs,
+static HB_Error Load_SubRuleSet( HB_SubRuleSet* srs,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_SubRule( &sr[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_SubRule( &sr[n], stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* ContextSubstFormat1 */
-static FT_Error Load_ContextSubst1( HB_ContextSubstFormat1* csf1,
+static HB_Error Load_ContextSubst1( HB_ContextSubstFormat1* csf1,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &csf1->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &csf1->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_SubRuleSet( &srs[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_SubRuleSet( &srs[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* SubClassRule */
-static FT_Error Load_SubClassRule( HB_ContextSubstFormat2* csf2,
+static HB_Error Load_SubClassRule( HB_ContextSubstFormat2* csf2,
HB_SubClassRule* scr,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
/* SubClassSet */
-static FT_Error Load_SubClassSet( HB_ContextSubstFormat2* csf2,
+static HB_Error Load_SubClassSet( HB_ContextSubstFormat2* csf2,
HB_SubClassSet* scs,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_SubClassRule( csf2, &scr[n],
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* ContextSubstFormat2 */
-static FT_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2,
+static HB_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &csf2->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &csf2->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = _HB_OPEN_Load_ClassDefinition( &csf2->ClassDef, count,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_SubClassSet( csf2, &scs[n],
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* ContextSubstFormat3 */
-static FT_Error Load_ContextSubst3( HB_ContextSubstFormat3* csf3,
+static HB_Error Load_ContextSubst3( HB_ContextSubstFormat3* csf3,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &c[n], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &c[n], stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
}
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
/* ContextSubst */
-static FT_Error Load_ContextSubst( HB_GSUB_SubTable* st,
+static HB_Error Load_ContextSubst( HB_GSUB_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
HB_ContextSubst* cs = &st->context;
switch ( cs->SubstFormat )
{
- case 1:
- return Load_ContextSubst1( &cs->csf.csf1, stream );
-
- case 2:
- return Load_ContextSubst2( &cs->csf.csf2, stream );
-
- case 3:
- return Load_ContextSubst3( &cs->csf.csf3, stream );
-
- default:
- return HB_Err_Invalid_GSUB_SubTable_Format;
+ case 1: return Load_ContextSubst1( &cs->csf.csf1, stream );
+ case 2: return Load_ContextSubst2( &cs->csf.csf2, stream );
+ case 3: return Load_ContextSubst3( &cs->csf.csf3, stream );
+ default: return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
switch ( cs->SubstFormat )
{
- case 1:
- Free_ContextSubst1( &cs->csf.csf1, memory );
- break;
-
- case 2:
- Free_ContextSubst2( &cs->csf.csf2, memory );
- break;
-
- case 3:
- Free_ContextSubst3( &cs->csf.csf3, memory );
- break;
+ case 1: Free_ContextSubst1( &cs->csf.csf1, memory ); break;
+ case 2: Free_ContextSubst2( &cs->csf.csf2, memory ); break;
+ case 3: Free_ContextSubst3( &cs->csf.csf3, memory ); break;
+ default: break;
}
}
-static FT_Error Lookup_ContextSubst1( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ContextSubst1( HB_GSUBHeader* gsub,
HB_ContextSubstFormat1* csf1,
HB_Buffer buffer,
FT_UShort flags,
{
FT_UShort index, property;
FT_UShort i, j, k, numsr;
- FT_Error error;
+ HB_Error error;
HB_SubRule* sr;
HB_GDEFHeader* gdef;
}
-static FT_Error Lookup_ContextSubst2( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ContextSubst2( HB_GSUBHeader* gsub,
HB_ContextSubstFormat2* csf2,
HB_Buffer buffer,
FT_UShort flags,
int nesting_level )
{
FT_UShort index, property;
- FT_Error error;
+ HB_Error error;
FT_Memory memory = gsub->memory;
FT_UShort i, j, k, known_classes;
scs = &csf2->SubClassSet[classes[0]];
if ( !scs )
{
- error = HB_Err_Invalid_GSUB_SubTable;
+ error = _hb_err(HB_Err_Invalid_GSUB_SubTable);
goto End;
}
}
-static FT_Error Lookup_ContextSubst3( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ContextSubst3( HB_GSUBHeader* gsub,
HB_ContextSubstFormat3* csf3,
HB_Buffer buffer,
FT_UShort flags,
FT_UShort context_length,
int nesting_level )
{
- FT_Error error;
+ HB_Error error;
FT_UShort index, i, j, property;
HB_Coverage* c;
}
-static FT_Error Lookup_ContextSubst( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ContextSubst( HB_GSUBHeader* gsub,
HB_GSUB_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
switch ( cs->SubstFormat )
{
- case 1:
- return Lookup_ContextSubst1( gsub, &cs->csf.csf1, buffer,
- flags, context_length, nesting_level );
-
- case 2:
- return Lookup_ContextSubst2( gsub, &cs->csf.csf2, buffer,
- flags, context_length, nesting_level );
-
- case 3:
- return Lookup_ContextSubst3( gsub, &cs->csf.csf3, buffer,
- flags, context_length, nesting_level );
-
- default:
- return HB_Err_Invalid_GSUB_SubTable_Format;
+ case 1: return Lookup_ContextSubst1( gsub, &cs->csf.csf1, buffer, flags, context_length, nesting_level );
+ case 2: return Lookup_ContextSubst2( gsub, &cs->csf.csf2, buffer, flags, context_length, nesting_level );
+ case 3: return Lookup_ContextSubst3( gsub, &cs->csf.csf3, buffer, flags, context_length, nesting_level );
+ default: return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
/* ChainSubRule */
-static FT_Error Load_ChainSubRule( HB_ChainSubRule* csr,
+static HB_Error Load_ChainSubRule( HB_ChainSubRule* csr,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
/* ChainSubRuleSet */
-static FT_Error Load_ChainSubRuleSet( HB_ChainSubRuleSet* csrs,
+static HB_Error Load_ChainSubRuleSet( HB_ChainSubRuleSet* csrs,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_ChainSubRule( &csr[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_ChainSubRule( &csr[n], stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* ChainContextSubstFormat1 */
-static FT_Error Load_ChainContextSubst1(
+static HB_Error Load_ChainContextSubst1(
HB_ChainContextSubstFormat1* ccsf1,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &ccsf1->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &ccsf1->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_ChainSubRuleSet( &csrs[n], stream ) ) != FT_Err_Ok )
+ ( error = Load_ChainSubRuleSet( &csrs[n], stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* ChainSubClassRule */
-static FT_Error Load_ChainSubClassRule(
+static HB_Error Load_ChainSubClassRule(
HB_ChainContextSubstFormat2* ccsf2,
HB_ChainSubClassRule* cscr,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
/* SubClassSet */
-static FT_Error Load_ChainSubClassSet(
+static HB_Error Load_ChainSubClassSet(
HB_ChainContextSubstFormat2* ccsf2,
HB_ChainSubClassSet* cscs,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_ChainSubClassRule( ccsf2, &cscr[n],
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
}
}
-static FT_Error GSUB_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
+static HB_Error GSUB_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
FT_UShort limit,
FT_ULong class_offset,
FT_ULong base_offset,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_ULong cur_offset;
cur_offset = FILE_Pos();
else
error = _HB_OPEN_Load_EmptyClassDefinition ( cd, stream );
- if (error == FT_Err_Ok)
+ if (error == HB_Err_Ok)
(void)FILE_Seek( cur_offset ); /* Changes error as a side-effect */
return error;
/* ChainContextSubstFormat2 */
-static FT_Error Load_ChainContextSubst2(
+static HB_Error Load_ChainContextSubst2(
HB_ChainContextSubstFormat2* ccsf2,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &ccsf2->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &ccsf2->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->BacktrackClassDef, 65535,
backtrack_offset, base_offset,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail5;
if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->InputClassDef, count,
input_offset, base_offset,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail4;
if ( ( error = GSUB_Load_EmptyOrClassDefinition( &ccsf2->LookaheadClassDef, 65535,
lookahead_offset, base_offset,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail3;
ccsf2->ChainSubClassSet = NULL;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_ChainSubClassSet( ccsf2, &cscs[n],
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* ChainContextSubstFormat3 */
-static FT_Error Load_ChainContextSubst3(
+static HB_Error Load_ChainContextSubst3(
HB_ChainContextSubstFormat3* ccsf3,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, nb = 0, ni =0, nl = 0, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )
goto Fail4;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &i[ni], stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
}
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
/* ChainContextSubst */
-static FT_Error Load_ChainContextSubst( HB_GSUB_SubTable* st,
+static HB_Error Load_ChainContextSubst( HB_GSUB_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
HB_ChainContextSubst* ccs = &st->chain;
if ( ACCESS_Frame( 2L ) )
FORGET_Frame();
- switch ( ccs->SubstFormat )
- {
- case 1:
- return Load_ChainContextSubst1( &ccs->ccsf.ccsf1, stream );
-
- case 2:
- return Load_ChainContextSubst2( &ccs->ccsf.ccsf2, stream );
-
- case 3:
- return Load_ChainContextSubst3( &ccs->ccsf.ccsf3, stream );
-
- default:
- return HB_Err_Invalid_GSUB_SubTable_Format;
+ switch ( ccs->SubstFormat ) {
+ case 1: return Load_ChainContextSubst1( &ccs->ccsf.ccsf1, stream );
+ case 2: return Load_ChainContextSubst2( &ccs->ccsf.ccsf2, stream );
+ case 3: return Load_ChainContextSubst3( &ccs->ccsf.ccsf3, stream );
+ default: return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
{
HB_ChainContextSubst* ccs = &st->chain;
- switch ( ccs->SubstFormat )
- {
- case 1:
- Free_ChainContextSubst1( &ccs->ccsf.ccsf1, memory );
- break;
-
- case 2:
- Free_ChainContextSubst2( &ccs->ccsf.ccsf2, memory );
- break;
-
- case 3:
- Free_ChainContextSubst3( &ccs->ccsf.ccsf3, memory );
- break;
+ switch ( ccs->SubstFormat ) {
+ case 1: Free_ChainContextSubst1( &ccs->ccsf.ccsf1, memory ); break;
+ case 2: Free_ChainContextSubst2( &ccs->ccsf.ccsf2, memory ); break;
+ case 3: Free_ChainContextSubst3( &ccs->ccsf.ccsf3, memory ); break;
+ default: break;
}
}
-static FT_Error Lookup_ChainContextSubst1( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ChainContextSubst1( HB_GSUBHeader* gsub,
HB_ChainContextSubstFormat1* ccsf1,
HB_Buffer buffer,
FT_UShort flags,
FT_UShort index, property;
FT_UShort i, j, k, num_csr;
FT_UShort bgc, igc, lgc;
- FT_Error error;
+ HB_Error error;
HB_ChainSubRule* csr;
HB_ChainSubRule curr_csr;
}
-static FT_Error Lookup_ChainContextSubst2( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ChainContextSubst2( HB_GSUBHeader* gsub,
HB_ChainContextSubstFormat2* ccsf2,
HB_Buffer buffer,
FT_UShort flags,
{
FT_UShort index, property;
FT_Memory memory;
- FT_Error error;
+ HB_Error error;
FT_UShort i, j, k;
FT_UShort bgc, igc, lgc;
FT_UShort known_backtrack_classes,
cscs = &ccsf2->ChainSubClassSet[input_classes[0]];
if ( !cscs )
{
- error = HB_Err_Invalid_GSUB_SubTable;
+ error = _hb_err(HB_Err_Invalid_GSUB_SubTable);
goto End1;
}
}
-static FT_Error Lookup_ChainContextSubst3( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ChainContextSubst3( HB_GSUBHeader* gsub,
HB_ChainContextSubstFormat3* ccsf3,
HB_Buffer buffer,
FT_UShort flags,
{
FT_UShort index, i, j, property;
FT_UShort bgc, igc, lgc;
- FT_Error error;
+ HB_Error error;
HB_Coverage* bc;
HB_Coverage* ic;
}
-static FT_Error Lookup_ChainContextSubst( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ChainContextSubst( HB_GSUBHeader* gsub,
HB_GSUB_SubTable* st,
HB_Buffer buffer,
FT_UShort flags,
{
HB_ChainContextSubst* ccs = &st->chain;
- switch ( ccs->SubstFormat )
- {
- case 1:
- return Lookup_ChainContextSubst1( gsub, &ccs->ccsf.ccsf1, buffer,
- flags, context_length,
- nesting_level );
-
- case 2:
- return Lookup_ChainContextSubst2( gsub, &ccs->ccsf.ccsf2, buffer,
- flags, context_length,
- nesting_level );
-
- case 3:
- return Lookup_ChainContextSubst3( gsub, &ccs->ccsf.ccsf3, buffer,
- flags, context_length,
- nesting_level );
-
- default:
- return HB_Err_Invalid_GSUB_SubTable_Format;
+ switch ( ccs->SubstFormat ) {
+ case 1: return Lookup_ChainContextSubst1( gsub, &ccs->ccsf.ccsf1, buffer, flags, context_length, nesting_level );
+ case 2: return Lookup_ChainContextSubst2( gsub, &ccs->ccsf.ccsf2, buffer, flags, context_length, nesting_level );
+ case 3: return Lookup_ChainContextSubst3( gsub, &ccs->ccsf.ccsf3, buffer, flags, context_length, nesting_level );
+ default: return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
}
-
- return FT_Err_Ok; /* never reached */
}
-static FT_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
+static HB_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
HB_ReverseChainContextSubst* rccs = &st->reverse;
rccs->SubstFormat = GET_UShort();
if ( rccs->SubstFormat != 1 )
- return HB_Err_Invalid_GSUB_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
FORGET_Frame();
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &rccs->Coverage, stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &rccs->Coverage, stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &b[nb], stream ) ) != HB_Err_Ok )
goto Fail3;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != FT_Err_Ok )
+ ( error = _HB_OPEN_Load_Coverage( &l[nl], stream ) ) != HB_Err_Ok )
goto Fail2;
(void)FILE_Seek( cur_offset );
}
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( sub );
}
-static FT_Error Lookup_ReverseChainContextSubst( HB_GSUBHeader* gsub,
+static HB_Error Lookup_ReverseChainContextSubst( HB_GSUBHeader* gsub,
HB_GSUB_SubTable* st,
HB_Buffer buffer,
- FT_UShort flags,
- /* note different signature here: */ FT_ULong string_index )
+ FT_UShort flags,
+ FT_UShort context_length,
+ int nesting_level )
{
FT_UShort index, input_index, i, j, property;
FT_UShort bgc, lgc;
- FT_Error error;
+ HB_Error error;
HB_ReverseChainContextSubst* rccs = &st->reverse;
HB_Coverage* bc;
HB_Coverage* lc;
HB_GDEFHeader* gdef;
+ if ( nesting_level != 1 || context_length != 0xFFFF )
+ return HB_Err_Not_Covered;
+
gdef = gsub->gdef;
- if ( CHECK_Property( gdef, IN_ITEM( string_index ), flags, &property ) )
+ if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
return error;
bgc = rccs->BacktrackGlyphCount;
/* check whether context is too long; it is a first guess only */
- if ( bgc > string_index || string_index + 1 + lgc > buffer->in_length )
+ if ( bgc > buffer->in_pos || buffer->in_pos + 1 + lgc > buffer->in_length )
return HB_Err_Not_Covered;
if ( bgc )
bc = rccs->BacktrackCoverage;
- for ( i = 0, j = string_index - 1; i < bgc; i++, j-- )
+ for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- )
{
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
}
}
- j = string_index;
+ j = buffer->in_pos;
error = _HB_OPEN_Coverage_Index( &rccs->Coverage, IN_GLYPH( j ), &input_index );
if ( error )
return error;
- /* we are starting for lookahead glyphs right after the last context
- glyph */
-
- j += 1;
-
lc = rccs->LookaheadCoverage;
- for ( i = 0; i < lgc; i++, j++ )
+ for ( i = 0, j = buffer->in_pos + 1; i < lgc; i++, j++ )
{
while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) )
{
return error;
}
- IN_GLYPH( string_index ) = rccs->Substitute[input_index];
+ IN_CURGLYPH() = rccs->Substitute[input_index];
+ buffer->in_pos--; /* Reverse! */
return error;
}
-FT_Error HB_GSUB_Select_Script( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Select_Script( HB_GSUBHeader* gsub,
FT_ULong script_tag,
FT_UShort* script_index )
{
if ( !gsub || !script_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gsub->ScriptList;
sr = sl->ScriptRecord;
{
*script_index = n;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
return HB_Err_Not_Covered;
-FT_Error HB_GSUB_Select_Language( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Select_Language( HB_GSUBHeader* gsub,
FT_ULong language_tag,
FT_UShort script_index,
FT_UShort* language_index,
if ( !gsub || !language_index || !req_feature_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gsub->ScriptList;
sr = sl->ScriptRecord;
if ( script_index >= sl->ScriptCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
s = &sr[script_index].Script;
lsr = s->LangSysRecord;
*language_index = n;
*req_feature_index = lsr[n].LangSys.ReqFeatureIndex;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
return HB_Err_Not_Covered;
default language (DefaultLangSys) */
-FT_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
FT_ULong feature_tag,
FT_UShort script_index,
FT_UShort language_index,
if ( !gsub || !feature_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gsub->ScriptList;
sr = sl->ScriptRecord;
fr = fl->FeatureRecord;
if ( script_index >= sl->ScriptCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
s = &sr[script_index].Script;
lsr = s->LangSysRecord;
else
{
if ( language_index >= s->LangSysCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
ls = &lsr[language_index].LangSys;
}
for ( n = 0; n < ls->FeatureCount; n++ )
{
if ( fi[n] >= fl->FeatureCount )
- return HB_Err_Invalid_GSUB_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
if ( feature_tag == fr[fi[n]].FeatureTag )
{
*feature_index = fi[n];
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
}
/* The next three functions return a null-terminated list */
-FT_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub,
FT_ULong** script_tag_list )
{
FT_UShort n;
- FT_Error error;
+ HB_Error error;
FT_Memory memory;
FT_ULong* stl;
if ( !gsub || !script_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gsub->memory;
*script_tag_list = stl;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
FT_UShort script_index,
FT_ULong** language_tag_list )
{
FT_UShort n;
- FT_Error error;
+ HB_Error error;
FT_Memory memory;
FT_ULong* ltl;
if ( !gsub || !language_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gsub->memory;
sr = sl->ScriptRecord;
if ( script_index >= sl->ScriptCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
s = &sr[script_index].Script;
lsr = s->LangSysRecord;
*language_tag_list = ltl;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
default language (DefaultLangSys) */
-FT_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
FT_UShort script_index,
FT_UShort language_index,
FT_ULong** feature_tag_list )
{
FT_UShort n;
- FT_Error error;
+ HB_Error error;
FT_Memory memory;
FT_ULong* ftl;
if ( !gsub || !feature_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gsub->memory;
fr = fl->FeatureRecord;
if ( script_index >= sl->ScriptCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
s = &sr[script_index].Script;
lsr = s->LangSysRecord;
else
{
if ( language_index >= s->LangSysCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
ls = &lsr[language_index].LangSys;
}
if ( fi[n] >= fl->FeatureCount )
{
FREE( ftl );
- return HB_Err_Invalid_GSUB_SubTable_Format;
+ return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
}
ftl[n] = fr[fi[n]].FeatureTag;
}
*feature_tag_list = ftl;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-typedef FT_Error (*Lookup_Subst_Func_Type)( HB_GSUBHeader* gsub,
- HB_GSUB_SubTable* st,
- HB_Buffer buffer,
- FT_UShort flags,
- FT_UShort context_length,
- int nesting_level );
-static const Lookup_Subst_Func_Type Lookup_Subst_Call_Table[] = {
- Lookup_DefaultSubst,
- Lookup_SingleSubst, /* HB_GSUB_LOOKUP_SINGLE 1 */
- Lookup_MultipleSubst, /* HB_GSUB_LOOKUP_MULTIPLE 2 */
- Lookup_AlternateSubst, /* HB_GSUB_LOOKUP_ALTERNATE 3 */
- Lookup_LigatureSubst, /* HB_GSUB_LOOKUP_LIGATURE 4 */
- Lookup_ContextSubst, /* HB_GSUB_LOOKUP_CONTEXT 5 */
- Lookup_ChainContextSubst, /* HB_GSUB_LOOKUP_CHAIN 6 */
- Lookup_DefaultSubst /* HB_GSUB_LOOKUP_EXTENSION 7 */
-};
-/* Note that the following lookup does not belong to the table above:
- * Lookup_ReverseChainContextSubst, HB_GSUB_LOOKUP_REVERSE_CHAIN 8
- * because it's invalid to happen where this table is used. It's
- * signature is different too...
- */
-
-/* Do an individual subtable lookup. Returns FT_Err_Ok if substitution
+/* Do an individual subtable lookup. Returns HB_Err_Ok if substitution
has been done, or HB_Err_Not_Covered if not. */
-static FT_Error GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
- FT_UShort lookup_index,
+static HB_Error GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
+ FT_UShort lookup_index,
HB_Buffer buffer,
- FT_UShort context_length,
- int nesting_level )
+ FT_UShort context_length,
+ int nesting_level )
{
- FT_Error error = HB_Err_Not_Covered;
+ HB_Error error = HB_Err_Not_Covered;
FT_UShort i, flags, lookup_count;
HB_Lookup* lo;
int lookup_type;
- Lookup_Subst_Func_Type Func;
-
nesting_level++;
if ( nesting_level > HB_MAX_NESTING_LEVEL )
- return HB_Err_Too_Many_Nested_Contexts;
+ return _hb_err(HB_Err_Too_Many_Nested_Contexts);
lookup_count = gsub->LookupList.LookupCount;
if (lookup_index >= lookup_count)
flags = lo->LookupFlag;
lookup_type = lo->LookupType;
- if (lookup_type >= ARRAY_LEN (Lookup_Subst_Call_Table))
- lookup_type = 0;
- Func = Lookup_Subst_Call_Table[lookup_type];
-
for ( i = 0; i < lo->SubTableCount; i++ )
{
- error = Func ( gsub,
- &lo->SubTable[i].st.gsub,
- buffer,
- flags, context_length,
- nesting_level );
+ HB_GSUB_SubTable *st = &lo->SubTable[i].st.gsub;
+
+ switch (lookup_type) {
+ case HB_GSUB_LOOKUP_SINGLE:
+ error = Lookup_SingleSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GSUB_LOOKUP_MULTIPLE:
+ error = Lookup_MultipleSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GSUB_LOOKUP_ALTERNATE:
+ error = Lookup_AlternateSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GSUB_LOOKUP_LIGATURE:
+ error = Lookup_LigatureSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GSUB_LOOKUP_CONTEXT:
+ error = Lookup_ContextSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+ case HB_GSUB_LOOKUP_CHAIN:
+ error = Lookup_ChainContextSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+ /*case HB_GSUB_LOOKUP_EXTENSION:
+ error = Lookup_ExtensionSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;*/
+ case HB_GSUB_LOOKUP_REVERSE_CHAIN:
+ error = Lookup_ReverseChainContextSubst ( gsub, st, buffer, flags, context_length, nesting_level ); break;
+ default:
+ error = HB_Err_Not_Covered;
+ };
/* Check whether we have a successful substitution or an error other
than HB_Err_Not_Covered */
-
if ( error != HB_Err_Not_Covered )
return error;
}
}
-static FT_Error Load_DefaultSubst( HB_GSUB_SubTable* st,
- FT_Stream stream )
-{
- FT_UNUSED(st);
- FT_UNUSED(stream);
-
- return HB_Err_Invalid_GSUB_SubTable_Format;
-}
-
-typedef FT_Error (*Load_Subst_Func_Type)( HB_GSUB_SubTable* st,
- FT_Stream stream );
-static const Load_Subst_Func_Type Load_Subst_Call_Table[] = {
- Load_DefaultSubst,
- Load_SingleSubst, /* HB_GSUB_LOOKUP_SINGLE 1 */
- Load_MultipleSubst, /* HB_GSUB_LOOKUP_MULTIPLE 2 */
- Load_AlternateSubst, /* HB_GSUB_LOOKUP_ALTERNATE 3 */
- Load_LigatureSubst, /* HB_GSUB_LOOKUP_LIGATURE 4 */
- Load_ContextSubst, /* HB_GSUB_LOOKUP_CONTEXT 5 */
- Load_ChainContextSubst, /* HB_GSUB_LOOKUP_CHAIN 6 */
- Load_DefaultSubst, /* HB_GSUB_LOOKUP_EXTENSION 7 */
- Load_ReverseChainContextSubst /* HB_GSUB_LOOKUP_REVERSE_CHAIN 8 */
-};
-
-FT_Error _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
+HB_Error _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
FT_Stream stream,
FT_UShort lookup_type )
{
- Load_Subst_Func_Type Func;
-
- if (lookup_type >= ARRAY_LEN (Load_Subst_Call_Table))
- lookup_type = 0;
-
- Func = Load_Subst_Call_Table[lookup_type];
-
- return Func ( st, stream );
-}
-
-
-static void Free_DefaultSubst( HB_GSUB_SubTable* st,
- FT_Memory memory )
-{
- FT_UNUSED(st);
- FT_UNUSED(memory);
+ switch (lookup_type) {
+ case HB_GSUB_LOOKUP_SINGLE: return Load_SingleSubst ( st, stream );
+ case HB_GSUB_LOOKUP_MULTIPLE: return Load_MultipleSubst ( st, stream );
+ case HB_GSUB_LOOKUP_ALTERNATE: return Load_AlternateSubst ( st, stream );
+ case HB_GSUB_LOOKUP_LIGATURE: return Load_LigatureSubst ( st, stream );
+ case HB_GSUB_LOOKUP_CONTEXT: return Load_ContextSubst ( st, stream );
+ case HB_GSUB_LOOKUP_CHAIN: return Load_ChainContextSubst ( st, stream );
+ /*case HB_GSUB_LOOKUP_EXTENSION: return Load_ExtensionSubst ( st, stream );*/
+ case HB_GSUB_LOOKUP_REVERSE_CHAIN: return Load_ReverseChainContextSubst ( st, stream );
+ default: return _hb_err(HB_Err_Invalid_GSUB_SubTable_Format);
+ };
}
-typedef void (*Free_Subst_Func_Type)( HB_GSUB_SubTable* st,
- FT_Memory memory );
-static const Free_Subst_Func_Type Free_Subst_Call_Table[] = {
- Free_DefaultSubst,
- Free_SingleSubst, /* HB_GSUB_LOOKUP_SINGLE 1 */
- Free_MultipleSubst, /* HB_GSUB_LOOKUP_MULTIPLE 2 */
- Free_AlternateSubst, /* HB_GSUB_LOOKUP_ALTERNATE 3 */
- Free_LigatureSubst, /* HB_GSUB_LOOKUP_LIGATURE 4 */
- Free_ContextSubst, /* HB_GSUB_LOOKUP_CONTEXT 5 */
- Free_ChainContextSubst, /* HB_GSUB_LOOKUP_CHAIN 6 */
- Free_DefaultSubst, /* HB_GSUB_LOOKUP_EXTENSION 7 */
- Free_ReverseChainContextSubst /* HB_GSUB_LOOKUP_REVERSE_CHAIN 8 */
-};
void _HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
FT_Memory memory,
FT_UShort lookup_type )
{
- Free_Subst_Func_Type Func;
-
- if (lookup_type >= ARRAY_LEN (Free_Subst_Call_Table))
- lookup_type = 0;
-
- Func = Free_Subst_Call_Table[lookup_type];
-
- Func ( st, memory );
+ switch ( lookup_type ) {
+ case HB_GSUB_LOOKUP_SINGLE: Free_SingleSubst ( st, memory ); return;
+ case HB_GSUB_LOOKUP_MULTIPLE: Free_MultipleSubst ( st, memory ); return;
+ case HB_GSUB_LOOKUP_ALTERNATE: Free_AlternateSubst ( st, memory ); return;
+ case HB_GSUB_LOOKUP_LIGATURE: Free_LigatureSubst ( st, memory ); return;
+ case HB_GSUB_LOOKUP_CONTEXT: Free_ContextSubst ( st, memory ); return;
+ case HB_GSUB_LOOKUP_CHAIN: Free_ChainContextSubst ( st, memory ); return;
+ /*case HB_GSUB_LOOKUP_EXTENSION: Free_ExtensionSubst ( st, memory ); return;*/
+ case HB_GSUB_LOOKUP_REVERSE_CHAIN: Free_ReverseChainContextSubst ( st, memory ); return;
+ default: return;
+ };
}
/* apply one lookup to the input string object */
-static FT_Error GSUB_Do_String_Lookup( HB_GSUBHeader* gsub,
- FT_UShort lookup_index,
- HB_Buffer buffer )
+static HB_Error GSUB_Do_String_Lookup( HB_GSUBHeader* gsub,
+ FT_UShort lookup_index,
+ HB_Buffer buffer )
{
- FT_Error error, retError = HB_Err_Not_Covered;
+ HB_Error error, retError = HB_Err_Not_Covered;
- FT_UInt* properties = gsub->LookupList.Properties;
+ FT_UInt* properties = gsub->LookupList.Properties;
+ int lookup_type = gsub->LookupList.Lookup[lookup_index].LookupType;
- int nesting_level = 0;
-
-
- while ( buffer->in_pos < buffer->in_length )
- {
- if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )
- {
- /* 0xFFFF indicates that we don't have a context length yet */
- error = GSUB_Do_Glyph_Lookup( gsub, lookup_index, buffer,
- 0xFFFF, nesting_level );
- if ( error )
- {
- if ( error != HB_Err_Not_Covered )
- return error;
- }
- else
- retError = error;
- }
- else
- error = HB_Err_Not_Covered;
+ const int nesting_level = 0;
+ /* 0xFFFF indicates that we don't have a context length yet */
+ const FT_UShort context_length = 0xFFFF;
- if ( error == HB_Err_Not_Covered )
- if ( (error = hb_buffer_copy_output_glyph ( buffer ) ) )
- return error;
- }
+ switch (lookup_type) {
- return retError;
-}
+ case HB_GSUB_LOOKUP_SINGLE:
+ case HB_GSUB_LOOKUP_MULTIPLE:
+ case HB_GSUB_LOOKUP_ALTERNATE:
+ case HB_GSUB_LOOKUP_LIGATURE:
+ case HB_GSUB_LOOKUP_CONTEXT:
+ case HB_GSUB_LOOKUP_CHAIN:
+ /* in/out forward substitution (implemented lazy) */
+ hb_buffer_clear_output ( buffer );
+ buffer->in_pos = 0;
+ while ( buffer->in_pos < buffer->in_length )
+ {
+ if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )
+ {
+ error = GSUB_Do_Glyph_Lookup( gsub, lookup_index, buffer, context_length, nesting_level );
+ if ( error )
+ {
+ if ( error != HB_Err_Not_Covered )
+ return error;
+ }
+ else
+ retError = error;
+ }
+ else
+ error = HB_Err_Not_Covered;
-static FT_Error Apply_ReverseChainContextSubst( HB_GSUBHeader* gsub,
- FT_UShort lookup_index,
- HB_Buffer buffer )
-{
- FT_UInt* properties = gsub->LookupList.Properties;
- FT_Error error, retError = HB_Err_Not_Covered;
- FT_ULong subtable_Count, string_index;
- FT_UShort flags;
- HB_Lookup* lo;
+ if ( error == HB_Err_Not_Covered )
+ if ( COPY_Glyph ( buffer ) )
+ return error;
+ }
+ /* we shouldn't swap if error occurred.
+ *
+ * also don't swap if nothing changed (ie HB_Err_Not_Covered).
+ * shouldn't matter in that case though.
+ */
+ if ( retError == HB_Err_Ok )
+ hb_buffer_swap( buffer );
- if ( buffer->in_length == 0 )
- return HB_Err_Not_Covered;
+ return retError;
- lo = &gsub->LookupList.Lookup[lookup_index];
- flags = lo->LookupFlag;
+ case HB_GSUB_LOOKUP_REVERSE_CHAIN:
+ /* in-place backward substitution */
- for ( subtable_Count = 0; subtable_Count < lo->SubTableCount; subtable_Count++ )
- {
- string_index = buffer->in_length - 1;
- do
- {
- if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )
+ buffer->in_pos = buffer->in_length - 1;
+ do
+ {
+ if ( ~IN_PROPERTIES( buffer->in_pos ) & properties[lookup_index] )
{
- error = Lookup_ReverseChainContextSubst( gsub, &lo->SubTable[subtable_Count].st.gsub,
- buffer, flags, string_index );
+ error = GSUB_Do_Glyph_Lookup( gsub, lookup_index, buffer, context_length, nesting_level );
if ( error )
- {
- if ( error != HB_Err_Not_Covered )
- return error;
- }
+ {
+ if ( error != HB_Err_Not_Covered )
+ return error;
+ }
else
retError = error;
}
- }
- while (string_index--);
- }
+ else
+ error = HB_Err_Not_Covered;
+
+ if ( error == HB_Err_Not_Covered )
+ buffer->in_pos--;
+ }
+ while (buffer->in_pos);
- return retError;
+ return retError;
+
+ /*case HB_GSUB_LOOKUP_EXTENSION:*/
+ default:
+ return retError;
+ };
}
-FT_Error HB_GSUB_Add_Feature( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Add_Feature( HB_GSUBHeader* gsub,
FT_UShort feature_index,
FT_UInt property )
{
if ( !gsub ||
feature_index >= gsub->FeatureList.FeatureCount ||
gsub->FeatureList.ApplyCount == gsub->FeatureList.FeatureCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gsub->FeatureList.ApplyOrder[gsub->FeatureList.ApplyCount++] = feature_index;
properties[lookup_index] |= property;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GSUB_Clear_Features( HB_GSUBHeader* gsub )
+HB_Error HB_GSUB_Clear_Features( HB_GSUBHeader* gsub )
{
FT_UShort i;
if ( !gsub )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gsub->FeatureList.ApplyCount = 0;
for ( i = 0; i < gsub->LookupList.LookupCount; i++ )
properties[i] = 0;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-FT_Error HB_GSUB_Register_Alternate_Function( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Register_Alternate_Function( HB_GSUBHeader* gsub,
HB_AltFunction altfunc,
void* data )
{
if ( !gsub )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gsub->altfunc = altfunc;
gsub->data = data;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
-
-
-FT_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub,
+/* returns error if one happened, otherwise returns HB_Err_Not_Covered if no
+ * feature were applied, or HB_Err_Ok otherwise.
+ */
+HB_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub,
HB_Buffer buffer )
{
- FT_Error error, retError = HB_Err_Not_Covered;
+ HB_Error error, retError = HB_Err_Not_Covered;
FT_UShort i, j, lookup_count;
if ( !gsub ||
- !buffer || buffer->in_length == 0 || buffer->in_pos >= buffer->in_length )
- return FT_Err_Invalid_Argument;
+ !buffer)
+ return HB_Err_Invalid_Argument;
+
+ if ( buffer->in_length == 0 )
+ return retError;
lookup_count = gsub->LookupList.LookupCount;
for ( i = 0; i < gsub->FeatureList.ApplyCount; i++)
{
- FT_UShort feature_index;
- HB_Feature feature;
-
- feature_index = gsub->FeatureList.ApplyOrder[i];
- feature = gsub->FeatureList.FeatureRecord[feature_index].Feature;
+ FT_UShort feature_index = gsub->FeatureList.ApplyOrder[i];
+ HB_Feature feature = gsub->FeatureList.FeatureRecord[feature_index].Feature;
for ( j = 0; j < feature.LookupListCount; j++ )
{
- FT_UShort lookup_index;
- HB_Lookup* lookup;
- FT_Bool need_swap;
-
- lookup_index = feature.LookupListIndex[j];
+ FT_UShort lookup_index = feature.LookupListIndex[j];
/* Skip nonexistant lookups */
if (lookup_index >= lookup_count)
continue;
- lookup = &gsub->LookupList.Lookup[lookup_index];
-
- if ( lookup->LookupType == HB_GSUB_LOOKUP_REVERSE_CHAIN )
- {
- error = Apply_ReverseChainContextSubst( gsub, lookup_index, buffer);
- need_swap = FALSE; /* We do ReverseChainContextSubst in-place */
- }
- else
- {
- error = GSUB_Do_String_Lookup( gsub, lookup_index, buffer );
- need_swap = TRUE;
- }
-
+ error = GSUB_Do_String_Lookup( gsub, lookup_index, buffer );
if ( error )
{
if ( error != HB_Err_Not_Covered )
- goto End;
+ return error;
}
else
retError = error;
-
- if ( need_swap )
- {
- error = hb_buffer_swap( buffer );
- if ( error )
- goto End;
- }
}
}
error = retError;
-End:
return error;
}
typedef HB_GSUBHeader* HB_GSUB;
-FT_Error HB_Load_GSUB_Table( FT_Face face,
+HB_Error HB_Load_GSUB_Table( FT_Face face,
HB_GSUBHeader** gsub,
HB_GDEFHeader* gdef );
-FT_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub );
+HB_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub );
-FT_Error HB_GSUB_Select_Script( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Select_Script( HB_GSUBHeader* gsub,
FT_ULong script_tag,
FT_UShort* script_index );
-FT_Error HB_GSUB_Select_Language( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Select_Language( HB_GSUBHeader* gsub,
FT_ULong language_tag,
FT_UShort script_index,
FT_UShort* language_index,
FT_UShort* req_feature_index );
-FT_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
FT_ULong feature_tag,
FT_UShort script_index,
FT_UShort language_index,
FT_UShort* feature_index );
-FT_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub,
FT_ULong** script_tag_list );
-FT_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
FT_UShort script_index,
FT_ULong** language_tag_list );
-FT_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
FT_UShort script_index,
FT_UShort language_index,
FT_ULong** feature_tag_list );
-FT_Error HB_GSUB_Add_Feature( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Add_Feature( HB_GSUBHeader* gsub,
FT_UShort feature_index,
FT_UInt property );
-FT_Error HB_GSUB_Clear_Features( HB_GSUBHeader* gsub );
+HB_Error HB_GSUB_Clear_Features( HB_GSUBHeader* gsub );
-FT_Error HB_GSUB_Register_Alternate_Function( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Register_Alternate_Function( HB_GSUBHeader* gsub,
HB_AltFunction altfunc,
void* data );
-FT_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub,
+HB_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub,
HB_Buffer buffer );
#define OUT_GLYPH( pos ) (buffer->out_string[(pos)].gindex)
#define OUT_ITEM( pos ) (&buffer->out_string[(pos)])
-#define CHECK_Property( gdef, index, flags, property ) \
- ( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags), \
- (property) ) ) != FT_Err_Ok )
+#define CHECK_Property( gdef, index, flags, property ) \
+ ( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags), \
+ (property) ) ) != HB_Err_Ok )
#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID ) \
- ( ( error = hb_buffer_add_output_glyphs( (buffer), \
+ ( ( error = hb_buffer_add_output_glyphs( (buffer), \
(num_in), (num_out), \
(glyph_data), (component), (ligID) \
- ) ) != FT_Err_Ok )
-#define ADD_Glyph( buffer, glyph_index, component, ligID ) \
+ ) ) != HB_Err_Ok )
+#define ADD_Glyph( buffer, glyph_index, component, ligID ) \
( ( error = hb_buffer_add_output_glyph( (buffer), \
- (glyph_index), (component), (ligID) \
- ) ) != FT_Err_Ok )
-
+ (glyph_index), (component), (ligID) \
+ ) ) != HB_Err_Ok )
+#define REPLACE_Glyph( buffer, glyph_index, nesting_level ) \
+ ( ( error = hb_buffer_replace_output_glyph( (buffer), (glyph_index), \
+ (nesting_level) == 1 ) ) != HB_Err_Ok )
+#define COPY_Glyph( buffer ) \
+ ( (error = hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )
FT_END_HEADER
};
-FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
+HB_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
FT_Stream stream );
-FT_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
+HB_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
FT_Stream input );
-FT_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
+HB_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
FT_Stream input,
HB_Type type );
-FT_Error _HB_OPEN_Load_Coverage( HB_Coverage* c,
+HB_Error _HB_OPEN_Load_Coverage( HB_Coverage* c,
FT_Stream input );
-FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
+HB_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
FT_UShort limit,
FT_Stream input );
-FT_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd,
+HB_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd,
FT_Stream input );
-FT_Error _HB_OPEN_Load_Device( HB_Device* d,
+HB_Error _HB_OPEN_Load_Device( HB_Device* d,
FT_Stream input );
void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl,
-FT_Error _HB_OPEN_Coverage_Index( HB_Coverage* c,
+HB_Error _HB_OPEN_Coverage_Index( HB_Coverage* c,
FT_UShort glyphID,
FT_UShort* index );
-FT_Error _HB_OPEN_Get_Class( HB_ClassDefinition* cd,
+HB_Error _HB_OPEN_Get_Class( HB_ClassDefinition* cd,
FT_UShort glyphID,
FT_UShort* class,
FT_UShort* index );
-FT_Error _HB_OPEN_Get_Device( HB_Device* d,
+HB_Error _HB_OPEN_Get_Device( HB_Device* d,
FT_UShort size,
FT_Short* value );
/* LangSys */
-static FT_Error Load_LangSys( HB_LangSys* ls,
+static HB_Error Load_LangSys( HB_LangSys* ls,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FT_UShort* fi;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* Script */
-static FT_Error Load_Script( HB_Script* s,
+static HB_Error Load_Script( HB_Script* s,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
FT_ULong cur_offset, new_offset, base_offset;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_LangSys( &s->DefaultLangSys,
- stream ) ) != FT_Err_Ok )
+ stream ) ) != HB_Err_Ok )
return error;
(void)FILE_Seek( cur_offset );
}
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_LangSys( &lsr[n].LangSys, stream ) ) != FT_Err_Ok )
+ ( error = Load_LangSys( &lsr[n].LangSys, stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* ScriptList */
-FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
+HB_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, script_count;
goto Fail;
error = Load_Script( &sr[sl->ScriptCount].Script, stream );
- if ( error == FT_Err_Ok )
+ if ( error == HB_Err_Ok )
sl->ScriptCount += 1;
else if ( error != HB_Err_Empty_Script )
goto Fail;
#if 0
if ( sl->ScriptCount == 0 )
{
- error = HB_Err_Invalid_SubTable;
+ error = _hb_err(HB_Err_Invalid_SubTable);
goto Fail;
}
#endif
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( n = 0; n < sl->ScriptCount; n++ )
/* Feature */
-static FT_Error Load_Feature( HB_Feature* f,
+static HB_Error Load_Feature( HB_Feature* f,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* FeatureList */
-FT_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
+HB_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_Feature( &fr[n].Feature, stream ) ) != FT_Err_Ok )
+ ( error = Load_Feature( &fr[n].Feature, stream ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
/* SubTable */
-static FT_Error Load_SubTable( HB_SubTable* st,
+static HB_Error Load_SubTable( HB_SubTable* st,
FT_Stream stream,
HB_Type table_type,
FT_UShort lookup_type )
/* Lookup */
-static FT_Error Load_Lookup( HB_Lookup* l,
+static HB_Error Load_Lookup( HB_Lookup* l,
FT_Stream stream,
HB_Type type )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
if ( FILE_Seek( new_offset ) ||
( error = Load_SubTable( &st[n], stream,
- type, l->LookupType ) ) != FT_Err_Ok )
+ type, l->LookupType ) ) != HB_Err_Ok )
goto Fail;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
/* LookupList */
-FT_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
+HB_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
FT_Stream stream,
HB_Type type )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
- ( error = Load_Lookup( &l[n], stream, type ) ) != FT_Err_Ok )
+ ( error = Load_Lookup( &l[n], stream, type ) ) != HB_Err_Ok )
goto Fail1;
(void)FILE_Seek( cur_offset );
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( ll->Properties );
/* CoverageFormat1 */
-static FT_Error Load_Coverage1( HB_CoverageFormat1* cf1,
+static HB_Error Load_Coverage1( HB_CoverageFormat1* cf1,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* CoverageFormat2 */
-static FT_Error Load_Coverage2( HB_CoverageFormat2* cf2,
+static HB_Error Load_Coverage2( HB_CoverageFormat2* cf2,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
( rr[n].End - rr[n].Start + (long)rr[n].StartCoverageIndex ) >=
0x10000L )
{
- error = HB_Err_Invalid_SubTable;
+ error = _hb_err(HB_Err_Invalid_SubTable);
goto Fail;
}
}
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
FREE( cf2->RangeRecord );
}
-FT_Error _HB_OPEN_Load_Coverage( HB_Coverage* c,
+HB_Error _HB_OPEN_Load_Coverage( HB_Coverage* c,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
if ( ACCESS_Frame( 2L ) )
return error;
switch ( c->CoverageFormat )
{
- case 1:
- return Load_Coverage1( &c->cf.cf1, stream );
-
- case 2:
- return Load_Coverage2( &c->cf.cf2, stream );
-
- default:
- return HB_Err_Invalid_SubTable_Format;
+ case 1: return Load_Coverage1( &c->cf.cf1, stream );
+ case 2: return Load_Coverage2( &c->cf.cf2, stream );
+ default: return _hb_err(HB_Err_Invalid_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
{
switch ( c->CoverageFormat )
{
- case 1:
- Free_Coverage1( &c->cf.cf1, memory );
- break;
-
- case 2:
- Free_Coverage2( &c->cf.cf2, memory );
- break;
+ case 1: Free_Coverage1( &c->cf.cf1, memory ); break;
+ case 2: Free_Coverage2( &c->cf.cf2, memory ); break;
+ default: break;
}
}
-static FT_Error Coverage_Index1( HB_CoverageFormat1* cf1,
+static HB_Error Coverage_Index1( HB_CoverageFormat1* cf1,
FT_UShort glyphID,
FT_UShort* index )
{
if ( glyphID == array[middle] )
{
*index = middle;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
else if ( glyphID < array[middle] )
{
}
-static FT_Error Coverage_Index2( HB_CoverageFormat2* cf2,
+static HB_Error Coverage_Index2( HB_CoverageFormat2* cf2,
FT_UShort glyphID,
FT_UShort* index )
{
if ( glyphID >= rr[middle].Start && glyphID <= rr[middle].End )
{
*index = rr[middle].StartCoverageIndex + glyphID - rr[middle].Start;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
else if ( glyphID < rr[middle].Start )
{
}
-FT_Error _HB_OPEN_Coverage_Index( HB_Coverage* c,
+HB_Error _HB_OPEN_Coverage_Index( HB_Coverage* c,
FT_UShort glyphID,
FT_UShort* index )
{
switch ( c->CoverageFormat )
{
- case 1:
- return Coverage_Index1( &c->cf.cf1, glyphID, index );
-
- case 2:
- return Coverage_Index2( &c->cf.cf2, glyphID, index );
-
- default:
- return HB_Err_Invalid_SubTable_Format;
+ case 1: return Coverage_Index1( &c->cf.cf1, glyphID, index );
+ case 2: return Coverage_Index2( &c->cf.cf2, glyphID, index );
+ default: return _hb_err(HB_Err_Invalid_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
/* ClassDefFormat1 */
-static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
+static HB_Error Load_ClassDef1( HB_ClassDefinition* cd,
FT_UShort limit,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
/* sanity check; we are limited to 16bit integers */
if ( cdf1->StartGlyph + (long)count >= 0x10000L )
- return HB_Err_Invalid_SubTable;
+ return _hb_err(HB_Err_Invalid_SubTable);
cdf1->ClassValueArray = NULL;
cva[n] = GET_UShort();
if ( cva[n] >= limit )
{
- error = HB_Err_Invalid_SubTable;
+ error = _hb_err(HB_Err_Invalid_SubTable);
goto Fail;
}
d[cva[n]] = TRUE;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
FREE( cva );
/* ClassDefFormat2 */
-static FT_Error Load_ClassDef2( HB_ClassDefinition* cd,
+static HB_Error Load_ClassDef2( HB_ClassDefinition* cd,
FT_UShort limit,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
if ( ACCESS_Frame( 2L ) )
return error;
- count = cdf2->ClassRangeCount = GET_UShort();
+ count = GET_UShort();
+ cdf2->ClassRangeCount = 0; /* zero for now. we fill with the number of good entries later */
FORGET_Frame();
if ( crr[n].Start > crr[n].End ||
crr[n].Class >= limit )
{
- error = HB_Err_Invalid_SubTable;
- goto Fail;
+ /* XXX
+ * Corrupt entry. Skip it.
+ * This is hit by Nafees Nastaliq font for example
+ */
+ n--;
+ count--;
}
- d[crr[n].Class] = TRUE;
+ else
+ d[crr[n].Class] = TRUE;
}
FORGET_Frame();
- return FT_Err_Ok;
+ cdf2->ClassRangeCount = count;
+
+ return HB_Err_Ok;
Fail:
FREE( crr );
/* ClassDefinition */
-FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
+HB_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
FT_UShort limit,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
switch ( cd->ClassFormat )
{
- case 1:
- error = Load_ClassDef1( cd, limit, stream );
- break;
-
- case 2:
- error = Load_ClassDef2( cd, limit, stream );
- break;
-
- default:
- error = HB_Err_Invalid_SubTable_Format;
- break;
+ case 1: error = Load_ClassDef1( cd, limit, stream ); break;
+ case 2: error = Load_ClassDef2( cd, limit, stream ); break;
+ default: error = _hb_err(HB_Err_Invalid_SubTable_Format); break;
}
if ( error )
cd->loaded = TRUE;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
FREE( cd->Defined );
}
-FT_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd,
+HB_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
if ( ALLOC_ARRAY( cd->cd.cd1.ClassValueArray, 1, FT_UShort ) )
goto Fail;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
FREE( cd->Defined );
switch ( cd->ClassFormat )
{
- case 1:
- Free_ClassDef1( &cd->cd.cd1, memory );
- break;
-
- case 2:
- Free_ClassDef2( &cd->cd.cd2, memory );
- break;
+ case 1: Free_ClassDef1( &cd->cd.cd1, memory ); break;
+ case 2: Free_ClassDef2( &cd->cd.cd2, memory ); break;
+ default: break;
}
}
-static FT_Error Get_Class1( HB_ClassDefFormat1* cdf1,
+static HB_Error Get_Class1( HB_ClassDefFormat1* cdf1,
FT_UShort glyphID,
FT_UShort* class,
FT_UShort* index )
glyphID < cdf1->StartGlyph + cdf1->GlyphCount )
{
*class = cva[glyphID - cdf1->StartGlyph];
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
else
{
/* we need the index value of the last searched class range record
in case of failure for constructed GDEF tables */
-static FT_Error Get_Class2( HB_ClassDefFormat2* cdf2,
+static HB_Error Get_Class2( HB_ClassDefFormat2* cdf2,
FT_UShort glyphID,
FT_UShort* class,
FT_UShort* index )
{
- FT_Error error = FT_Err_Ok;
+ HB_Error error = HB_Err_Ok;
FT_UShort min, max, new_min, new_max, middle;
HB_ClassRangeRecord* crr = cdf2->ClassRangeRecord;
if ( glyphID >= crr[middle].Start && glyphID <= crr[middle].End )
{
*class = crr[middle].Class;
- error = FT_Err_Ok;
+ error = HB_Err_Ok;
break;
}
else if ( glyphID < crr[middle].Start )
}
-FT_Error _HB_OPEN_Get_Class( HB_ClassDefinition* cd,
+HB_Error _HB_OPEN_Get_Class( HB_ClassDefinition* cd,
FT_UShort glyphID,
FT_UShort* class,
FT_UShort* index )
{
switch ( cd->ClassFormat )
{
- case 1:
- return Get_Class1( &cd->cd.cd1, glyphID, class, index );
-
- case 2:
- return Get_Class2( &cd->cd.cd2, glyphID, class, index );
-
- default:
- return HB_Err_Invalid_SubTable_Format;
+ case 1: return Get_Class1( &cd->cd.cd1, glyphID, class, index );
+ case 2: return Get_Class2( &cd->cd.cd2, glyphID, class, index );
+ default: return _hb_err(HB_Err_Invalid_SubTable_Format);
}
- return FT_Err_Ok; /* never reached */
+ return HB_Err_Ok; /* never reached */
}
***************************/
-FT_Error _HB_OPEN_Load_Device( HB_Device* d,
+HB_Error _HB_OPEN_Load_Device( HB_Device* d,
FT_Stream stream )
{
- FT_Error error;
+ HB_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, count;
FORGET_Frame();
+ d->DeltaValue = NULL;
+
if ( d->StartSize > d->EndSize ||
d->DeltaFormat == 0 || d->DeltaFormat > 3 )
- return HB_Err_Invalid_SubTable;
-
- d->DeltaValue = NULL;
+ {
+ /* XXX
+ * I've seen fontforge generate DeltaFormat == 0.
+ * Just return Ok and let the NULL DeltaValue disable
+ * this table.
+ */
+ return HB_Err_Ok;
+ }
count = ( ( d->EndSize - d->StartSize + 1 ) >>
( 4 - d->DeltaFormat ) ) + 1;
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
mask = 0x00FF */
-FT_Error _HB_OPEN_Get_Device( HB_Device* d,
+HB_Error _HB_OPEN_Get_Device( HB_Device* d,
FT_UShort size,
FT_Short* value )
{
if ( *value >= ( ( mask + 1 ) >> 1 ) )
*value -= mask + 1;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
else
{
#define HB_MAX_NESTING_LEVEL 100
+typedef FT_Error HB_Error;
+
+#define HB_Err_Invalid_Argument FT_Err_Invalid_Argument
+#define HB_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle
+#define HB_Err_Invalid_Stream_Operation FT_Err_Invalid_Stream_Operation
+#define HB_Err_Empty_Script 0x1005
+
+#define HB_Err_Ok FT_Err_Ok
+#define HB_Err_Not_Covered 0x1002
+#define HB_Err_Out_Of_Memory FT_Err_Out_Of_Memory
+#define HB_Err_Table_Missing FT_Err_Table_Missing
#define HB_Err_Invalid_SubTable_Format 0x1000
#define HB_Err_Invalid_SubTable 0x1001
-#define HB_Err_Not_Covered 0x1002
#define HB_Err_Too_Many_Nested_Contexts 0x1003
#define HB_Err_No_MM_Interpreter 0x1004
-#define HB_Err_Empty_Script 0x1005
/* Script list related structures */