summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-10-11 00:07:58 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-10-11 00:07:58 +0000
commit04755c9304d976ad5bace39c409286a198d20ff2 (patch)
tree67217aa2da4d4a52d76d045ed77597068d458a1a /pango
parentfc08a649dbf57da6d79a1e8df1c3883f8f6b7111 (diff)
downloadpango-04755c9304d976ad5bace39c409286a198d20ff2.tar.gz
Bug 485559 – Boston Summit HarfBuzz optimizations
2007-10-10 Behdad Esfahbod <behdad@gnome.org> Bug 485559 – Boston Summit HarfBuzz optimizations * pango/opentype/*: HarfBuzz hacking to: - Rename last remaining FT_Err stuff to HB_Err. - Fix a couple invalid table paths to be permissive so fonts work better. Particularly GDEF table for Nafees Nastaliq is loaded and works great now. - Optimize harfbuzz buffer to not copy/swap for simple one-to-one and "copy" GSUB operations. * pango/pango-ot*: Update to FT_Err to HB_Err renaming. svn path=/trunk/; revision=2431
Diffstat (limited to 'pango')
-rw-r--r--pango/opentype/ftglue.c51
-rw-r--r--pango/opentype/ftglue.h21
-rw-r--r--pango/opentype/harfbuzz-buffer.c190
-rw-r--r--pango/opentype/harfbuzz-buffer.h26
-rw-r--r--pango/opentype/harfbuzz-dump-main.c14
-rw-r--r--pango/opentype/harfbuzz-dump.c15
-rw-r--r--pango/opentype/harfbuzz-gdef-private.h4
-rw-r--r--pango/opentype/harfbuzz-gdef.c149
-rw-r--r--pango/opentype/harfbuzz-gdef.h10
-rw-r--r--pango/opentype/harfbuzz-gpos-private.h2
-rw-r--r--pango/opentype/harfbuzz-gpos.c810
-rw-r--r--pango/opentype/harfbuzz-gpos.h30
-rw-r--r--pango/opentype/harfbuzz-gsub-private.h2
-rw-r--r--pango/opentype/harfbuzz-gsub.c919
-rw-r--r--pango/opentype/harfbuzz-gsub.h24
-rw-r--r--pango/opentype/harfbuzz-impl.h22
-rw-r--r--pango/opentype/harfbuzz-open-private.h20
-rw-r--r--pango/opentype/harfbuzz-open.c238
-rw-r--r--pango/opentype/harfbuzz-open.h13
-rw-r--r--pango/pango-ot-buffer.c4
-rw-r--r--pango/pango-ot-info.c16
-rw-r--r--pango/pango-ot-ruleset.c2
22 files changed, 1264 insertions, 1318 deletions
diff --git a/pango/opentype/ftglue.c b/pango/opentype/ftglue.c
index 6444e67d..752c976f 100644
--- a/pango/opentype/ftglue.c
+++ b/pango/opentype/ftglue.c
@@ -32,16 +32,16 @@ _hb_ftglue_log( const char* format, ... )
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;
@@ -55,16 +55,16 @@ _hb_ftglue_qalloc( FT_Memory memory,
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 );
}
@@ -79,10 +79,10 @@ _hb_ftglue_realloc( FT_Memory memory,
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 )
{
@@ -96,7 +96,7 @@ _hb_ftglue_realloc( FT_Memory memory,
{
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) );
}
@@ -126,31 +126,31 @@ _hb_ftglue_stream_pos( FT_Stream stream )
}
-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 )
@@ -168,7 +168,7 @@ _hb_ftglue_stream_frame_enter( FT_Stream stream,
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;
@@ -180,7 +180,7 @@ _hb_ftglue_stream_frame_enter( FT_Stream stream,
if ( stream->pos >= stream->size ||
stream->pos + count > stream->size )
{
- error = FT_Err_Invalid_Stream_Operation;
+ error = HB_Err_Invalid_Stream_Operation;
goto Exit;
}
@@ -212,12 +212,12 @@ _hb_ftglue_stream_frame_exit( FT_Stream stream )
}
-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,
@@ -230,7 +230,7 @@ _hb_ftglue_face_goto_table( FT_Face 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
{
@@ -285,7 +285,7 @@ _hb_ftglue_face_goto_table( FT_Face face,
goto FoundIt;
}
}
- error = FT_Err_Table_Missing;
+ error = HB_Err_Table_Missing;
FoundIt:
FORGET_Frame();
@@ -298,3 +298,12 @@ Exit:
}
#undef QALLOC
+
+/* abuse these private header/source files */
+
+/* helper func to set a breakpoint on */
+HB_Error
+_hb_err (HB_Error code)
+{
+ return code;
+}
diff --git a/pango/opentype/ftglue.h b/pango/opentype/ftglue.h
index 84de7f35..9b237dda 100644
--- a/pango/opentype/ftglue.h
+++ b/pango/opentype/ftglue.h
@@ -46,11 +46,17 @@
#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
@@ -88,18 +94,18 @@ FT_BEGIN_HEADER
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 );
@@ -132,19 +138,24 @@ _hb_ftglue_face_goto_table( FT_Face face,
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 */
diff --git a/pango/opentype/harfbuzz-buffer.c b/pango/opentype/harfbuzz-buffer.c
index 40a7d2b8..148d98d9 100644
--- a/pango/opentype/harfbuzz-buffer.c
+++ b/pango/opentype/harfbuzz-buffer.c
@@ -1,6 +1,6 @@
/* 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.
@@ -11,7 +11,34 @@
#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 )
{
@@ -20,29 +47,63 @@ hb_buffer_ensure( HB_Buffer buffer,
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;
@@ -56,61 +117,77 @@ hb_buffer_new( FT_Memory memory,
(*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 );
@@ -127,7 +204,7 @@ hb_buffer_add_glyph( HB_Buffer buffer,
buffer->in_length++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
/* The following function copies `num_out' elements from `glyph_data'
@@ -149,7 +226,7 @@ hb_buffer_add_glyph( HB_Buffer buffer,
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,
@@ -157,7 +234,7 @@ hb_buffer_add_output_glyphs( HB_Buffer buffer,
FT_UShort component,
FT_UShort ligID )
{
- FT_Error error;
+ HB_Error error;
FT_UShort i;
FT_UInt properties;
FT_UInt cluster;
@@ -166,6 +243,13 @@ hb_buffer_add_output_glyphs( HB_Buffer buffer,
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 )
@@ -190,10 +274,10 @@ hb_buffer_add_output_glyphs( HB_Buffer buffer,
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,
@@ -205,19 +289,49 @@ hb_buffer_add_output_glyph( HB_Buffer buffer,
&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
diff --git a/pango/opentype/harfbuzz-buffer.h b/pango/opentype/harfbuzz-buffer.h
index c7478e38..8b6b659f 100644
--- a/pango/opentype/harfbuzz-buffer.h
+++ b/pango/opentype/harfbuzz-buffer.h
@@ -56,32 +56,37 @@ typedef struct HB_BufferRec_{
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,
@@ -89,15 +94,20 @@ hb_buffer_add_output_glyphs( HB_Buffer buffer,
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 );
diff --git a/pango/opentype/harfbuzz-dump-main.c b/pango/opentype/harfbuzz-dump-main.c
index 81fecf43..4a95f2e5 100644
--- a/pango/opentype/harfbuzz-dump-main.c
+++ b/pango/opentype/harfbuzz-dump-main.c
@@ -28,7 +28,7 @@
#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);
@@ -59,7 +59,7 @@ maybe_add_feature (HB_GSUB gsub,
FT_ULong tag,
FT_UShort property)
{
- FT_Error error;
+ HB_Error error;
FT_UShort feature_index;
/* 0xffff == default language system */
@@ -122,7 +122,7 @@ select_cmap (FT_Face face)
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;
@@ -173,7 +173,7 @@ try_string (FT_Library library,
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;
@@ -210,7 +210,7 @@ try_string (FT_Library library,
int
main (int argc, char **argv)
{
- FT_Error error;
+ HB_Error error;
FT_Library library;
FT_Face face;
HB_GSUB gsub;
@@ -238,7 +238,7 @@ main (int argc, char **argv)
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)))
@@ -248,7 +248,7 @@ main (int argc, char **argv)
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");
diff --git a/pango/opentype/harfbuzz-dump.c b/pango/opentype/harfbuzz-dump.c
index bf30f66b..53feba12 100644
--- a/pango/opentype/harfbuzz-dump.c
+++ b/pango/opentype/harfbuzz-dump.c
@@ -452,7 +452,7 @@ static void
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;
@@ -472,6 +472,9 @@ Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
case 3:
bits = 8;
break;
+ default:
+ bits = 0;
+ break;
}
DUMP ("<DeltaValue>");
@@ -634,7 +637,7 @@ Dump_GPOS_Lookup_Markbase (HB_SubTable *subtable, FILE *stream, int indent, HB_T
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)
@@ -663,6 +666,10 @@ DEF_DUMP (Lookup)
lookup_name = "CHAIN";
lookup_func = Dump_GSUB_Lookup_Chain;
break;
+ default:
+ lookup_name = "(unknown)";
+ lookup_func = NULL;
+ break;
}
}
else
@@ -696,6 +703,10 @@ DEF_DUMP (Lookup)
case HB_GPOS_LOOKUP_CHAIN:
lookup_name = "CHAIN";
break;
+ default:
+ lookup_name = "(unknown)";
+ lookup_func = NULL;
+ break;
}
}
diff --git a/pango/opentype/harfbuzz-gdef-private.h b/pango/opentype/harfbuzz-gdef-private.h
index e07e2364..e93fd44e 100644
--- a/pango/opentype/harfbuzz-gdef-private.h
+++ b/pango/opentype/harfbuzz-gdef-private.h
@@ -87,11 +87,11 @@ struct HB_LigGlyph_
};
-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 );
diff --git a/pango/opentype/harfbuzz-gdef.c b/pango/opentype/harfbuzz-gdef.c
index 7a30d8bd..859c81bb 100644
--- a/pango/opentype/harfbuzz-gdef.c
+++ b/pango/opentype/harfbuzz-gdef.c
@@ -14,9 +14,9 @@
#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,
@@ -37,7 +37,7 @@ static void Free_NewGlyphClasses( HB_GDEFHeader* gdef,
#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 );
@@ -49,7 +49,7 @@ static FT_Error GDEF_Create( void* ext,
/* by convention */
if ( !gdef )
- return FT_Err_Ok;
+ return HB_Err_Ok;
/* a null offset indicates that there is no GDEF table */
@@ -59,7 +59,7 @@ static FT_Error GDEF_Create( void* ext,
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 ) )
@@ -72,11 +72,11 @@ static FT_Error GDEF_Create( void* ext,
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;
@@ -85,7 +85,7 @@ static FT_Error GDEF_Destroy( void* ext,
/* by convention */
if ( !gdef )
- return FT_Err_Ok;
+ return HB_Err_Ok;
if ( gdef->loaded )
{
@@ -97,18 +97,18 @@ static FT_Error GDEF_Destroy( void* ext,
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,
@@ -130,16 +130,16 @@ FT_Error HB_Init_GDEF_Extension( HB_Engine engine )
-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;
@@ -157,14 +157,14 @@ FT_Error HB_New_GDEF_Table( FT_Face face,
*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;
@@ -173,7 +173,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
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;
@@ -204,7 +204,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
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 );
}
@@ -223,7 +223,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
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 );
}
@@ -242,7 +242,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
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 );
}
@@ -265,7 +265,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
*retptr = gdef;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail3:
Free_LigCaretList( &gdef->LigCaretList, memory );
@@ -283,7 +283,7 @@ Fail0:
}
-FT_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef )
+HB_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef )
{
FT_Memory memory = gdef->memory;
@@ -296,7 +296,7 @@ FT_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef )
FREE( gdef );
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -309,11 +309,11 @@ FT_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef )
/* 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;
@@ -347,7 +347,7 @@ static FT_Error Load_AttachPoint( HB_AttachPoint* ap,
FORGET_Frame();
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -360,11 +360,11 @@ static void Free_AttachPoint( HB_AttachPoint* ap,
/* 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;
@@ -383,7 +383,7 @@ static FT_Error Load_AttachList( HB_AttachList* al,
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 );
@@ -412,14 +412,14 @@ static FT_Error Load_AttachList( HB_AttachList* al,
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++ )
@@ -470,10 +470,10 @@ static void Free_AttachList( HB_AttachList* al,
/* 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;
@@ -522,7 +522,7 @@ static FT_Error Load_CaretValue( HB_CaretValue* cv,
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 );
@@ -538,10 +538,10 @@ static FT_Error Load_CaretValue( HB_CaretValue* cv,
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;
}
@@ -555,11 +555,11 @@ static void Free_CaretValue( HB_CaretValue* cv,
/* 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;
@@ -594,12 +594,12 @@ static FT_Error Load_LigGlyph( HB_LigGlyph* lg,
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++ )
@@ -633,11 +633,11 @@ static void Free_LigGlyph( HB_LigGlyph* lg,
/* 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;
@@ -656,7 +656,7 @@ static FT_Error Load_LigCaretList( HB_LigCaretList* lcl,
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 );
@@ -685,14 +685,14 @@ static FT_Error Load_LigCaretList( HB_LigCaretList* lcl,
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++ )
@@ -778,17 +778,17 @@ static FT_UShort Get_New_Class( 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_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 */
@@ -800,7 +800,7 @@ FT_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
if ( !error )
{
*property = class << 8;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
}
@@ -816,6 +816,7 @@ FT_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
switch ( class )
{
+ default:
case UNCLASSIFIED_GLYPH:
*property = 0;
break;
@@ -837,17 +838,17 @@ FT_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
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;
@@ -873,12 +874,12 @@ static FT_Error Make_ClassRange( HB_ClassDefinition* cd,
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,
@@ -886,7 +887,7 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
{
FT_UShort start, curr_glyph, curr_class;
FT_UShort n, m, count;
- FT_Error error;
+ HB_Error error;
FT_Memory memory;
HB_ClassDefinition* gcd;
@@ -895,7 +896,7 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
if ( !gdef || !glyph_array || !class_array )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gdef->memory;
gcd = &gdef->GlyphClassDef;
@@ -918,13 +919,13 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
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] )
{
@@ -933,14 +934,14 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
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
@@ -952,12 +953,12 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
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;
}
@@ -967,7 +968,7 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
if ( curr_class >= 5 )
{
- error = FT_Err_Invalid_Argument;
+ error = HB_Err_Invalid_Argument;
goto Fail3;
}
@@ -976,14 +977,14 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
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
@@ -1046,7 +1047,7 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
gcd->loaded = TRUE;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
@@ -1084,11 +1085,11 @@ static void Free_NewGlyphClasses( HB_GDEFHeader* gdef,
}
-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;
@@ -1129,7 +1130,7 @@ FT_Error _HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
break;
default:
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
}
count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount;
@@ -1165,16 +1166,16 @@ FT_Error _HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
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 )
{
@@ -1221,7 +1222,7 @@ FT_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
*property = 0;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
diff --git a/pango/opentype/harfbuzz-gdef.h b/pango/opentype/harfbuzz-gdef.h
index e126e826..59e14b97 100644
--- a/pango/opentype/harfbuzz-gdef.h
+++ b/pango/opentype/harfbuzz-gdef.h
@@ -100,22 +100,22 @@ typedef struct HB_GDEFHeader_ HB_GDEFHeader;
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,
diff --git a/pango/opentype/harfbuzz-gpos-private.h b/pango/opentype/harfbuzz-gpos-private.h
index a04416f5..a36f3a48 100644
--- a/pango/opentype/harfbuzz-gpos-private.h
+++ b/pango/opentype/harfbuzz-gpos-private.h
@@ -670,7 +670,7 @@ typedef union HB_GPOS_SubTable_ HB_GPOS_SubTable;
-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 );
diff --git a/pango/opentype/harfbuzz-gpos.c b/pango/opentype/harfbuzz-gpos.c
index 6f0476ab..e3486f0d 100644
--- a/pango/opentype/harfbuzz-gpos.c
+++ b/pango/opentype/harfbuzz-gpos.c
@@ -4,6 +4,7 @@
* 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.
*
@@ -32,7 +33,7 @@ struct GPOS_Instance_
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,
@@ -43,7 +44,7 @@ static FT_Error GPOS_Do_Glyph_Lookup( GPOS_Instance* gpi,
/* 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 )
@@ -52,12 +53,12 @@ static FT_Error default_mmfunc( FT_Face face,
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 )
{
@@ -68,15 +69,12 @@ FT_Error HB_Load_GPOS_Table( FT_Face face,
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;
@@ -103,7 +101,7 @@ FT_Error HB_Load_GPOS_Table( FT_Face face,
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 );
@@ -117,7 +115,7 @@ FT_Error HB_Load_GPOS_Table( FT_Face face,
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 );
@@ -131,7 +129,7 @@ FT_Error HB_Load_GPOS_Table( FT_Face face,
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 */
@@ -157,7 +155,7 @@ FT_Error HB_Load_GPOS_Table( FT_Face face,
{
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;
@@ -167,7 +165,7 @@ FT_Error HB_Load_GPOS_Table( FT_Face face,
*retptr = gpos;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
_HB_OPEN_Free_LookupList( &gpos->LookupList, HB_Type_GPOS, memory );
@@ -185,7 +183,7 @@ Fail4:
}
-FT_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos )
+HB_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos )
{
FT_Memory memory = gpos->memory;
@@ -195,7 +193,7 @@ FT_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos )
FREE( gpos );
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -211,12 +209,12 @@ FT_Error HB_Done_GPOS_Table( HB_GPOSHeader* gpos )
`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;
@@ -286,7 +284,7 @@ static FT_Error Load_ValueRecord( HB_ValueRecord* vr,
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 );
}
@@ -317,7 +315,7 @@ static FT_Error Load_ValueRecord( HB_ValueRecord* vr,
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 );
}
@@ -348,7 +346,7 @@ static FT_Error Load_ValueRecord( HB_ValueRecord* vr,
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 );
}
@@ -379,7 +377,7 @@ static FT_Error Load_ValueRecord( HB_ValueRecord* vr,
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 );
}
@@ -442,7 +440,7 @@ static FT_Error Load_ValueRecord( HB_ValueRecord* vr,
else
vr->YIdAdvance = 0;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
_HB_OPEN_Free_Device( &vr->YAdvanceDevice, memory );
@@ -471,14 +469,14 @@ static void Free_ValueRecord( HB_ValueRecord* vr,
}
-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;
@@ -486,7 +484,7 @@ static FT_Error Get_ValueRecord( GPOS_Instance* gpi,
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;
@@ -574,10 +572,10 @@ static FT_Error Get_ValueRecord( GPOS_Instance* gpi,
/* 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;
@@ -633,7 +631,7 @@ static FT_Error Load_Anchor( HB_Anchor* an,
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 );
}
@@ -658,7 +656,7 @@ static FT_Error Load_Anchor( HB_Anchor* an,
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 );
}
@@ -681,10 +679,10 @@ static FT_Error Load_Anchor( HB_Anchor* an,
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 );
@@ -703,13 +701,13 @@ static void Free_Anchor( HB_Anchor* an,
}
-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;
@@ -731,6 +729,7 @@ static FT_Error Get_Anchor( GPOS_Instance* gpi,
{
case 0:
/* The special case of an empty AnchorTable */
+ default:
return HB_Err_Not_Covered;
@@ -751,7 +750,7 @@ static FT_Error Get_Anchor( GPOS_Instance* gpi,
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;
@@ -765,7 +764,7 @@ static FT_Error Get_Anchor( GPOS_Instance* gpi,
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;
@@ -812,10 +811,10 @@ static FT_Error Get_Anchor( GPOS_Instance* gpi,
/* 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;
@@ -852,12 +851,12 @@ static FT_Error Load_MarkArray ( HB_MarkArray* ma,
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++ )
@@ -894,10 +893,10 @@ static void Free_MarkArray( HB_MarkArray* ma,
/* 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;
@@ -920,11 +919,11 @@ static FT_Error Load_SinglePos( HB_GPOS_SubTable* st,
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 );
@@ -961,10 +960,10 @@ static FT_Error Load_SinglePos( HB_GPOS_SubTable* st,
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++ )
@@ -1007,28 +1006,14 @@ static void Free_SinglePos( HB_GPOS_SubTable* st,
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,
@@ -1036,7 +1021,7 @@ static FT_Error Lookup_SinglePos( GPOS_Instance* gpi,
int nesting_level )
{
FT_UShort index, property;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_SinglePos* sp = &st->single;
@@ -1063,7 +1048,7 @@ static FT_Error Lookup_SinglePos( GPOS_Instance* gpi,
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 )
@@ -1071,12 +1056,12 @@ static FT_Error Lookup_SinglePos( GPOS_Instance* gpi,
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;
}
@@ -1084,12 +1069,12 @@ static FT_Error Lookup_SinglePos( GPOS_Instance* gpi,
/* 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;
@@ -1143,7 +1128,7 @@ static FT_Error Load_PairSet ( HB_PairSet* ps,
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
@@ -1189,12 +1174,12 @@ static void Free_PairSet( HB_PairSet* ps,
/* 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;
@@ -1231,12 +1216,12 @@ static FT_Error Load_PairPos1( HB_PairPosFormat1* ppf1,
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++ )
@@ -1272,12 +1257,12 @@ static void Free_PairPos1( HB_PairPosFormat1* ppf1,
/* 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;
@@ -1306,11 +1291,11 @@ static FT_Error Load_PairPos2( HB_PairPosFormat2* ppf2,
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 );
@@ -1365,7 +1350,7 @@ static FT_Error Load_PairPos2( HB_PairPosFormat2* ppf2,
goto Fail1;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( k = 0; k < m; k++ )
@@ -1434,10 +1419,10 @@ static void Free_PairPos2( HB_PairPosFormat2* ppf2,
}
-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;
@@ -1460,7 +1445,7 @@ static FT_Error Load_PairPos( HB_GPOS_SubTable* st,
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 );
@@ -1479,10 +1464,10 @@ static FT_Error Load_PairPos( HB_GPOS_SubTable* st,
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 );
@@ -1509,13 +1494,16 @@ static void Free_PairPos( HB_GPOS_SubTable* st,
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,
@@ -1523,18 +1511,18 @@ static FT_Error Lookup_PairPos1( GPOS_Instance* gpi,
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();
@@ -1557,14 +1545,14 @@ static FT_Error Lookup_PairPos1( GPOS_Instance* gpi,
}
-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;
@@ -1582,7 +1570,7 @@ static FT_Error Lookup_PairPos2( GPOS_Instance* gpi,
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 ) );
@@ -1592,14 +1580,14 @@ static FT_Error Lookup_PairPos2( GPOS_Instance* gpi,
}
-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;
@@ -1654,7 +1642,7 @@ static FT_Error Lookup_PairPos( GPOS_Instance* gpi,
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
@@ -1676,10 +1664,10 @@ static FT_Error Lookup_PairPos( GPOS_Instance* gpi,
/* 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;
@@ -1701,7 +1689,7 @@ static FT_Error Load_CursivePos( HB_GPOS_SubTable* st,
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 );
@@ -1737,7 +1725,7 @@ static FT_Error Load_CursivePos( HB_GPOS_SubTable* st,
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 );
}
@@ -1758,7 +1746,7 @@ static FT_Error Load_CursivePos( HB_GPOS_SubTable* st,
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 );
@@ -1770,7 +1758,7 @@ static FT_Error Load_CursivePos( HB_GPOS_SubTable* st,
eer[n].ExitAnchor.PosFormat = 0;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
@@ -1814,7 +1802,7 @@ static void Free_CursivePos( HB_GPOS_SubTable* st,
}
-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,
@@ -1822,7 +1810,7 @@ static FT_Error Lookup_CursivePos( GPOS_Instance* gpi,
int nesting_level )
{
FT_UShort index, property;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_CursivePos* cp = &st->cursive;
@@ -1861,7 +1849,7 @@ static FT_Error Lookup_CursivePos( GPOS_Instance* gpi,
}
if ( index >= cp->EntryExitCount )
- return HB_Err_Invalid_GPOS_SubTable;
+ return _hb_err(HB_Err_Invalid_GPOS_SubTable);
eer = &cp->EntryExitRecord[index];
@@ -2033,7 +2021,7 @@ end:
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -2041,11 +2029,11 @@ end:
/* 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;
@@ -2090,14 +2078,17 @@ static FT_Error Load_BaseArray( HB_BaseArray* ba,
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 );
}
@@ -2109,7 +2100,7 @@ static FT_Error Load_BaseArray( HB_BaseArray* ba,
goto Fail;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( k = 0; k < m; k++ )
@@ -2159,10 +2150,10 @@ static void Free_BaseArray( HB_BaseArray* ba,
/* 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;
@@ -2180,11 +2171,11 @@ static FT_Error Load_MarkBasePos( HB_GPOS_SubTable* st,
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 );
@@ -2197,7 +2188,7 @@ static FT_Error Load_MarkBasePos( HB_GPOS_SubTable* st,
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 );
@@ -2211,7 +2202,7 @@ static FT_Error Load_MarkBasePos( HB_GPOS_SubTable* st,
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 );
@@ -2225,10 +2216,10 @@ static FT_Error Load_MarkBasePos( HB_GPOS_SubTable* st,
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 );
@@ -2254,7 +2245,7 @@ static void Free_MarkBasePos( HB_GPOS_SubTable* st,
}
-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,
@@ -2263,7 +2254,7 @@ static FT_Error Lookup_MarkBasePos( GPOS_Instance* gpi,
{
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;
@@ -2328,18 +2319,18 @@ static FT_Error Lookup_MarkBasePos( GPOS_Instance* gpi,
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];
@@ -2366,7 +2357,7 @@ static FT_Error Lookup_MarkBasePos( GPOS_Instance* gpi,
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -2374,11 +2365,11 @@ static FT_Error Lookup_MarkBasePos( GPOS_Instance* gpi,
/* 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;
@@ -2428,7 +2419,7 @@ static FT_Error Load_LigatureAttach( HB_LigatureAttach* lat,
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 );
}
@@ -2443,7 +2434,7 @@ static FT_Error Load_LigatureAttach( HB_LigatureAttach* lat,
goto Fail;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( k = 0; k < m; k++ )
@@ -2493,11 +2484,11 @@ static void Free_LigatureAttach( HB_LigatureAttach* lat,
/* 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;
@@ -2534,12 +2525,12 @@ static FT_Error Load_LigatureArray( HB_LigatureArray* la,
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++ )
@@ -2574,10 +2565,10 @@ static void Free_LigatureArray( HB_LigatureArray* la,
/* 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;
@@ -2596,7 +2587,7 @@ static FT_Error Load_MarkLigPos( HB_GPOS_SubTable* st,
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 );
@@ -2610,7 +2601,7 @@ static FT_Error Load_MarkLigPos( HB_GPOS_SubTable* st,
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 );
@@ -2624,7 +2615,7 @@ static FT_Error Load_MarkLigPos( HB_GPOS_SubTable* st,
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 );
@@ -2638,10 +2629,10 @@ static FT_Error Load_MarkLigPos( HB_GPOS_SubTable* st,
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 );
@@ -2667,7 +2658,7 @@ static void Free_MarkLigPos( HB_GPOS_SubTable* st,
}
-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,
@@ -2677,7 +2668,7 @@ static FT_Error Lookup_MarkLigPos( GPOS_Instance* gpi,
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;
@@ -2745,18 +2736,18 @@ static FT_Error Lookup_MarkLigPos( GPOS_Instance* gpi,
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];
@@ -2798,7 +2789,7 @@ static FT_Error Lookup_MarkLigPos( GPOS_Instance* gpi,
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -2806,11 +2797,11 @@ static FT_Error Lookup_MarkLigPos( GPOS_Instance* gpi,
/* 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;
@@ -2856,7 +2847,7 @@ static FT_Error Load_Mark2Array( HB_Mark2Array* m2a,
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 );
}
@@ -2868,7 +2859,7 @@ static FT_Error Load_Mark2Array( HB_Mark2Array* m2a,
goto Fail;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
for ( k = 0; k < m; k++ )
@@ -2918,10 +2909,10 @@ static void Free_Mark2Array( HB_Mark2Array* m2a,
/* 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;
@@ -2941,7 +2932,7 @@ static FT_Error Load_MarkMarkPos( HB_GPOS_SubTable* st,
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 );
@@ -2955,7 +2946,7 @@ static FT_Error Load_MarkMarkPos( HB_GPOS_SubTable* st,
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 );
@@ -2969,7 +2960,7 @@ static FT_Error Load_MarkMarkPos( HB_GPOS_SubTable* st,
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 );
@@ -2983,10 +2974,10 @@ static FT_Error Load_MarkMarkPos( HB_GPOS_SubTable* st,
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 );
@@ -3012,7 +3003,7 @@ static void Free_MarkMarkPos( HB_GPOS_SubTable* st,
}
-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,
@@ -3022,7 +3013,7 @@ static FT_Error Lookup_MarkMarkPos( GPOS_Instance* gpi,
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;
@@ -3089,18 +3080,18 @@ static FT_Error Lookup_MarkMarkPos( GPOS_Instance* gpi,
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];
@@ -3126,7 +3117,7 @@ static FT_Error Lookup_MarkMarkPos( GPOS_Instance* gpi,
(buffer->in_pos)++;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -3134,14 +3125,14 @@ static FT_Error Lookup_MarkMarkPos( GPOS_Instance* gpi,
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;
@@ -3172,7 +3163,7 @@ static FT_Error Do_ContextPos( GPOS_Instance* gpi,
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -3180,10 +3171,10 @@ static FT_Error Do_ContextPos( GPOS_Instance* gpi,
/* 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;
@@ -3237,7 +3228,7 @@ static FT_Error Load_PosRule( HB_PosRule* pr,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
@@ -3258,10 +3249,10 @@ static void Free_PosRule( HB_PosRule* pr,
/* 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;
@@ -3297,12 +3288,12 @@ static FT_Error Load_PosRuleSet( HB_PosRuleSet* prs,
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++ )
@@ -3336,10 +3327,10 @@ static void Free_PosRuleSet( HB_PosRuleSet* prs,
/* 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;
@@ -3359,7 +3350,7 @@ static FT_Error Load_ContextPos1( HB_ContextPosFormat1* cpf1,
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 );
@@ -3388,12 +3379,12 @@ static FT_Error Load_ContextPos1( HB_ContextPosFormat1* cpf1,
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++ )
@@ -3432,11 +3423,11 @@ static void Free_ContextPos1( HB_ContextPosFormat1* cpf1,
/* 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;
@@ -3503,7 +3494,7 @@ static FT_Error Load_PosClassRule( HB_ContextPosFormat2* cpf2,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
@@ -3524,11 +3515,11 @@ static void Free_PosClassRule( HB_PosClassRule* pcr,
/* 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;
@@ -3565,12 +3556,12 @@ static FT_Error Load_PosClassSet( HB_ContextPosFormat2* cpf2,
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++ )
@@ -3604,10 +3595,10 @@ static void Free_PosClassSet( HB_PosClassSet* pcs,
/* 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;
@@ -3627,7 +3618,7 @@ static FT_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2,
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 );
@@ -3646,7 +3637,7 @@ static FT_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2,
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 );
@@ -3672,7 +3663,7 @@ static FT_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2,
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 );
}
@@ -3685,7 +3676,7 @@ static FT_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2,
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; n++ )
@@ -3728,10 +3719,10 @@ static void Free_ContextPos2( HB_ContextPosFormat2* cpf2,
/* 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;
@@ -3771,7 +3762,7 @@ static FT_Error Load_ContextPos3( HB_ContextPosFormat3* cpf3,
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 );
}
@@ -3796,7 +3787,7 @@ static FT_Error Load_ContextPos3( HB_ContextPosFormat3* cpf3,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
@@ -3835,10 +3826,10 @@ static void Free_ContextPos3( HB_ContextPosFormat3* cpf3,
/* 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;
@@ -3861,10 +3852,10 @@ static FT_Error Load_ContextPos( HB_GPOS_SubTable* st,
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 */
}
@@ -3875,22 +3866,15 @@ static void Free_ContextPos( HB_GPOS_SubTable* st,
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,
@@ -3899,7 +3883,7 @@ static FT_Error Lookup_ContextPos1( GPOS_Instance* gpi,
{
FT_UShort index, property;
FT_UShort i, j, k, numpr;
- FT_Error error;
+ HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_PosRule* pr;
@@ -3955,7 +3939,7 @@ static FT_Error Lookup_ContextPos1( GPOS_Instance* gpi,
}
-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,
@@ -3963,7 +3947,7 @@ static FT_Error Lookup_ContextPos2( GPOS_Instance* gpi,
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;
@@ -4001,7 +3985,7 @@ static FT_Error Lookup_ContextPos2( GPOS_Instance* gpi,
pcs = &cpf2->PosClassSet[classes[0]];
if ( !pcs )
{
- error = HB_Err_Invalid_GPOS_SubTable;
+ error = _hb_err(HB_Err_Invalid_GPOS_SubTable);
goto End;
}
@@ -4063,14 +4047,14 @@ 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;
@@ -4115,7 +4099,7 @@ static FT_Error Lookup_ContextPos3( GPOS_Instance* gpi,
}
-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,
@@ -4139,10 +4123,10 @@ static FT_Error Lookup_ContextPos( GPOS_Instance* gpi,
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 */
}
@@ -4150,10 +4134,10 @@ static FT_Error Lookup_ContextPos( GPOS_Instance* gpi,
/* 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;
@@ -4263,7 +4247,7 @@ static FT_Error Load_ChainPosRule( HB_ChainPosRule* cpr,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
@@ -4292,10 +4276,10 @@ static void Free_ChainPosRule( HB_ChainPosRule* cpr,
/* 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;
@@ -4331,12 +4315,12 @@ static FT_Error Load_ChainPosRuleSet( HB_ChainPosRuleSet* cprs,
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++ )
@@ -4370,10 +4354,10 @@ static void Free_ChainPosRuleSet( HB_ChainPosRuleSet* cprs,
/* 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;
@@ -4393,7 +4377,7 @@ static FT_Error Load_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1,
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 );
@@ -4422,12 +4406,12 @@ static FT_Error Load_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1,
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++ )
@@ -4466,12 +4450,12 @@ static void Free_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1,
/* 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;
@@ -4612,7 +4596,7 @@ static FT_Error Load_ChainPosClassRule(
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
@@ -4641,12 +4625,12 @@ static void Free_ChainPosClassRule( HB_ChainPosClassRule* cpcr,
/* 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;
@@ -4684,12 +4668,12 @@ static FT_Error Load_ChainPosClassSet(
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++ )
@@ -4721,13 +4705,13 @@ static void Free_ChainPosClassSet( HB_ChainPosClassSet* cpcs,
}
-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();
@@ -4740,7 +4724,7 @@ static FT_Error GPOS_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
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;
@@ -4748,10 +4732,10 @@ static FT_Error GPOS_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
/* 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;
@@ -4772,7 +4756,7 @@ static FT_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2,
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 );
@@ -4793,15 +4777,15 @@ static FT_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2,
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;
@@ -4828,7 +4812,7 @@ static FT_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2,
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 );
}
@@ -4841,7 +4825,7 @@ static FT_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2,
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
@@ -4893,10 +4877,10 @@ static void Free_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2,
/* 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;
@@ -4939,7 +4923,7 @@ static FT_Error Load_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3,
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 );
}
@@ -4971,7 +4955,7 @@ static FT_Error Load_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3,
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 );
}
@@ -5004,7 +4988,7 @@ static FT_Error Load_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3,
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 );
}
@@ -5036,7 +5020,7 @@ static FT_Error Load_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( plr );
@@ -5109,10 +5093,10 @@ static void Free_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3,
/* 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;
@@ -5135,10 +5119,10 @@ static FT_Error Load_ChainContextPos( HB_GPOS_SubTable* st,
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 */
}
@@ -5149,22 +5133,15 @@ static void Free_ChainContextPos( HB_GPOS_SubTable* st,
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,
@@ -5175,7 +5152,7 @@ static FT_Error Lookup_ChainContextPos1(
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;
@@ -5293,7 +5270,7 @@ static FT_Error Lookup_ChainContextPos1(
}
-static FT_Error Lookup_ChainContextPos2(
+static HB_Error Lookup_ChainContextPos2(
GPOS_Instance* gpi,
HB_ChainContextPosFormat2* ccpf2,
HB_Buffer buffer,
@@ -5303,7 +5280,7 @@ static FT_Error Lookup_ChainContextPos2(
{
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,
@@ -5357,7 +5334,7 @@ static FT_Error Lookup_ChainContextPos2(
cpcs = &ccpf2->ChainPosClassSet[input_classes[0]];
if ( !cpcs )
{
- error = HB_Err_Invalid_GPOS_SubTable;
+ error = _hb_err(HB_Err_Invalid_GPOS_SubTable);
goto End1;
}
@@ -5496,7 +5473,7 @@ End3:
}
-static FT_Error Lookup_ChainContextPos3(
+static HB_Error Lookup_ChainContextPos3(
GPOS_Instance* gpi,
HB_ChainContextPosFormat3* ccpf3,
HB_Buffer buffer,
@@ -5506,7 +5483,7 @@ static FT_Error Lookup_ChainContextPos3(
{
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;
@@ -5607,7 +5584,7 @@ static FT_Error Lookup_ChainContextPos3(
}
-static FT_Error Lookup_ChainContextPos(
+static HB_Error Lookup_ChainContextPos(
GPOS_Instance* gpi,
HB_GPOS_SubTable* st,
HB_Buffer buffer,
@@ -5635,10 +5612,10 @@ static FT_Error Lookup_ChainContextPos(
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 */
}
@@ -5649,7 +5626,7 @@ static FT_Error Lookup_ChainContextPos(
-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 )
{
@@ -5660,7 +5637,7 @@ FT_Error HB_GPOS_Select_Script( HB_GPOSHeader* gpos,
if ( !gpos || !script_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gpos->ScriptList;
sr = sl->ScriptRecord;
@@ -5670,7 +5647,7 @@ FT_Error HB_GPOS_Select_Script( HB_GPOSHeader* gpos,
{
*script_index = n;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
return HB_Err_Not_Covered;
@@ -5678,7 +5655,7 @@ FT_Error HB_GPOS_Select_Script( HB_GPOSHeader* gpos,
-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,
@@ -5693,13 +5670,13 @@ FT_Error HB_GPOS_Select_Language( HB_GPOSHeader* gpos,
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;
@@ -5710,7 +5687,7 @@ FT_Error HB_GPOS_Select_Language( HB_GPOSHeader* gpos,
*language_index = n;
*req_feature_index = lsr[n].LangSys.ReqFeatureIndex;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
return HB_Err_Not_Covered;
@@ -5721,7 +5698,7 @@ FT_Error HB_GPOS_Select_Language( HB_GPOSHeader* gpos,
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,
@@ -5741,7 +5718,7 @@ FT_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
if ( !gpos || !feature_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gpos->ScriptList;
sr = sl->ScriptRecord;
@@ -5750,7 +5727,7 @@ FT_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
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;
@@ -5760,7 +5737,7 @@ FT_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
else
{
if ( language_index >= s->LangSysCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
ls = &lsr[language_index].LangSys;
}
@@ -5770,13 +5747,13 @@ FT_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
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;
}
}
@@ -5787,10 +5764,10 @@ FT_Error HB_GPOS_Select_Feature( HB_GPOSHeader* gpos,
/* 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;
@@ -5800,7 +5777,7 @@ FT_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos,
if ( !gpos || !script_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gpos->memory;
sl = &gpos->ScriptList;
@@ -5815,16 +5792,16 @@ FT_Error HB_GPOS_Query_Scripts( HB_GPOSHeader* gpos,
*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;
@@ -5836,14 +5813,14 @@ FT_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos,
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;
@@ -5857,7 +5834,7 @@ FT_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos,
*language_tag_list = ltl;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -5865,13 +5842,13 @@ FT_Error HB_GPOS_Query_Languages( HB_GPOSHeader* gpos,
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;
@@ -5887,7 +5864,7 @@ FT_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
if ( !gpos || !feature_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gpos->memory;
sl = &gpos->ScriptList;
@@ -5897,7 +5874,7 @@ FT_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
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;
@@ -5907,7 +5884,7 @@ FT_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
else
{
if ( language_index >= s->LangSysCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
ls = &lsr[language_index].LangSys;
}
@@ -5922,7 +5899,7 @@ FT_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
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;
}
@@ -5930,49 +5907,29 @@ FT_Error HB_GPOS_Query_Features( HB_GPOSHeader* gpos,
*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)
@@ -5981,21 +5938,36 @@ static FT_Error GPOS_Do_Glyph_Lookup( GPOS_Instance* gpi,
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;
}
@@ -6004,106 +5976,67 @@ static FT_Error GPOS_Do_Glyph_Lookup( GPOS_Instance* gpi,
}
-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
@@ -6111,8 +6044,7 @@ static FT_Error GPOS_Do_String_Lookup( GPOS_Instance* gpi,
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;
}
@@ -6135,7 +6067,7 @@ static FT_Error GPOS_Do_String_Lookup( GPOS_Instance* gpi,
}
-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;
@@ -6156,11 +6088,11 @@ static FT_Error Position_CursiveChain ( HB_Buffer buffer )
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 )
{
@@ -6176,7 +6108,7 @@ FT_Error HB_GPOS_Add_Feature( HB_GPOSHeader* gpos,
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;
@@ -6193,12 +6125,12 @@ FT_Error HB_GPOS_Add_Feature( HB_GPOSHeader* gpos,
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;
@@ -6206,7 +6138,7 @@ FT_Error HB_GPOS_Clear_Features( HB_GPOSHeader* gpos )
if ( !gpos )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gpos->FeatureList.ApplyCount = 0;
@@ -6215,56 +6147,57 @@ FT_Error HB_GPOS_Clear_Features( HB_GPOSHeader* gpos )
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;
@@ -6276,9 +6209,8 @@ FT_Error HB_GPOS_Apply_String( FT_Face face,
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++ )
{
diff --git a/pango/opentype/harfbuzz-gpos.h b/pango/opentype/harfbuzz-gpos.h
index 1c670279..2db7938a 100644
--- a/pango/opentype/harfbuzz-gpos.h
+++ b/pango/opentype/harfbuzz-gpos.h
@@ -48,7 +48,7 @@ FT_BEGIN_HEADER
_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 );
@@ -64,7 +64,7 @@ typedef FT_Error (*HB_GlyphFunction)(FT_Face face,
`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 );
@@ -99,56 +99,56 @@ typedef struct HB_GPOSHeader_ HB_GPOSHeader;
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 );
@@ -156,7 +156,7 @@ FT_Error HB_GPOS_Register_MM_Function( HB_GPOSHeader* gpos,
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,
diff --git a/pango/opentype/harfbuzz-gsub-private.h b/pango/opentype/harfbuzz-gsub-private.h
index 84c08df5..bc6d1b44 100644
--- a/pango/opentype/harfbuzz-gsub-private.h
+++ b/pango/opentype/harfbuzz-gsub-private.h
@@ -435,7 +435,7 @@ union HB_GSUB_SubTable_
-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 );
diff --git a/pango/opentype/harfbuzz-gsub.c b/pango/opentype/harfbuzz-gsub.c
index 23b87b85..ab6721a7 100644
--- a/pango/opentype/harfbuzz-gsub.c
+++ b/pango/opentype/harfbuzz-gsub.c
@@ -4,6 +4,7 @@
* 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.
*
@@ -15,7 +16,7 @@
#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,
@@ -29,13 +30,13 @@ static FT_Error GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
-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;
@@ -43,7 +44,7 @@ FT_Error HB_Load_GSUB_Table( FT_Face face,
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;
@@ -68,7 +69,7 @@ FT_Error HB_Load_GSUB_Table( FT_Face face,
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 );
@@ -82,7 +83,7 @@ FT_Error HB_Load_GSUB_Table( FT_Face face,
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 );
@@ -96,7 +97,7 @@ FT_Error HB_Load_GSUB_Table( FT_Face face,
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 */
@@ -123,7 +124,7 @@ FT_Error HB_Load_GSUB_Table( FT_Face face,
{
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;
@@ -133,7 +134,7 @@ FT_Error HB_Load_GSUB_Table( FT_Face face,
*retptr = gsub;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
_HB_OPEN_Free_LookupList( &gsub->LookupList, HB_Type_GSUB, memory );
@@ -152,7 +153,7 @@ Fail4:
}
-FT_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub )
+HB_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub )
{
FT_Memory memory = gsub->memory;
@@ -162,39 +163,23 @@ FT_Error HB_Done_GSUB_Table( HB_GSUBHeader* gsub )
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;
@@ -216,7 +201,7 @@ static FT_Error Load_SingleSubst( HB_GSUB_SubTable* st,
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 );
@@ -258,10 +243,10 @@ static FT_Error Load_SingleSubst( HB_GSUB_SubTable* st,
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 );
@@ -285,13 +270,16 @@ static void Free_SingleSubst( HB_GSUB_SubTable* st,
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,
@@ -299,13 +287,12 @@ static FT_Error Lookup_SingleSubst( HB_GSUBHeader* gsub,
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;
@@ -319,21 +306,21 @@ static FT_Error Lookup_SingleSubst( HB_GSUBHeader* gsub,
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 )
@@ -345,7 +332,7 @@ static FT_Error Lookup_SingleSubst( HB_GSUBHeader* gsub,
return error;
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -353,10 +340,10 @@ static FT_Error Lookup_SingleSubst( HB_GSUBHeader* gsub,
/* 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;
@@ -391,7 +378,7 @@ static FT_Error Load_Sequence( HB_Sequence* s,
FORGET_Frame();
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -404,10 +391,10 @@ static void Free_Sequence( HB_Sequence* s,
/* 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;
@@ -429,7 +416,7 @@ static FT_Error Load_MultipleSubst( HB_GSUB_SubTable* st,
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 );
@@ -458,12 +445,12 @@ static FT_Error Load_MultipleSubst( HB_GSUB_SubTable* st,
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++ )
@@ -501,14 +488,14 @@ static void Free_MultipleSubst( HB_GSUB_SubTable* st,
}
-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;
@@ -527,7 +514,7 @@ static FT_Error Lookup_MultipleSubst( HB_GSUBHeader* gsub,
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;
@@ -550,7 +537,7 @@ static FT_Error Lookup_MultipleSubst( HB_GSUBHeader* gsub,
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -558,10 +545,10 @@ static FT_Error Lookup_MultipleSubst( HB_GSUBHeader* gsub,
/* 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;
@@ -593,7 +580,7 @@ static FT_Error Load_AlternateSet( HB_AlternateSet* as,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -606,10 +593,10 @@ static void Free_AlternateSet( HB_AlternateSet* as,
/* 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;
@@ -631,7 +618,7 @@ static FT_Error Load_AlternateSubst( HB_GSUB_SubTable* st,
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 );
@@ -660,12 +647,12 @@ static FT_Error Load_AlternateSubst( HB_GSUB_SubTable* st,
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++ )
@@ -703,15 +690,15 @@ static void Free_AlternateSubst( HB_GSUB_SubTable* st,
}
-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;
@@ -739,21 +726,20 @@ static FT_Error Lookup_AlternateSubst( HB_GSUBHeader* gsub,
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;
}
@@ -761,10 +747,10 @@ static FT_Error Lookup_AlternateSubst( HB_GSUBHeader* gsub,
/* 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;
@@ -799,7 +785,7 @@ static FT_Error Load_Ligature( HB_Ligature* l,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -812,10 +798,10 @@ static void Free_Ligature( HB_Ligature* l,
/* 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;
@@ -851,12 +837,12 @@ static FT_Error Load_LigatureSet( HB_LigatureSet* ls,
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++ )
@@ -890,10 +876,10 @@ static void Free_LigatureSet( HB_LigatureSet* ls,
/* 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;
@@ -915,7 +901,7 @@ static FT_Error Load_LigatureSubst( HB_GSUB_SubTable* st,
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 );
@@ -944,12 +930,12 @@ static FT_Error Load_LigatureSubst( HB_GSUB_SubTable* st,
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++ )
@@ -987,7 +973,7 @@ static void Free_LigatureSubst( HB_GSUB_SubTable* st,
}
-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,
@@ -995,7 +981,7 @@ static FT_Error Lookup_LigatureSubst( HB_GSUBHeader* gsub,
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;
@@ -1016,7 +1002,7 @@ static FT_Error Lookup_LigatureSubst( HB_GSUBHeader* gsub,
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;
@@ -1085,8 +1071,7 @@ static FT_Error Lookup_LigatureSubst( HB_GSUBHeader* gsub,
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
@@ -1100,15 +1085,14 @@ static FT_Error Lookup_LigatureSubst( HB_GSUBHeader* gsub,
{
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:
;
@@ -1122,14 +1106,14 @@ static FT_Error Lookup_LigatureSubst( HB_GSUBHeader* gsub,
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;
@@ -1152,10 +1136,7 @@ static FT_Error Do_ContextSubst( HB_GSUBHeader* gsub,
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++;
}
@@ -1166,14 +1147,13 @@ static FT_Error Do_ContextSubst( HB_GSUBHeader* gsub,
{
/* 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;
}
@@ -1181,10 +1161,10 @@ static FT_Error Do_ContextSubst( HB_GSUBHeader* gsub,
/* 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;
@@ -1238,7 +1218,7 @@ static FT_Error Load_SubRule( HB_SubRule* sr,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
@@ -1259,10 +1239,10 @@ static void Free_SubRule( HB_SubRule* sr,
/* 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;
@@ -1298,12 +1278,12 @@ static FT_Error Load_SubRuleSet( HB_SubRuleSet* srs,
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++ )
@@ -1337,10 +1317,10 @@ static void Free_SubRuleSet( HB_SubRuleSet* srs,
/* 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;
@@ -1360,7 +1340,7 @@ static FT_Error Load_ContextSubst1( HB_ContextSubstFormat1* csf1,
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 );
@@ -1389,12 +1369,12 @@ static FT_Error Load_ContextSubst1( HB_ContextSubstFormat1* csf1,
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++ )
@@ -1433,11 +1413,11 @@ static void Free_ContextSubst1( HB_ContextSubstFormat1* csf1,
/* 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;
@@ -1503,7 +1483,7 @@ static FT_Error Load_SubClassRule( HB_ContextSubstFormat2* csf2,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
@@ -1524,11 +1504,11 @@ static void Free_SubClassRule( HB_SubClassRule* scr,
/* 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;
@@ -1565,12 +1545,12 @@ static FT_Error Load_SubClassSet( HB_ContextSubstFormat2* csf2,
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++ )
@@ -1604,10 +1584,10 @@ static void Free_SubClassSet( HB_SubClassSet* scs,
/* 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;
@@ -1627,7 +1607,7 @@ static FT_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2,
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 );
@@ -1646,7 +1626,7 @@ static FT_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2,
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 );
@@ -1672,7 +1652,7 @@ static FT_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2,
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 );
}
@@ -1685,7 +1665,7 @@ static FT_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2,
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
@@ -1728,10 +1708,10 @@ static void Free_ContextSubst2( HB_ContextSubstFormat2* csf2,
/* 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;
@@ -1771,7 +1751,7 @@ static FT_Error Load_ContextSubst3( HB_ContextSubstFormat3* csf3,
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 );
}
@@ -1797,7 +1777,7 @@ static FT_Error Load_ContextSubst3( HB_ContextSubstFormat3* csf3,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
@@ -1836,10 +1816,10 @@ static void Free_ContextSubst3( HB_ContextSubstFormat3* csf3,
/* 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;
@@ -1852,20 +1832,13 @@ static FT_Error Load_ContextSubst( HB_GSUB_SubTable* st,
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 */
}
@@ -1876,22 +1849,15 @@ static void Free_ContextSubst( HB_GSUB_SubTable* st,
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,
@@ -1900,7 +1866,7 @@ static FT_Error Lookup_ContextSubst1( HB_GSUBHeader* gsub,
{
FT_UShort index, property;
FT_UShort i, j, k, numsr;
- FT_Error error;
+ HB_Error error;
HB_SubRule* sr;
HB_GDEFHeader* gdef;
@@ -1954,7 +1920,7 @@ static FT_Error Lookup_ContextSubst1( HB_GSUBHeader* gsub,
}
-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,
@@ -1962,7 +1928,7 @@ static FT_Error Lookup_ContextSubst2( HB_GSUBHeader* gsub,
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;
@@ -1999,7 +1965,7 @@ static FT_Error Lookup_ContextSubst2( HB_GSUBHeader* gsub,
scs = &csf2->SubClassSet[classes[0]];
if ( !scs )
{
- error = HB_Err_Invalid_GSUB_SubTable;
+ error = _hb_err(HB_Err_Invalid_GSUB_SubTable);
goto End;
}
@@ -2061,14 +2027,14 @@ 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;
@@ -2112,7 +2078,7 @@ static FT_Error Lookup_ContextSubst3( HB_GSUBHeader* gsub,
}
-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,
@@ -2123,23 +2089,13 @@ static FT_Error Lookup_ContextSubst( HB_GSUBHeader* gsub,
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 */
}
@@ -2147,10 +2103,10 @@ static FT_Error Lookup_ContextSubst( HB_GSUBHeader* gsub,
/* 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;
@@ -2260,7 +2216,7 @@ static FT_Error Load_ChainSubRule( HB_ChainSubRule* csr,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
@@ -2289,10 +2245,10 @@ static void Free_ChainSubRule( HB_ChainSubRule* csr,
/* 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;
@@ -2328,12 +2284,12 @@ static FT_Error Load_ChainSubRuleSet( HB_ChainSubRuleSet* csrs,
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++ )
@@ -2367,11 +2323,11 @@ static void Free_ChainSubRuleSet( HB_ChainSubRuleSet* csrs,
/* 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;
@@ -2391,7 +2347,7 @@ static FT_Error Load_ChainContextSubst1(
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 );
@@ -2420,12 +2376,12 @@ static FT_Error Load_ChainContextSubst1(
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++ )
@@ -2464,12 +2420,12 @@ static void Free_ChainContextSubst1( HB_ChainContextSubstFormat1* ccsf1,
/* 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;
@@ -2611,7 +2567,7 @@ static FT_Error Load_ChainSubClassRule(
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
@@ -2640,12 +2596,12 @@ static void Free_ChainSubClassRule( HB_ChainSubClassRule* cscr,
/* 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;
@@ -2683,12 +2639,12 @@ static FT_Error Load_ChainSubClassSet(
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++ )
@@ -2719,13 +2675,13 @@ static void Free_ChainSubClassSet( HB_ChainSubClassSet* cscs,
}
}
-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();
@@ -2738,7 +2694,7 @@ static FT_Error GSUB_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
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;
@@ -2747,11 +2703,11 @@ static FT_Error GSUB_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
/* 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;
@@ -2772,7 +2728,7 @@ static FT_Error Load_ChainContextSubst2(
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 );
@@ -2793,16 +2749,16 @@ static FT_Error Load_ChainContextSubst2(
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;
@@ -2829,7 +2785,7 @@ static FT_Error Load_ChainContextSubst2(
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 );
}
@@ -2842,7 +2798,7 @@ static FT_Error Load_ChainContextSubst2(
}
}
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
for ( m = 0; m < n; m++ )
@@ -2894,11 +2850,11 @@ static void Free_ChainContextSubst2( HB_ChainContextSubstFormat2* ccsf2,
/* 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;
@@ -2941,7 +2897,7 @@ static FT_Error Load_ChainContextSubst3(
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 );
}
@@ -2973,7 +2929,7 @@ static FT_Error Load_ChainContextSubst3(
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 );
}
@@ -3006,7 +2962,7 @@ static FT_Error Load_ChainContextSubst3(
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 );
}
@@ -3039,7 +2995,7 @@ static FT_Error Load_ChainContextSubst3(
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( slr );
@@ -3112,10 +3068,10 @@ static void Free_ChainContextSubst3( HB_ChainContextSubstFormat3* ccsf3,
/* 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 ) )
@@ -3125,22 +3081,14 @@ static FT_Error Load_ChainContextSubst( HB_GSUB_SubTable* st,
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 */
}
@@ -3149,24 +3097,16 @@ static void Free_ChainContextSubst( HB_GSUB_SubTable* st,
{
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,
@@ -3176,7 +3116,7 @@ static FT_Error Lookup_ChainContextSubst1( HB_GSUBHeader* gsub,
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;
@@ -3293,7 +3233,7 @@ static FT_Error Lookup_ChainContextSubst1( HB_GSUBHeader* gsub,
}
-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,
@@ -3302,7 +3242,7 @@ static FT_Error Lookup_ChainContextSubst2( HB_GSUBHeader* gsub,
{
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,
@@ -3356,7 +3296,7 @@ static FT_Error Lookup_ChainContextSubst2( HB_GSUBHeader* gsub,
cscs = &ccsf2->ChainSubClassSet[input_classes[0]];
if ( !cscs )
{
- error = HB_Err_Invalid_GSUB_SubTable;
+ error = _hb_err(HB_Err_Invalid_GSUB_SubTable);
goto End1;
}
@@ -3495,7 +3435,7 @@ End3:
}
-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,
@@ -3504,7 +3444,7 @@ static FT_Error Lookup_ChainContextSubst3( HB_GSUBHeader* gsub,
{
FT_UShort index, i, j, property;
FT_UShort bgc, igc, lgc;
- FT_Error error;
+ HB_Error error;
HB_Coverage* bc;
HB_Coverage* ic;
@@ -3604,7 +3544,7 @@ static FT_Error Lookup_ChainContextSubst3( HB_GSUBHeader* gsub,
}
-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,
@@ -3613,35 +3553,19 @@ static FT_Error Lookup_ChainContextSubst( HB_GSUBHeader* gsub,
{
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;
@@ -3663,7 +3587,7 @@ static FT_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
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();
@@ -3676,7 +3600,7 @@ static FT_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
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 );
@@ -3709,7 +3633,7 @@ static FT_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
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 );
}
@@ -3743,7 +3667,7 @@ static FT_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
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 );
}
@@ -3773,7 +3697,7 @@ static FT_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail1:
FREE( sub );
@@ -3832,24 +3756,28 @@ static void Free_ReverseChainContextSubst( HB_GSUB_SubTable* st,
}
-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;
@@ -3857,7 +3785,7 @@ static FT_Error Lookup_ReverseChainContextSubst( HB_GSUBHeader* gsub,
/* 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 )
@@ -3867,7 +3795,7 @@ static FT_Error Lookup_ReverseChainContextSubst( HB_GSUBHeader* gsub,
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 ) )
{
@@ -3885,20 +3813,15 @@ static FT_Error Lookup_ReverseChainContextSubst( HB_GSUBHeader* gsub,
}
}
- 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 ) )
{
@@ -3915,7 +3838,8 @@ static FT_Error Lookup_ReverseChainContextSubst( HB_GSUBHeader* gsub,
return error;
}
- IN_GLYPH( string_index ) = rccs->Substitute[input_index];
+ IN_CURGLYPH() = rccs->Substitute[input_index];
+ buffer->in_pos--; /* Reverse! */
return error;
}
@@ -3928,7 +3852,7 @@ static FT_Error Lookup_ReverseChainContextSubst( 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 )
{
@@ -3939,7 +3863,7 @@ FT_Error HB_GSUB_Select_Script( HB_GSUBHeader* gsub,
if ( !gsub || !script_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gsub->ScriptList;
sr = sl->ScriptRecord;
@@ -3949,7 +3873,7 @@ FT_Error HB_GSUB_Select_Script( HB_GSUBHeader* gsub,
{
*script_index = n;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
return HB_Err_Not_Covered;
@@ -3957,7 +3881,7 @@ FT_Error HB_GSUB_Select_Script( HB_GSUBHeader* gsub,
-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,
@@ -3972,13 +3896,13 @@ FT_Error HB_GSUB_Select_Language( HB_GSUBHeader* gsub,
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;
@@ -3989,7 +3913,7 @@ FT_Error HB_GSUB_Select_Language( HB_GSUBHeader* gsub,
*language_index = n;
*req_feature_index = lsr[n].LangSys.ReqFeatureIndex;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
return HB_Err_Not_Covered;
@@ -4000,7 +3924,7 @@ FT_Error HB_GSUB_Select_Language( HB_GSUBHeader* gsub,
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,
@@ -4020,7 +3944,7 @@ FT_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
if ( !gsub || !feature_index )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
sl = &gsub->ScriptList;
sr = sl->ScriptRecord;
@@ -4029,7 +3953,7 @@ FT_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
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;
@@ -4039,7 +3963,7 @@ FT_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
else
{
if ( language_index >= s->LangSysCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
ls = &lsr[language_index].LangSys;
}
@@ -4049,13 +3973,13 @@ FT_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
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;
}
}
@@ -4066,11 +3990,11 @@ FT_Error HB_GSUB_Select_Feature( HB_GSUBHeader* gsub,
/* 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;
@@ -4079,7 +4003,7 @@ FT_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub,
if ( !gsub || !script_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gsub->memory;
@@ -4095,17 +4019,17 @@ FT_Error HB_GSUB_Query_Scripts( HB_GSUBHeader* gsub,
*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;
@@ -4116,7 +4040,7 @@ FT_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
if ( !gsub || !language_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gsub->memory;
@@ -4124,7 +4048,7 @@ FT_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
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;
@@ -4138,7 +4062,7 @@ FT_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
*language_tag_list = ltl;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -4146,13 +4070,13 @@ FT_Error HB_GSUB_Query_Languages( HB_GSUBHeader* gsub,
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;
@@ -4168,7 +4092,7 @@ FT_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
if ( !gsub || !feature_tag_list )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
memory = gsub->memory;
@@ -4179,7 +4103,7 @@ FT_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
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;
@@ -4189,7 +4113,7 @@ FT_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
else
{
if ( language_index >= s->LangSysCount )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
ls = &lsr[language_index].LangSys;
}
@@ -4204,7 +4128,7 @@ FT_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
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;
}
@@ -4212,51 +4136,27 @@ FT_Error HB_GSUB_Query_Features( HB_GSUBHeader* gsub,
*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)
@@ -4266,21 +4166,33 @@ static FT_Error GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
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;
}
@@ -4289,163 +4201,135 @@ static FT_Error GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
}
-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 )
{
@@ -4461,7 +4345,7 @@ FT_Error HB_GSUB_Add_Feature( HB_GSUBHeader* gsub,
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;
@@ -4478,12 +4362,12 @@ FT_Error HB_GSUB_Add_Feature( HB_GSUBHeader* gsub,
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;
@@ -4491,7 +4375,7 @@ FT_Error HB_GSUB_Clear_Features( HB_GSUBHeader* gsub )
if ( !gsub )
- return FT_Err_Invalid_Argument;
+ return HB_Err_Invalid_Argument;
gsub->FeatureList.ApplyCount = 0;
@@ -4500,91 +4384,68 @@ FT_Error HB_GSUB_Clear_Features( HB_GSUBHeader* gsub )
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;
}
diff --git a/pango/opentype/harfbuzz-gsub.h b/pango/opentype/harfbuzz-gsub.h
index 09145bad..3c72981e 100644
--- a/pango/opentype/harfbuzz-gsub.h
+++ b/pango/opentype/harfbuzz-gsub.h
@@ -73,57 +73,57 @@ typedef struct HB_GSUBHeader_ HB_GSUBHeader;
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 );
diff --git a/pango/opentype/harfbuzz-impl.h b/pango/opentype/harfbuzz-impl.h
index f31f5cde..9547b062 100644
--- a/pango/opentype/harfbuzz-impl.h
+++ b/pango/opentype/harfbuzz-impl.h
@@ -63,20 +63,24 @@ FT_BEGIN_HEADER
#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
diff --git a/pango/opentype/harfbuzz-open-private.h b/pango/opentype/harfbuzz-open-private.h
index be265af2..03d232de 100644
--- a/pango/opentype/harfbuzz-open-private.h
+++ b/pango/opentype/harfbuzz-open-private.h
@@ -30,22 +30,22 @@ struct HB_SubTable_
};
-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,
@@ -65,14 +65,14 @@ void _HB_OPEN_Free_Device( HB_Device* d,
-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 );
diff --git a/pango/opentype/harfbuzz-open.c b/pango/opentype/harfbuzz-open.c
index fa540401..2aebb5ac 100644
--- a/pango/opentype/harfbuzz-open.c
+++ b/pango/opentype/harfbuzz-open.c
@@ -21,10 +21,10 @@
/* 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;
@@ -57,7 +57,7 @@ static FT_Error Load_LangSys( HB_LangSys* ls,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -70,10 +70,10 @@ static void Free_LangSys( HB_LangSys* ls,
/* 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;
@@ -95,7 +95,7 @@ static FT_Error Load_Script( HB_Script* s,
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 );
}
@@ -144,12 +144,12 @@ static FT_Error Load_Script( HB_Script* s,
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++ )
@@ -188,10 +188,10 @@ static void Free_Script( HB_Script* s,
/* 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;
@@ -233,7 +233,7 @@ FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
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;
@@ -247,12 +247,12 @@ FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
#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++ )
@@ -292,10 +292,10 @@ void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl,
/* 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;
@@ -329,7 +329,7 @@ static FT_Error Load_Feature( HB_Feature* f,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -342,10 +342,10 @@ static void Free_Feature( HB_Feature* f,
/* 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;
@@ -386,12 +386,12 @@ FT_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
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++ )
@@ -440,7 +440,7 @@ void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl,
/* 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 )
@@ -466,11 +466,11 @@ static void Free_SubTable( HB_SubTable* st,
/* 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;
@@ -530,12 +530,12 @@ static FT_Error Load_Lookup( HB_Lookup* l,
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++ )
@@ -570,11 +570,11 @@ static void Free_Lookup( HB_Lookup* l,
/* 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;
@@ -612,12 +612,12 @@ FT_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
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 );
@@ -663,10 +663,10 @@ void _HB_OPEN_Free_LookupList( HB_LookupList* ll,
/* 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;
@@ -699,7 +699,7 @@ static FT_Error Load_Coverage1( HB_CoverageFormat1* cf1,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -712,10 +712,10 @@ static void Free_Coverage1( HB_CoverageFormat1* cf1,
/* 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;
@@ -751,14 +751,14 @@ static FT_Error Load_Coverage2( HB_CoverageFormat2* cf2,
( 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 );
@@ -773,10 +773,10 @@ static void Free_Coverage2( HB_CoverageFormat2* cf2,
}
-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;
@@ -787,17 +787,12 @@ FT_Error _HB_OPEN_Load_Coverage( HB_Coverage* c,
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 */
}
@@ -806,18 +801,14 @@ void _HB_OPEN_Free_Coverage( HB_Coverage* c,
{
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 )
{
@@ -847,7 +838,7 @@ static FT_Error Coverage_Index1( HB_CoverageFormat1* cf1,
if ( glyphID == array[middle] )
{
*index = middle;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
else if ( glyphID < array[middle] )
{
@@ -867,7 +858,7 @@ static FT_Error Coverage_Index1( HB_CoverageFormat1* cf1,
}
-static FT_Error Coverage_Index2( HB_CoverageFormat2* cf2,
+static HB_Error Coverage_Index2( HB_CoverageFormat2* cf2,
FT_UShort glyphID,
FT_UShort* index )
{
@@ -897,7 +888,7 @@ static FT_Error Coverage_Index2( HB_CoverageFormat2* cf2,
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 )
{
@@ -917,23 +908,18 @@ static FT_Error Coverage_Index2( HB_CoverageFormat2* cf2,
}
-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 */
}
@@ -945,11 +931,11 @@ FT_Error _HB_OPEN_Coverage_Index( HB_Coverage* c,
/* 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;
@@ -973,7 +959,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
/* 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;
@@ -991,7 +977,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
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;
@@ -999,7 +985,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
FREE( cva );
@@ -1017,11 +1003,11 @@ static void Free_ClassDef1( HB_ClassDefFormat1* cdf1,
/* 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;
@@ -1037,7 +1023,8 @@ static FT_Error Load_ClassDef2( HB_ClassDefinition* cd,
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();
@@ -1063,15 +1050,22 @@ static FT_Error Load_ClassDef2( HB_ClassDefinition* cd,
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 );
@@ -1089,11 +1083,11 @@ static void Free_ClassDef2( HB_ClassDefFormat2* cdf2,
/* 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;
@@ -1109,17 +1103,9 @@ FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
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 )
@@ -1127,7 +1113,7 @@ FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
cd->loaded = TRUE;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
FREE( cd->Defined );
@@ -1135,10 +1121,10 @@ Fail:
}
-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;
@@ -1151,7 +1137,7 @@ FT_Error _HB_OPEN_Load_EmptyClassDefinition( HB_ClassDefinition* cd,
if ( ALLOC_ARRAY( cd->cd.cd1.ClassValueArray, 1, FT_UShort ) )
goto Fail;
- return FT_Err_Ok;
+ return HB_Err_Ok;
Fail:
FREE( cd->Defined );
@@ -1168,18 +1154,14 @@ void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd,
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 )
@@ -1194,7 +1176,7 @@ static FT_Error Get_Class1( HB_ClassDefFormat1* cdf1,
glyphID < cdf1->StartGlyph + cdf1->GlyphCount )
{
*class = cva[glyphID - cdf1->StartGlyph];
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
else
{
@@ -1207,12 +1189,12 @@ static FT_Error Get_Class1( HB_ClassDefFormat1* cdf1,
/* 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;
@@ -1245,7 +1227,7 @@ static FT_Error Get_Class2( HB_ClassDefFormat2* cdf2,
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 )
@@ -1277,24 +1259,19 @@ static FT_Error Get_Class2( HB_ClassDefFormat2* cdf2,
}
-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 */
}
@@ -1304,10 +1281,10 @@ FT_Error _HB_OPEN_Get_Class( HB_ClassDefinition* cd,
***************************/
-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;
@@ -1324,11 +1301,18 @@ FT_Error _HB_OPEN_Load_Device( HB_Device* d,
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;
@@ -1349,7 +1333,7 @@ FT_Error _HB_OPEN_Load_Device( HB_Device* d,
FORGET_Frame();
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
@@ -1395,7 +1379,7 @@ void _HB_OPEN_Free_Device( HB_Device* d,
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 )
{
@@ -1418,7 +1402,7 @@ FT_Error _HB_OPEN_Get_Device( HB_Device* d,
if ( *value >= ( ( mask + 1 ) >> 1 ) )
*value -= mask + 1;
- return FT_Err_Ok;
+ return HB_Err_Ok;
}
else
{
diff --git a/pango/opentype/harfbuzz-open.h b/pango/opentype/harfbuzz-open.h
index 17e1f29b..5864405c 100644
--- a/pango/opentype/harfbuzz-open.h
+++ b/pango/opentype/harfbuzz-open.h
@@ -25,12 +25,21 @@ FT_BEGIN_HEADER
#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 */
diff --git a/pango/pango-ot-buffer.c b/pango/pango-ot-buffer.c
index f84c4cd3..39a63060 100644
--- a/pango/pango-ot-buffer.c
+++ b/pango/pango-ot-buffer.c
@@ -47,7 +47,7 @@ pango_ot_buffer_new (PangoFcFont *font)
PangoOTBuffer *buffer = g_slice_new (PangoOTBuffer);
FT_Face face = pango_fc_font_lock_face (font);
- if (hb_buffer_new (face->memory, &buffer->buffer) != FT_Err_Ok)
+ if (hb_buffer_new (face->memory, &buffer->buffer) != HB_Err_Ok)
g_warning ("Allocation of HB_Buffer failed"); /* this doesn't happen */
buffer->font = g_object_ref (font);
@@ -339,7 +339,7 @@ pango_ot_buffer_output (const PangoOTBuffer *buffer,
if (buffer->zero_width_marks &&
gdef &&
- HB_GDEF_Get_Glyph_Property (gdef, glyphs->glyphs[i].glyph, &property) == FT_Err_Ok &&
+ HB_GDEF_Get_Glyph_Property (gdef, glyphs->glyphs[i].glyph, &property) == HB_Err_Ok &&
(property == HB_GDEF_MARK || (property & HB_LOOKUP_FLAG_IGNORE_SPECIAL_MARKS) != 0))
{
glyphs->glyphs[i].geometry.width = 0;
diff --git a/pango/pango-ot-info.c b/pango/pango-ot-info.c
index ba5633ff..a9db1916 100644
--- a/pango/pango-ot-info.c
+++ b/pango/pango-ot-info.c
@@ -202,8 +202,8 @@ set_unicode_charmap (FT_Face face)
for (charmap = 0; charmap < face->num_charmaps; charmap++)
if (face->charmaps[charmap]->encoding == ft_encoding_unicode)
{
- FT_Error error = FT_Set_Charmap(face, face->charmaps[charmap]);
- return error == FT_Err_Ok;
+ HB_Error error = FT_Set_Charmap(face, face->charmaps[charmap]);
+ return error == HB_Err_Ok;
}
return FALSE;
@@ -289,7 +289,7 @@ pango_ot_info_get_gdef (PangoOTInfo *info)
if (!(info->loaded & INFO_LOADED_GDEF))
{
- FT_Error error;
+ HB_Error error;
info->loaded |= INFO_LOADED_GDEF;
@@ -297,7 +297,7 @@ pango_ot_info_get_gdef (PangoOTInfo *info)
{
error = HB_Load_GDEF_Table (info->face, &info->gdef);
- if (error && error != FT_Err_Table_Missing)
+ if (error && error != HB_Err_Table_Missing)
g_warning ("Error loading GDEF table %d", error);
if (!info->gdef)
@@ -318,7 +318,7 @@ pango_ot_info_get_gsub (PangoOTInfo *info)
if (!(info->loaded & INFO_LOADED_GSUB))
{
- FT_Error error;
+ HB_Error error;
HB_GDEF gdef = pango_ot_info_get_gdef (info);
info->loaded |= INFO_LOADED_GSUB;
@@ -327,7 +327,7 @@ pango_ot_info_get_gsub (PangoOTInfo *info)
{
error = HB_Load_GSUB_Table (info->face, &info->gsub, gdef);
- if (error && error != FT_Err_Table_Missing)
+ if (error && error != HB_Err_Table_Missing)
g_warning ("Error loading GSUB table %d", error);
}
}
@@ -342,7 +342,7 @@ pango_ot_info_get_gpos (PangoOTInfo *info)
if (!(info->loaded & INFO_LOADED_GPOS))
{
- FT_Error error;
+ HB_Error error;
HB_GDEF gdef = pango_ot_info_get_gdef (info);
info->loaded |= INFO_LOADED_GPOS;
@@ -351,7 +351,7 @@ pango_ot_info_get_gpos (PangoOTInfo *info)
{
error = HB_Load_GPOS_Table (info->face, &info->gpos, gdef);
- if (error && error != FT_Err_Table_Missing)
+ if (error && error != HB_Err_Table_Missing)
g_warning ("Error loading GPOS table %d", error);
}
}
diff --git a/pango/pango-ot-ruleset.c b/pango/pango-ot-ruleset.c
index a40019fa..f484c4e0 100644
--- a/pango/pango-ot-ruleset.c
+++ b/pango/pango-ot-ruleset.c
@@ -564,7 +564,7 @@ pango_ot_ruleset_position (const PangoOTRuleset *ruleset,
if (HB_GPOS_Apply_String (ruleset->info->face, gpos, 0, buffer->buffer,
FALSE /* enable device-dependant values */,
- buffer->rtl) == FT_Err_Ok)
+ buffer->rtl) == HB_Err_Ok)
buffer->applied_gpos = TRUE;
}