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.
This commit is contained in:
parent
dd810b76bc
commit
a8abb8b994
51
src/ftglue.c
51
src/ftglue.c
|
@ -32,16 +32,16 @@ _hb_ftglue_log( const char* format, ... )
|
||||||
static FT_Pointer
|
static FT_Pointer
|
||||||
_hb_ftglue_qalloc( FT_Memory memory,
|
_hb_ftglue_qalloc( FT_Memory memory,
|
||||||
FT_ULong size,
|
FT_ULong size,
|
||||||
FT_Error *perror )
|
HB_Error *perror )
|
||||||
{
|
{
|
||||||
FT_Error error = 0;
|
HB_Error error = 0;
|
||||||
FT_Pointer block = NULL;
|
FT_Pointer block = NULL;
|
||||||
|
|
||||||
if ( size > 0 )
|
if ( size > 0 )
|
||||||
{
|
{
|
||||||
block = memory->alloc( memory, size );
|
block = memory->alloc( memory, size );
|
||||||
if ( !block )
|
if ( !block )
|
||||||
error = FT_Err_Out_Of_Memory;
|
error = HB_Err_Out_Of_Memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
*perror = error;
|
*perror = error;
|
||||||
|
@ -55,16 +55,16 @@ _hb_ftglue_qalloc( FT_Memory memory,
|
||||||
FTGLUE_APIDEF( FT_Pointer )
|
FTGLUE_APIDEF( FT_Pointer )
|
||||||
_hb_ftglue_alloc( FT_Memory memory,
|
_hb_ftglue_alloc( FT_Memory memory,
|
||||||
FT_ULong size,
|
FT_ULong size,
|
||||||
FT_Error *perror )
|
HB_Error *perror )
|
||||||
{
|
{
|
||||||
FT_Error error = 0;
|
HB_Error error = 0;
|
||||||
FT_Pointer block = NULL;
|
FT_Pointer block = NULL;
|
||||||
|
|
||||||
if ( size > 0 )
|
if ( size > 0 )
|
||||||
{
|
{
|
||||||
block = memory->alloc( memory, size );
|
block = memory->alloc( memory, size );
|
||||||
if ( !block )
|
if ( !block )
|
||||||
error = FT_Err_Out_Of_Memory;
|
error = HB_Err_Out_Of_Memory;
|
||||||
else
|
else
|
||||||
memset( (char*)block, 0, (size_t)size );
|
memset( (char*)block, 0, (size_t)size );
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,10 @@ _hb_ftglue_realloc( FT_Memory memory,
|
||||||
FT_Pointer block,
|
FT_Pointer block,
|
||||||
FT_ULong old_size,
|
FT_ULong old_size,
|
||||||
FT_ULong new_size,
|
FT_ULong new_size,
|
||||||
FT_Error *perror )
|
HB_Error *perror )
|
||||||
{
|
{
|
||||||
FT_Pointer block2 = NULL;
|
FT_Pointer block2 = NULL;
|
||||||
FT_Error error = 0;
|
HB_Error error = 0;
|
||||||
|
|
||||||
if ( old_size == 0 || block == NULL )
|
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 );
|
block2 = memory->realloc( memory, old_size, new_size, block );
|
||||||
if ( block2 == NULL )
|
if ( block2 == NULL )
|
||||||
error = FT_Err_Out_Of_Memory;
|
error = HB_Err_Out_Of_Memory;
|
||||||
else if ( new_size > old_size )
|
else if ( new_size > old_size )
|
||||||
memset( (char*)block2 + old_size, 0, (size_t)(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,
|
_hb_ftglue_stream_seek( FT_Stream stream,
|
||||||
FT_Long pos )
|
FT_Long pos )
|
||||||
{
|
{
|
||||||
FT_Error error = 0;
|
HB_Error error = 0;
|
||||||
|
|
||||||
stream->pos = pos;
|
stream->pos = pos;
|
||||||
if ( stream->read )
|
if ( stream->read )
|
||||||
{
|
{
|
||||||
if ( stream->read( stream, pos, NULL, 0 ) )
|
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 )
|
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 ));
|
LOG(( "ftglue:stream:seek(%ld) -> %d\n", pos, error ));
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FTGLUE_APIDEF( FT_Error )
|
FTGLUE_APIDEF( HB_Error )
|
||||||
_hb_ftglue_stream_frame_enter( FT_Stream stream,
|
_hb_ftglue_stream_frame_enter( FT_Stream stream,
|
||||||
FT_ULong count )
|
FT_ULong count )
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
HB_Error error = HB_Err_Ok;
|
||||||
FT_ULong read_bytes;
|
FT_ULong read_bytes;
|
||||||
|
|
||||||
if ( stream->read )
|
if ( stream->read )
|
||||||
|
@ -168,7 +168,7 @@ _hb_ftglue_stream_frame_enter( FT_Stream stream,
|
||||||
if ( read_bytes < count )
|
if ( read_bytes < count )
|
||||||
{
|
{
|
||||||
FREE( stream->base );
|
FREE( stream->base );
|
||||||
error = FT_Err_Invalid_Stream_Operation;
|
error = HB_Err_Invalid_Stream_Operation;
|
||||||
}
|
}
|
||||||
stream->cursor = stream->base;
|
stream->cursor = stream->base;
|
||||||
stream->limit = stream->cursor + count;
|
stream->limit = stream->cursor + count;
|
||||||
|
@ -180,7 +180,7 @@ _hb_ftglue_stream_frame_enter( FT_Stream stream,
|
||||||
if ( stream->pos >= stream->size ||
|
if ( stream->pos >= stream->size ||
|
||||||
stream->pos + count > stream->size )
|
stream->pos + count > stream->size )
|
||||||
{
|
{
|
||||||
error = FT_Err_Invalid_Stream_Operation;
|
error = HB_Err_Invalid_Stream_Operation;
|
||||||
goto Exit;
|
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,
|
_hb_ftglue_face_goto_table( FT_Face face,
|
||||||
FT_ULong the_tag,
|
FT_ULong the_tag,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
LOG(( "_hb_ftglue_face_goto_table( %p, %c%c%c%c, %p )\n",
|
LOG(( "_hb_ftglue_face_goto_table( %p, %c%c%c%c, %p )\n",
|
||||||
face,
|
face,
|
||||||
|
@ -230,7 +230,7 @@ _hb_ftglue_face_goto_table( FT_Face face,
|
||||||
if ( !FT_IS_SFNT(face) )
|
if ( !FT_IS_SFNT(face) )
|
||||||
{
|
{
|
||||||
LOG(( "not a SFNT face !!\n" ));
|
LOG(( "not a SFNT face !!\n" ));
|
||||||
error = FT_Err_Invalid_Face_Handle;
|
error = HB_Err_Invalid_Face_Handle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -285,7 +285,7 @@ _hb_ftglue_face_goto_table( FT_Face face,
|
||||||
goto FoundIt;
|
goto FoundIt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error = FT_Err_Table_Missing;
|
error = HB_Err_Table_Missing;
|
||||||
|
|
||||||
FoundIt:
|
FoundIt:
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
|
@ -298,3 +298,12 @@ Exit:
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef QALLOC
|
#undef QALLOC
|
||||||
|
|
||||||
|
/* abuse these private header/source files */
|
||||||
|
|
||||||
|
/* helper func to set a breakpoint on */
|
||||||
|
HB_Error
|
||||||
|
_hb_err (HB_Error code)
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
21
src/ftglue.h
21
src/ftglue.h
|
@ -46,11 +46,17 @@
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
#include "harfbuzz-open.h"
|
||||||
|
|
||||||
FT_BEGIN_HEADER
|
FT_BEGIN_HEADER
|
||||||
|
|
||||||
|
|
||||||
/* utility macros */
|
/* utility macros */
|
||||||
|
|
||||||
|
#ifndef HB_Error
|
||||||
|
#define HB_Error FT_Error
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SET_ERR(c) ( (error = (c)) != 0 )
|
#define SET_ERR(c) ( (error = (c)) != 0 )
|
||||||
|
|
||||||
#ifndef FTGLUE_API
|
#ifndef FTGLUE_API
|
||||||
|
@ -88,18 +94,18 @@ FT_BEGIN_HEADER
|
||||||
FTGLUE_API( FT_Long )
|
FTGLUE_API( FT_Long )
|
||||||
_hb_ftglue_stream_pos( FT_Stream stream );
|
_hb_ftglue_stream_pos( FT_Stream stream );
|
||||||
|
|
||||||
FTGLUE_API( FT_Error )
|
FTGLUE_API( HB_Error )
|
||||||
_hb_ftglue_stream_seek( FT_Stream stream,
|
_hb_ftglue_stream_seek( FT_Stream stream,
|
||||||
FT_Long pos );
|
FT_Long pos );
|
||||||
|
|
||||||
FTGLUE_API( FT_Error )
|
FTGLUE_API( HB_Error )
|
||||||
_hb_ftglue_stream_frame_enter( FT_Stream stream,
|
_hb_ftglue_stream_frame_enter( FT_Stream stream,
|
||||||
FT_ULong size );
|
FT_ULong size );
|
||||||
|
|
||||||
FTGLUE_API( void )
|
FTGLUE_API( void )
|
||||||
_hb_ftglue_stream_frame_exit( FT_Stream stream );
|
_hb_ftglue_stream_frame_exit( FT_Stream stream );
|
||||||
|
|
||||||
FTGLUE_API( FT_Error )
|
FTGLUE_API( HB_Error )
|
||||||
_hb_ftglue_face_goto_table( FT_Face face,
|
_hb_ftglue_face_goto_table( FT_Face face,
|
||||||
FT_ULong tag,
|
FT_ULong tag,
|
||||||
FT_Stream stream );
|
FT_Stream stream );
|
||||||
|
@ -132,19 +138,24 @@ _hb_ftglue_face_goto_table( FT_Face face,
|
||||||
FTGLUE_API( FT_Pointer )
|
FTGLUE_API( FT_Pointer )
|
||||||
_hb_ftglue_alloc( FT_Memory memory,
|
_hb_ftglue_alloc( FT_Memory memory,
|
||||||
FT_ULong size,
|
FT_ULong size,
|
||||||
FT_Error *perror_ );
|
HB_Error *perror_ );
|
||||||
|
|
||||||
FTGLUE_API( FT_Pointer )
|
FTGLUE_API( FT_Pointer )
|
||||||
_hb_ftglue_realloc( FT_Memory memory,
|
_hb_ftglue_realloc( FT_Memory memory,
|
||||||
FT_Pointer block,
|
FT_Pointer block,
|
||||||
FT_ULong old_size,
|
FT_ULong old_size,
|
||||||
FT_ULong new_size,
|
FT_ULong new_size,
|
||||||
FT_Error *perror_ );
|
HB_Error *perror_ );
|
||||||
|
|
||||||
FTGLUE_API( void )
|
FTGLUE_API( void )
|
||||||
_hb_ftglue_free( FT_Memory memory,
|
_hb_ftglue_free( FT_Memory memory,
|
||||||
FT_Pointer block );
|
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
|
FT_END_HEADER
|
||||||
|
|
||||||
#endif /* FTGLUE_H */
|
#endif /* FTGLUE_H */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* harfbuzz-buffer.c: Buffer of glyphs for substitution/positioning
|
/* 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
|
* Portions Copyright 1996-2000 by
|
||||||
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
||||||
|
@ -11,7 +11,34 @@
|
||||||
#include "harfbuzz-gsub-private.h"
|
#include "harfbuzz-gsub-private.h"
|
||||||
#include "harfbuzz-gpos-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,
|
hb_buffer_ensure( HB_Buffer buffer,
|
||||||
FT_ULong size )
|
FT_ULong size )
|
||||||
{
|
{
|
||||||
|
@ -20,29 +47,63 @@ hb_buffer_ensure( HB_Buffer buffer,
|
||||||
|
|
||||||
if (size > new_allocated)
|
if (size > new_allocated)
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
while (size > new_allocated)
|
while (size > new_allocated)
|
||||||
new_allocated += (new_allocated >> 1) + 8;
|
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 ) )
|
if ( REALLOC_ARRAY( buffer->positions, buffer->allocated, new_allocated, HB_PositionRec ) )
|
||||||
return error;
|
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;
|
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_new( FT_Memory memory,
|
||||||
HB_Buffer *buffer )
|
HB_Buffer *buffer )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
if ( ALLOC( *buffer, sizeof( HB_BufferRec ) ) )
|
if ( ALLOC( *buffer, sizeof( HB_BufferRec ) ) )
|
||||||
return error;
|
return error;
|
||||||
|
@ -56,61 +117,77 @@ hb_buffer_new( FT_Memory memory,
|
||||||
|
|
||||||
(*buffer)->in_string = NULL;
|
(*buffer)->in_string = NULL;
|
||||||
(*buffer)->out_string = NULL;
|
(*buffer)->out_string = NULL;
|
||||||
|
(*buffer)->alt_string = NULL;
|
||||||
(*buffer)->positions = NULL;
|
(*buffer)->positions = NULL;
|
||||||
(*buffer)->max_ligID = 0;
|
(*buffer)->max_ligID = 0;
|
||||||
|
(*buffer)->inplace = TRUE;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Error
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
hb_buffer_swap( HB_Buffer buffer )
|
hb_buffer_swap( HB_Buffer buffer )
|
||||||
{
|
{
|
||||||
HB_GlyphItem tmp_string;
|
HB_GlyphItem tmp_string;
|
||||||
|
int tmp_length;
|
||||||
|
int tmp_pos;
|
||||||
|
|
||||||
tmp_string = buffer->in_string;
|
if ( ! buffer->inplace )
|
||||||
buffer->in_string = buffer->out_string;
|
{
|
||||||
buffer->out_string = tmp_string;
|
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->in_length = buffer->out_length;
|
||||||
buffer->out_length = 0;
|
buffer->out_length = tmp_length;
|
||||||
|
|
||||||
buffer->in_pos = 0;
|
tmp_pos = buffer->in_pos;
|
||||||
buffer->out_pos = 0;
|
buffer->in_pos = buffer->out_pos;
|
||||||
|
buffer->out_pos = tmp_pos;
|
||||||
return FT_Err_Ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Error
|
void
|
||||||
hb_buffer_free( HB_Buffer buffer )
|
hb_buffer_free( HB_Buffer buffer )
|
||||||
{
|
{
|
||||||
FT_Memory memory = buffer->memory;
|
FT_Memory memory = buffer->memory;
|
||||||
|
|
||||||
FREE( buffer->in_string );
|
FREE( buffer->in_string );
|
||||||
FREE( buffer->out_string );
|
FREE( buffer->alt_string );
|
||||||
|
buffer->out_string = NULL;
|
||||||
FREE( buffer->positions );
|
FREE( buffer->positions );
|
||||||
FREE( buffer );
|
FREE( buffer );
|
||||||
|
|
||||||
return FT_Err_Ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Error
|
void
|
||||||
hb_buffer_clear( HB_Buffer buffer )
|
hb_buffer_clear( HB_Buffer buffer )
|
||||||
{
|
{
|
||||||
buffer->in_length = 0;
|
buffer->in_length = 0;
|
||||||
buffer->out_length = 0;
|
buffer->out_length = 0;
|
||||||
buffer->in_pos = 0;
|
buffer->in_pos = 0;
|
||||||
buffer->out_pos = 0;
|
buffer->out_pos = 0;
|
||||||
|
buffer->out_string = buffer->in_string;
|
||||||
return FT_Err_Ok;
|
buffer->inplace = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Error
|
HB_Error
|
||||||
hb_buffer_add_glyph( HB_Buffer buffer,
|
hb_buffer_add_glyph( HB_Buffer buffer,
|
||||||
FT_UInt glyph_index,
|
FT_UInt glyph_index,
|
||||||
FT_UInt properties,
|
FT_UInt properties,
|
||||||
FT_UInt cluster )
|
FT_UInt cluster )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
HB_GlyphItem glyph;
|
HB_GlyphItem glyph;
|
||||||
|
|
||||||
error = hb_buffer_ensure( buffer, buffer->in_length + 1 );
|
error = hb_buffer_ensure( buffer, buffer->in_length + 1 );
|
||||||
|
@ -127,7 +204,7 @@ hb_buffer_add_glyph( HB_Buffer buffer,
|
||||||
|
|
||||||
buffer->in_length++;
|
buffer->in_length++;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following function copies `num_out' elements from `glyph_data'
|
/* 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
|
The cluster value for the glyph at position buffer->in_pos is used
|
||||||
for all replacement glyphs */
|
for all replacement glyphs */
|
||||||
FT_Error
|
HB_Error
|
||||||
hb_buffer_add_output_glyphs( HB_Buffer buffer,
|
hb_buffer_add_output_glyphs( HB_Buffer buffer,
|
||||||
FT_UShort num_in,
|
FT_UShort num_in,
|
||||||
FT_UShort num_out,
|
FT_UShort num_out,
|
||||||
|
@ -157,7 +234,7 @@ hb_buffer_add_output_glyphs( HB_Buffer buffer,
|
||||||
FT_UShort component,
|
FT_UShort component,
|
||||||
FT_UShort ligID )
|
FT_UShort ligID )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_UShort i;
|
FT_UShort i;
|
||||||
FT_UInt properties;
|
FT_UInt properties;
|
||||||
FT_UInt cluster;
|
FT_UInt cluster;
|
||||||
|
@ -166,6 +243,13 @@ hb_buffer_add_output_glyphs( HB_Buffer buffer,
|
||||||
if ( error )
|
if ( error )
|
||||||
return 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;
|
properties = buffer->in_string[buffer->in_pos].properties;
|
||||||
cluster = buffer->in_string[buffer->in_pos].cluster;
|
cluster = buffer->in_string[buffer->in_pos].cluster;
|
||||||
if ( component == 0xFFFF )
|
if ( component == 0xFFFF )
|
||||||
|
@ -190,10 +274,10 @@ hb_buffer_add_output_glyphs( HB_Buffer buffer,
|
||||||
|
|
||||||
buffer->out_length = buffer->out_pos;
|
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,
|
hb_buffer_add_output_glyph( HB_Buffer buffer,
|
||||||
FT_UInt glyph_index,
|
FT_UInt glyph_index,
|
||||||
FT_UShort component,
|
FT_UShort component,
|
||||||
|
@ -205,19 +289,49 @@ hb_buffer_add_output_glyph( HB_Buffer buffer,
|
||||||
&glyph_data, component, ligID );
|
&glyph_data, component, ligID );
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_Error
|
HB_Error
|
||||||
hb_buffer_copy_output_glyph ( HB_Buffer buffer )
|
hb_buffer_copy_output_glyph ( HB_Buffer buffer )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );
|
error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );
|
||||||
if ( error )
|
if ( error )
|
||||||
return 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;
|
buffer->out_length = buffer->out_pos;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
HB_Error
|
||||||
|
hb_buffer_replace_output_glyph( HB_Buffer buffer,
|
||||||
|
FT_UInt glyph_index,
|
||||||
|
FT_Bool inplace )
|
||||||
|
{
|
||||||
|
|
||||||
|
HB_Error error;
|
||||||
|
|
||||||
|
if ( inplace )
|
||||||
|
{
|
||||||
|
error = hb_buffer_copy_output_glyph ( buffer );
|
||||||
|
if ( error )
|
||||||
|
return error;
|
||||||
|
|
||||||
|
buffer->out_string[buffer->out_pos-1].gindex = glyph_index;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return hb_buffer_add_output_glyph( buffer, glyph_index, 0xFFFF, 0xFFFF );
|
||||||
|
}
|
||||||
|
|
||||||
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_UShort
|
FT_UShort
|
||||||
|
|
|
@ -56,32 +56,37 @@ typedef struct HB_BufferRec_{
|
||||||
FT_ULong in_pos;
|
FT_ULong in_pos;
|
||||||
FT_ULong out_pos;
|
FT_ULong out_pos;
|
||||||
|
|
||||||
|
FT_Bool inplace;
|
||||||
HB_GlyphItem in_string;
|
HB_GlyphItem in_string;
|
||||||
HB_GlyphItem out_string;
|
HB_GlyphItem out_string;
|
||||||
|
HB_GlyphItem alt_string;
|
||||||
HB_Position positions;
|
HB_Position positions;
|
||||||
FT_UShort max_ligID;
|
FT_UShort max_ligID;
|
||||||
} HB_BufferRec, *HB_Buffer;
|
} HB_BufferRec, *HB_Buffer;
|
||||||
|
|
||||||
FT_Error
|
HB_Error
|
||||||
hb_buffer_new( FT_Memory memory,
|
hb_buffer_new( FT_Memory memory,
|
||||||
HB_Buffer *buffer );
|
HB_Buffer *buffer );
|
||||||
|
|
||||||
FT_Error
|
void
|
||||||
hb_buffer_swap( HB_Buffer buffer );
|
hb_buffer_swap( HB_Buffer buffer );
|
||||||
|
|
||||||
FT_Error
|
void
|
||||||
hb_buffer_free( HB_Buffer buffer );
|
hb_buffer_free( HB_Buffer buffer );
|
||||||
|
|
||||||
FT_Error
|
void
|
||||||
hb_buffer_clear( HB_Buffer buffer );
|
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,
|
hb_buffer_add_glyph( HB_Buffer buffer,
|
||||||
FT_UInt glyph_index,
|
FT_UInt glyph_index,
|
||||||
FT_UInt properties,
|
FT_UInt properties,
|
||||||
FT_UInt cluster );
|
FT_UInt cluster );
|
||||||
|
|
||||||
FT_Error
|
HB_Error
|
||||||
hb_buffer_add_output_glyphs( HB_Buffer buffer,
|
hb_buffer_add_output_glyphs( HB_Buffer buffer,
|
||||||
FT_UShort num_in,
|
FT_UShort num_in,
|
||||||
FT_UShort num_out,
|
FT_UShort num_out,
|
||||||
|
@ -89,15 +94,20 @@ hb_buffer_add_output_glyphs( HB_Buffer buffer,
|
||||||
FT_UShort component,
|
FT_UShort component,
|
||||||
FT_UShort ligID );
|
FT_UShort ligID );
|
||||||
|
|
||||||
FT_Error
|
HB_Error
|
||||||
hb_buffer_add_output_glyph ( HB_Buffer buffer,
|
hb_buffer_add_output_glyph ( HB_Buffer buffer,
|
||||||
FT_UInt glyph_index,
|
FT_UInt glyph_index,
|
||||||
FT_UShort component,
|
FT_UShort component,
|
||||||
FT_UShort ligID );
|
FT_UShort ligID );
|
||||||
|
|
||||||
FT_Error
|
HB_Error
|
||||||
hb_buffer_copy_output_glyph ( HB_Buffer buffer );
|
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
|
FT_UShort
|
||||||
hb_buffer_allocate_ligid( HB_Buffer buffer );
|
hb_buffer_allocate_ligid( HB_Buffer buffer );
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#define N_ELEMENTS(arr) (sizeof(arr)/ sizeof((arr)[0]))
|
#define N_ELEMENTS(arr) (sizeof(arr)/ sizeof((arr)[0]))
|
||||||
|
|
||||||
static int
|
static int
|
||||||
croak (const char *situation, FT_Error error)
|
croak (const char *situation, HB_Error error)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: Error %d\n", situation, error);
|
fprintf (stderr, "%s: Error %d\n", situation, error);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ maybe_add_feature (HB_GSUB gsub,
|
||||||
FT_ULong tag,
|
FT_ULong tag,
|
||||||
FT_UShort property)
|
FT_UShort property)
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_UShort feature_index;
|
FT_UShort feature_index;
|
||||||
|
|
||||||
/* 0xffff == default language system */
|
/* 0xffff == default language system */
|
||||||
|
@ -122,7 +122,7 @@ select_cmap (FT_Face face)
|
||||||
static void
|
static void
|
||||||
add_features (HB_GSUB gsub)
|
add_features (HB_GSUB gsub)
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_ULong tag = FT_MAKE_TAG ('a', 'r', 'a', 'b');
|
FT_ULong tag = FT_MAKE_TAG ('a', 'r', 'a', 'b');
|
||||||
FT_UShort script_index;
|
FT_UShort script_index;
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ try_string (FT_Library library,
|
||||||
FT_Face face,
|
FT_Face face,
|
||||||
HB_GSUB gsub)
|
HB_GSUB gsub)
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
HB_GSUB_String *in_str;
|
HB_GSUB_String *in_str;
|
||||||
HB_GSUB_String *out_str;
|
HB_GSUB_String *out_str;
|
||||||
FT_ULong i;
|
FT_ULong i;
|
||||||
|
@ -210,7 +210,7 @@ try_string (FT_Library library,
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Library library;
|
FT_Library library;
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
HB_GSUB gsub;
|
HB_GSUB gsub;
|
||||||
|
@ -238,7 +238,7 @@ main (int argc, char **argv)
|
||||||
if ((error = HB_Done_GSUB_Table (gsub)))
|
if ((error = HB_Done_GSUB_Table (gsub)))
|
||||||
croak ("HB_Done_GSUB_Table", error);
|
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);
|
fprintf (stderr, "HB_Load_GSUB_Table %x\n", error);
|
||||||
|
|
||||||
if (!(error = HB_Load_GPOS_Table (face, &gpos, NULL)))
|
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)))
|
if ((error = HB_Done_GPOS_Table (gpos)))
|
||||||
croak ("HB_Done_GPOS_Table", error);
|
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);
|
fprintf (stderr, "HB_Load_GPOS_Table %x\n", error);
|
||||||
|
|
||||||
printf ("</OpenType>\n");
|
printf ("</OpenType>\n");
|
||||||
|
|
|
@ -452,7 +452,7 @@ static void
|
||||||
Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
|
Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int bits = 0;
|
int bits;
|
||||||
int n_per;
|
int n_per;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
|
||||||
|
@ -472,6 +472,9 @@ Dump_Device (HB_Device *Device, FILE *stream, int indent, HB_Type hb_type)
|
||||||
case 3:
|
case 3:
|
||||||
bits = 8;
|
bits = 8;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
bits = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DUMP ("<DeltaValue>");
|
DUMP ("<DeltaValue>");
|
||||||
|
@ -634,7 +637,7 @@ Dump_GPOS_Lookup_Markbase (HB_SubTable *subtable, FILE *stream, int indent, HB_T
|
||||||
DEF_DUMP (Lookup)
|
DEF_DUMP (Lookup)
|
||||||
{
|
{
|
||||||
int i;
|
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;
|
void (*lookup_func) (HB_SubTable *subtable, FILE *stream, int indent, HB_Type hb_type) = NULL;
|
||||||
|
|
||||||
if (hb_type == HB_Type_GSUB)
|
if (hb_type == HB_Type_GSUB)
|
||||||
|
@ -663,6 +666,10 @@ DEF_DUMP (Lookup)
|
||||||
lookup_name = "CHAIN";
|
lookup_name = "CHAIN";
|
||||||
lookup_func = Dump_GSUB_Lookup_Chain;
|
lookup_func = Dump_GSUB_Lookup_Chain;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
lookup_name = "(unknown)";
|
||||||
|
lookup_func = NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -696,6 +703,10 @@ DEF_DUMP (Lookup)
|
||||||
case HB_GPOS_LOOKUP_CHAIN:
|
case HB_GPOS_LOOKUP_CHAIN:
|
||||||
lookup_name = "CHAIN";
|
lookup_name = "CHAIN";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
lookup_name = "(unknown)";
|
||||||
|
lookup_func = NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 glyphID,
|
||||||
FT_UShort property );
|
FT_UShort property );
|
||||||
|
|
||||||
FT_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
|
HB_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
|
||||||
HB_GlyphItem item,
|
HB_GlyphItem item,
|
||||||
FT_UShort flags,
|
FT_UShort flags,
|
||||||
FT_UShort* property );
|
FT_UShort* property );
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
#include "harfbuzz-gdef-private.h"
|
#include "harfbuzz-gdef-private.h"
|
||||||
#include "harfbuzz-open-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 );
|
FT_Stream stream );
|
||||||
static FT_Error Load_LigCaretList( HB_LigCaretList* lcl,
|
static HB_Error Load_LigCaretList( HB_LigCaretList* lcl,
|
||||||
FT_Stream stream );
|
FT_Stream stream );
|
||||||
|
|
||||||
static void Free_AttachList( HB_AttachList* al,
|
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' )
|
#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 )
|
PFace face )
|
||||||
{
|
{
|
||||||
DEFINE_LOAD_LOCALS( face->stream );
|
DEFINE_LOAD_LOCALS( face->stream );
|
||||||
|
@ -49,7 +49,7 @@ static FT_Error GDEF_Create( void* ext,
|
||||||
/* by convention */
|
/* by convention */
|
||||||
|
|
||||||
if ( !gdef )
|
if ( !gdef )
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
/* a null offset indicates that there is no GDEF table */
|
/* 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 );
|
table = HB_LookUp_Table( face, TTAG_GDEF );
|
||||||
if ( table < 0 )
|
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 ) ||
|
if ( FILE_Seek( face->dirTables[table].Offset ) ||
|
||||||
ACCESS_Frame( 4L ) )
|
ACCESS_Frame( 4L ) )
|
||||||
|
@ -72,11 +72,11 @@ static FT_Error GDEF_Create( void* ext,
|
||||||
|
|
||||||
gdef->loaded = FALSE;
|
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 )
|
PFace face )
|
||||||
{
|
{
|
||||||
HB_GDEFHeader* gdef = (HB_GDEFHeader*)ext;
|
HB_GDEFHeader* gdef = (HB_GDEFHeader*)ext;
|
||||||
|
@ -85,7 +85,7 @@ static FT_Error GDEF_Destroy( void* ext,
|
||||||
/* by convention */
|
/* by convention */
|
||||||
|
|
||||||
if ( !gdef )
|
if ( !gdef )
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
if ( gdef->loaded )
|
if ( gdef->loaded )
|
||||||
{
|
{
|
||||||
|
@ -97,18 +97,18 @@ static FT_Error GDEF_Destroy( void* ext,
|
||||||
Free_NewGlyphClasses( gdef, memory );
|
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 );
|
PEngine_Instance _engine = HANDLE_Engine( engine );
|
||||||
|
|
||||||
|
|
||||||
if ( !_engine )
|
if ( !_engine )
|
||||||
return FT_Err_Invalid_Engine;
|
return HB_Err_Invalid_Engine;
|
||||||
|
|
||||||
return HB_Register_Extension( _engine,
|
return HB_Register_Extension( _engine,
|
||||||
GDEF_ID,
|
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 )
|
HB_GDEFHeader** retptr )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = face->memory;
|
FT_Memory memory = face->memory;
|
||||||
|
|
||||||
HB_GDEFHeader* gdef;
|
HB_GDEFHeader* gdef;
|
||||||
|
|
||||||
if ( !retptr )
|
if ( !retptr )
|
||||||
return FT_Err_Invalid_Argument;
|
return HB_Err_Invalid_Argument;
|
||||||
|
|
||||||
if ( ALLOC( gdef, sizeof( *gdef ) ) )
|
if ( ALLOC( gdef, sizeof( *gdef ) ) )
|
||||||
return error;
|
return error;
|
||||||
|
@ -157,14 +157,14 @@ FT_Error HB_New_GDEF_Table( FT_Face face,
|
||||||
|
|
||||||
*retptr = gdef;
|
*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 )
|
HB_GDEFHeader** retptr )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = face->memory;
|
FT_Memory memory = face->memory;
|
||||||
FT_Stream stream = face->stream;
|
FT_Stream stream = face->stream;
|
||||||
FT_ULong cur_offset, new_offset, base_offset;
|
FT_ULong cur_offset, new_offset, base_offset;
|
||||||
|
@ -173,7 +173,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
|
||||||
|
|
||||||
|
|
||||||
if ( !retptr )
|
if ( !retptr )
|
||||||
return FT_Err_Invalid_Argument;
|
return HB_Err_Invalid_Argument;
|
||||||
|
|
||||||
if (( error = _hb_ftglue_face_goto_table( face, TTAG_GDEF, stream ) ))
|
if (( error = _hb_ftglue_face_goto_table( face, TTAG_GDEF, stream ) ))
|
||||||
return error;
|
return error;
|
||||||
|
@ -204,7 +204,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
if ( FILE_Seek( new_offset ) ||
|
||||||
( error = _HB_OPEN_Load_ClassDefinition( &gdef->GlyphClassDef, 5,
|
( error = _HB_OPEN_Load_ClassDefinition( &gdef->GlyphClassDef, 5,
|
||||||
stream ) ) != FT_Err_Ok )
|
stream ) ) != HB_Err_Ok )
|
||||||
goto Fail0;
|
goto Fail0;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
if ( FILE_Seek( new_offset ) ||
|
||||||
( error = Load_AttachList( &gdef->AttachList,
|
( error = Load_AttachList( &gdef->AttachList,
|
||||||
stream ) ) != FT_Err_Ok )
|
stream ) ) != HB_Err_Ok )
|
||||||
goto Fail1;
|
goto Fail1;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
if ( FILE_Seek( new_offset ) ||
|
||||||
( error = Load_LigCaretList( &gdef->LigCaretList,
|
( error = Load_LigCaretList( &gdef->LigCaretList,
|
||||||
stream ) ) != FT_Err_Ok )
|
stream ) ) != HB_Err_Ok )
|
||||||
goto Fail2;
|
goto Fail2;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ FT_Error HB_Load_GDEF_Table( FT_Face face,
|
||||||
|
|
||||||
*retptr = gdef;
|
*retptr = gdef;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail3:
|
Fail3:
|
||||||
Free_LigCaretList( &gdef->LigCaretList, memory );
|
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;
|
FT_Memory memory = gdef->memory;
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ FT_Error HB_Done_GDEF_Table ( HB_GDEFHeader* gdef )
|
||||||
|
|
||||||
FREE( 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 */
|
/* AttachPoint */
|
||||||
|
|
||||||
static FT_Error Load_AttachPoint( HB_AttachPoint* ap,
|
static HB_Error Load_AttachPoint( HB_AttachPoint* ap,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
FT_UShort n, count;
|
FT_UShort n, count;
|
||||||
FT_UShort* pi;
|
FT_UShort* pi;
|
||||||
|
@ -347,7 +347,7 @@ static FT_Error Load_AttachPoint( HB_AttachPoint* ap,
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -360,11 +360,11 @@ static void Free_AttachPoint( HB_AttachPoint* ap,
|
||||||
|
|
||||||
/* AttachList */
|
/* AttachList */
|
||||||
|
|
||||||
static FT_Error Load_AttachList( HB_AttachList* al,
|
static HB_Error Load_AttachList( HB_AttachList* al,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
FT_UShort n, m, count;
|
FT_UShort n, m, count;
|
||||||
FT_ULong cur_offset, new_offset, base_offset;
|
FT_ULong cur_offset, new_offset, base_offset;
|
||||||
|
@ -383,7 +383,7 @@ static FT_Error Load_AttachList( HB_AttachList* al,
|
||||||
|
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
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;
|
return error;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
|
|
||||||
|
@ -412,14 +412,14 @@ static FT_Error Load_AttachList( HB_AttachList* al,
|
||||||
|
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
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;
|
goto Fail1;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
al->loaded = TRUE;
|
al->loaded = TRUE;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail1:
|
Fail1:
|
||||||
for ( m = 0; m < n; m++ )
|
for ( m = 0; m < n; m++ )
|
||||||
|
@ -470,10 +470,10 @@ static void Free_AttachList( HB_AttachList* al,
|
||||||
/* CaretValueFormat3 */
|
/* CaretValueFormat3 */
|
||||||
/* CaretValueFormat4 */
|
/* CaretValueFormat4 */
|
||||||
|
|
||||||
static FT_Error Load_CaretValue( HB_CaretValue* cv,
|
static HB_Error Load_CaretValue( HB_CaretValue* cv,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
FT_ULong cur_offset, new_offset, base_offset;
|
FT_ULong cur_offset, new_offset, base_offset;
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ static FT_Error Load_CaretValue( HB_CaretValue* cv,
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
if ( FILE_Seek( new_offset ) ||
|
||||||
( error = _HB_OPEN_Load_Device( &cv->cvf.cvf3.Device,
|
( error = _HB_OPEN_Load_Device( &cv->cvf.cvf3.Device,
|
||||||
stream ) ) != FT_Err_Ok )
|
stream ) ) != HB_Err_Ok )
|
||||||
return error;
|
return error;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
|
|
||||||
|
@ -538,10 +538,10 @@ static FT_Error Load_CaretValue( HB_CaretValue* cv,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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 */
|
/* LigGlyph */
|
||||||
|
|
||||||
static FT_Error Load_LigGlyph( HB_LigGlyph* lg,
|
static HB_Error Load_LigGlyph( HB_LigGlyph* lg,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
FT_UShort n, m, count;
|
FT_UShort n, m, count;
|
||||||
FT_ULong cur_offset, new_offset, base_offset;
|
FT_ULong cur_offset, new_offset, base_offset;
|
||||||
|
@ -594,12 +594,12 @@ static FT_Error Load_LigGlyph( HB_LigGlyph* lg,
|
||||||
|
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
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;
|
goto Fail;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
for ( m = 0; m < n; m++ )
|
for ( m = 0; m < n; m++ )
|
||||||
|
@ -633,11 +633,11 @@ static void Free_LigGlyph( HB_LigGlyph* lg,
|
||||||
|
|
||||||
/* LigCaretList */
|
/* LigCaretList */
|
||||||
|
|
||||||
static FT_Error Load_LigCaretList( HB_LigCaretList* lcl,
|
static HB_Error Load_LigCaretList( HB_LigCaretList* lcl,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
FT_UShort m, n, count;
|
FT_UShort m, n, count;
|
||||||
FT_ULong cur_offset, new_offset, base_offset;
|
FT_ULong cur_offset, new_offset, base_offset;
|
||||||
|
@ -656,7 +656,7 @@ static FT_Error Load_LigCaretList( HB_LigCaretList* lcl,
|
||||||
|
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
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;
|
return error;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
|
|
||||||
|
@ -685,14 +685,14 @@ static FT_Error Load_LigCaretList( HB_LigCaretList* lcl,
|
||||||
|
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
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;
|
goto Fail1;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
lcl->loaded = TRUE;
|
lcl->loaded = TRUE;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail1:
|
Fail1:
|
||||||
for ( m = 0; m < n; m++ )
|
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 glyphID,
|
||||||
FT_UShort* property )
|
FT_UShort* property )
|
||||||
{
|
{
|
||||||
FT_UShort class, index;
|
FT_UShort class, index;
|
||||||
|
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
|
|
||||||
if ( !gdef || !property )
|
if ( !gdef || !property )
|
||||||
return FT_Err_Invalid_Argument;
|
return HB_Err_Invalid_Argument;
|
||||||
|
|
||||||
/* first, we check for mark attach classes */
|
/* first, we check for mark attach classes */
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ FT_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
|
||||||
if ( !error )
|
if ( !error )
|
||||||
{
|
{
|
||||||
*property = class << 8;
|
*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 )
|
switch ( class )
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case UNCLASSIFIED_GLYPH:
|
case UNCLASSIFIED_GLYPH:
|
||||||
*property = 0;
|
*property = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -837,17 +838,17 @@ FT_Error HB_GDEF_Get_Glyph_Property( HB_GDEFHeader* gdef,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static FT_Error Make_ClassRange( HB_ClassDefinition* cd,
|
static HB_Error Make_ClassRange( HB_ClassDefinition* cd,
|
||||||
FT_UShort start,
|
FT_UShort start,
|
||||||
FT_UShort end,
|
FT_UShort end,
|
||||||
FT_UShort class,
|
FT_UShort class,
|
||||||
FT_Memory memory )
|
FT_Memory memory )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_UShort index;
|
FT_UShort index;
|
||||||
|
|
||||||
HB_ClassDefFormat2* cdf2;
|
HB_ClassDefFormat2* cdf2;
|
||||||
|
@ -873,12 +874,12 @@ static FT_Error Make_ClassRange( HB_ClassDefinition* cd,
|
||||||
|
|
||||||
cd->Defined[class] = TRUE;
|
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 num_glyphs,
|
||||||
FT_UShort glyph_count,
|
FT_UShort glyph_count,
|
||||||
FT_UShort* glyph_array,
|
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 start, curr_glyph, curr_class;
|
||||||
FT_UShort n, m, count;
|
FT_UShort n, m, count;
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory;
|
FT_Memory memory;
|
||||||
|
|
||||||
HB_ClassDefinition* gcd;
|
HB_ClassDefinition* gcd;
|
||||||
|
@ -895,7 +896,7 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
|
||||||
|
|
||||||
|
|
||||||
if ( !gdef || !glyph_array || !class_array )
|
if ( !gdef || !glyph_array || !class_array )
|
||||||
return FT_Err_Invalid_Argument;
|
return HB_Err_Invalid_Argument;
|
||||||
|
|
||||||
memory = gdef->memory;
|
memory = gdef->memory;
|
||||||
gcd = &gdef->GlyphClassDef;
|
gcd = &gdef->GlyphClassDef;
|
||||||
|
@ -918,13 +919,13 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
|
||||||
|
|
||||||
if ( curr_class >= 5 )
|
if ( curr_class >= 5 )
|
||||||
{
|
{
|
||||||
error = FT_Err_Invalid_Argument;
|
error = HB_Err_Invalid_Argument;
|
||||||
goto Fail4;
|
goto Fail4;
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph_count--;
|
glyph_count--;
|
||||||
|
|
||||||
for ( n = 0; n <= glyph_count; n++ )
|
for ( n = 0; n < glyph_count + 1; n++ )
|
||||||
{
|
{
|
||||||
if ( curr_glyph == glyph_array[n] && curr_class == class_array[n] )
|
if ( 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,
|
if ( ( error = Make_ClassRange( gcd, start,
|
||||||
curr_glyph,
|
curr_glyph,
|
||||||
curr_class,
|
curr_class,
|
||||||
memory ) ) != FT_Err_Ok )
|
memory ) ) != HB_Err_Ok )
|
||||||
goto Fail3;
|
goto Fail3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( curr_glyph == 0xFFFF )
|
if ( curr_glyph == 0xFFFF )
|
||||||
{
|
{
|
||||||
error = FT_Err_Invalid_Argument;
|
error = HB_Err_Invalid_Argument;
|
||||||
goto Fail3;
|
goto Fail3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -952,12 +953,12 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
|
||||||
if ( ( error = Make_ClassRange( gcd, start,
|
if ( ( error = Make_ClassRange( gcd, start,
|
||||||
curr_glyph - 1,
|
curr_glyph - 1,
|
||||||
curr_class,
|
curr_class,
|
||||||
memory ) ) != FT_Err_Ok )
|
memory ) ) != HB_Err_Ok )
|
||||||
goto Fail3;
|
goto Fail3;
|
||||||
|
|
||||||
if ( curr_glyph > glyph_array[n] )
|
if ( curr_glyph > glyph_array[n] )
|
||||||
{
|
{
|
||||||
error = FT_Err_Invalid_Argument;
|
error = HB_Err_Invalid_Argument;
|
||||||
goto Fail3;
|
goto Fail3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,7 +968,7 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
|
||||||
|
|
||||||
if ( curr_class >= 5 )
|
if ( curr_class >= 5 )
|
||||||
{
|
{
|
||||||
error = FT_Err_Invalid_Argument;
|
error = HB_Err_Invalid_Argument;
|
||||||
goto Fail3;
|
goto Fail3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -976,14 +977,14 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
|
||||||
if ( ( error = Make_ClassRange( gcd, start,
|
if ( ( error = Make_ClassRange( gcd, start,
|
||||||
curr_glyph,
|
curr_glyph,
|
||||||
curr_class,
|
curr_class,
|
||||||
memory ) ) != FT_Err_Ok )
|
memory ) ) != HB_Err_Ok )
|
||||||
goto Fail3;
|
goto Fail3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( curr_glyph == 0xFFFF )
|
if ( curr_glyph == 0xFFFF )
|
||||||
{
|
{
|
||||||
error = FT_Err_Invalid_Argument;
|
error = HB_Err_Invalid_Argument;
|
||||||
goto Fail3;
|
goto Fail3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1046,7 +1047,7 @@ FT_Error HB_GDEF_Build_ClassDefinition( HB_GDEFHeader* gdef,
|
||||||
|
|
||||||
gcd->loaded = TRUE;
|
gcd->loaded = TRUE;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail1:
|
Fail1:
|
||||||
for ( m = 0; m < n; m++ )
|
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 glyphID,
|
||||||
FT_UShort property )
|
FT_UShort property )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_UShort class, new_class, index;
|
FT_UShort class, new_class, index;
|
||||||
FT_UShort byte, bits, mask;
|
FT_UShort byte, bits, mask;
|
||||||
FT_UShort array_index, glyph_index, count;
|
FT_UShort array_index, glyph_index, count;
|
||||||
|
@ -1129,7 +1130,7 @@ FT_Error _HB_GDEF_Add_Glyph_Property( HB_GDEFHeader* gdef,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FT_Err_Invalid_Argument;
|
return HB_Err_Invalid_Argument;
|
||||||
}
|
}
|
||||||
|
|
||||||
count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount;
|
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;
|
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,
|
HB_GlyphItem gitem,
|
||||||
FT_UShort flags,
|
FT_UShort flags,
|
||||||
FT_UShort* property )
|
FT_UShort* property )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
if ( gdef )
|
if ( gdef )
|
||||||
{
|
{
|
||||||
|
@ -1221,7 +1222,7 @@ FT_Error _HB_GDEF_Check_Property( HB_GDEFHeader* gdef,
|
||||||
*property = 0;
|
*property = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -100,22 +100,22 @@ typedef struct HB_GDEFHeader_ HB_GDEFHeader;
|
||||||
typedef struct HB_GDEFHeader_* HB_GDEF;
|
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 );
|
HB_GDEFHeader** retptr );
|
||||||
|
|
||||||
|
|
||||||
FT_Error HB_Load_GDEF_Table( FT_Face face,
|
HB_Error HB_Load_GDEF_Table( FT_Face face,
|
||||||
HB_GDEFHeader** gdef );
|
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 glyphID,
|
||||||
FT_UShort* property );
|
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 num_glyphs,
|
||||||
FT_UShort glyph_count,
|
FT_UShort glyph_count,
|
||||||
FT_UShort* glyph_array,
|
FT_UShort* glyph_array,
|
||||||
|
|
|
@ -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_Stream stream,
|
||||||
FT_UShort lookup_type );
|
FT_UShort lookup_type );
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -48,7 +48,7 @@ FT_BEGIN_HEADER
|
||||||
|
|
||||||
_glyph = HANDLE_Glyph( glyph ) */
|
_glyph = HANDLE_Glyph( glyph ) */
|
||||||
|
|
||||||
typedef FT_Error (*HB_GlyphFunction)(FT_Face face,
|
typedef HB_Error (*HB_GlyphFunction)(FT_Face face,
|
||||||
FT_UInt glyphIndex,
|
FT_UInt glyphIndex,
|
||||||
FT_Int loadFlags );
|
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
|
`metric_value' must be returned as a scaled value (but shouldn't
|
||||||
be rounded). */
|
be rounded). */
|
||||||
|
|
||||||
typedef FT_Error (*HB_MMFunction)(FT_Face face,
|
typedef HB_Error (*HB_MMFunction)(FT_Face face,
|
||||||
FT_UShort metric_id,
|
FT_UShort metric_id,
|
||||||
FT_Pos* metric_value,
|
FT_Pos* metric_value,
|
||||||
void* data );
|
void* data );
|
||||||
|
@ -99,56 +99,56 @@ typedef struct HB_GPOSHeader_ HB_GPOSHeader;
|
||||||
typedef HB_GPOSHeader* HB_GPOS;
|
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_GPOSHeader** gpos,
|
||||||
HB_GDEFHeader* gdef );
|
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_ULong script_tag,
|
||||||
FT_UShort* script_index );
|
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_ULong language_tag,
|
||||||
FT_UShort script_index,
|
FT_UShort script_index,
|
||||||
FT_UShort* language_index,
|
FT_UShort* language_index,
|
||||||
FT_UShort* req_feature_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_ULong feature_tag,
|
||||||
FT_UShort script_index,
|
FT_UShort script_index,
|
||||||
FT_UShort language_index,
|
FT_UShort language_index,
|
||||||
FT_UShort* feature_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_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_UShort script_index,
|
||||||
FT_ULong** language_tag_list );
|
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 script_index,
|
||||||
FT_UShort language_index,
|
FT_UShort language_index,
|
||||||
FT_ULong** feature_tag_list );
|
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_UShort feature_index,
|
||||||
FT_UInt property );
|
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 );
|
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,
|
HB_MMFunction mmfunc,
|
||||||
void* data );
|
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. */
|
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,
|
HB_GPOSHeader* gpos,
|
||||||
FT_UShort load_flags,
|
FT_UShort load_flags,
|
||||||
HB_Buffer buffer,
|
HB_Buffer buffer,
|
||||||
|
|
|
@ -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_Stream stream,
|
||||||
FT_UShort lookup_type );
|
FT_UShort lookup_type );
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -73,57 +73,57 @@ typedef struct HB_GSUBHeader_ HB_GSUBHeader;
|
||||||
typedef HB_GSUBHeader* HB_GSUB;
|
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_GSUBHeader** gsub,
|
||||||
HB_GDEFHeader* gdef );
|
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_ULong script_tag,
|
||||||
FT_UShort* script_index );
|
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_ULong language_tag,
|
||||||
FT_UShort script_index,
|
FT_UShort script_index,
|
||||||
FT_UShort* language_index,
|
FT_UShort* language_index,
|
||||||
FT_UShort* req_feature_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_ULong feature_tag,
|
||||||
FT_UShort script_index,
|
FT_UShort script_index,
|
||||||
FT_UShort language_index,
|
FT_UShort language_index,
|
||||||
FT_UShort* feature_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_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_UShort script_index,
|
||||||
FT_ULong** language_tag_list );
|
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 script_index,
|
||||||
FT_UShort language_index,
|
FT_UShort language_index,
|
||||||
FT_ULong** feature_tag_list );
|
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_UShort feature_index,
|
||||||
FT_UInt property );
|
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,
|
HB_AltFunction altfunc,
|
||||||
void* data );
|
void* data );
|
||||||
|
|
||||||
|
|
||||||
FT_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub,
|
HB_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub,
|
||||||
HB_Buffer buffer );
|
HB_Buffer buffer );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,20 +63,24 @@ FT_BEGIN_HEADER
|
||||||
#define OUT_GLYPH( pos ) (buffer->out_string[(pos)].gindex)
|
#define OUT_GLYPH( pos ) (buffer->out_string[(pos)].gindex)
|
||||||
#define OUT_ITEM( pos ) (&buffer->out_string[(pos)])
|
#define OUT_ITEM( pos ) (&buffer->out_string[(pos)])
|
||||||
|
|
||||||
#define CHECK_Property( gdef, index, flags, property ) \
|
#define CHECK_Property( gdef, index, flags, property ) \
|
||||||
( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags), \
|
( ( error = _HB_GDEF_Check_Property( (gdef), (index), (flags), \
|
||||||
(property) ) ) != FT_Err_Ok )
|
(property) ) ) != HB_Err_Ok )
|
||||||
|
|
||||||
#define ADD_String( buffer, num_in, num_out, glyph_data, component, ligID ) \
|
#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), \
|
(num_in), (num_out), \
|
||||||
(glyph_data), (component), (ligID) \
|
(glyph_data), (component), (ligID) \
|
||||||
) ) != FT_Err_Ok )
|
) ) != HB_Err_Ok )
|
||||||
#define ADD_Glyph( buffer, glyph_index, component, ligID ) \
|
#define ADD_Glyph( buffer, glyph_index, component, ligID ) \
|
||||||
( ( error = hb_buffer_add_output_glyph( (buffer), \
|
( ( error = hb_buffer_add_output_glyph( (buffer), \
|
||||||
(glyph_index), (component), (ligID) \
|
(glyph_index), (component), (ligID) \
|
||||||
) ) != FT_Err_Ok )
|
) ) != HB_Err_Ok )
|
||||||
|
#define REPLACE_Glyph( buffer, glyph_index, nesting_level ) \
|
||||||
|
( ( error = hb_buffer_replace_output_glyph( (buffer), (glyph_index), \
|
||||||
|
(nesting_level) == 1 ) ) != HB_Err_Ok )
|
||||||
|
#define COPY_Glyph( buffer ) \
|
||||||
|
( (error = hb_buffer_copy_output_glyph ( buffer ) ) != HB_Err_Ok )
|
||||||
|
|
||||||
FT_END_HEADER
|
FT_END_HEADER
|
||||||
|
|
||||||
|
|
|
@ -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_Stream stream );
|
||||||
FT_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
|
HB_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
|
||||||
FT_Stream input );
|
FT_Stream input );
|
||||||
FT_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
|
HB_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
|
||||||
FT_Stream input,
|
FT_Stream input,
|
||||||
HB_Type type );
|
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_Stream input );
|
||||||
FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
|
HB_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
|
||||||
FT_UShort limit,
|
FT_UShort limit,
|
||||||
FT_Stream input );
|
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_Stream input );
|
||||||
FT_Error _HB_OPEN_Load_Device( HB_Device* d,
|
HB_Error _HB_OPEN_Load_Device( HB_Device* d,
|
||||||
FT_Stream input );
|
FT_Stream input );
|
||||||
|
|
||||||
void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl,
|
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 glyphID,
|
||||||
FT_UShort* index );
|
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 glyphID,
|
||||||
FT_UShort* class,
|
FT_UShort* class,
|
||||||
FT_UShort* index );
|
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_UShort size,
|
||||||
FT_Short* value );
|
FT_Short* value );
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
|
|
||||||
/* LangSys */
|
/* LangSys */
|
||||||
|
|
||||||
static FT_Error Load_LangSys( HB_LangSys* ls,
|
static HB_Error Load_LangSys( HB_LangSys* ls,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
FT_UShort n, count;
|
FT_UShort n, count;
|
||||||
FT_UShort* fi;
|
FT_UShort* fi;
|
||||||
|
@ -57,7 +57,7 @@ static FT_Error Load_LangSys( HB_LangSys* ls,
|
||||||
|
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@ static void Free_LangSys( HB_LangSys* ls,
|
||||||
|
|
||||||
/* Script */
|
/* Script */
|
||||||
|
|
||||||
static FT_Error Load_Script( HB_Script* s,
|
static HB_Error Load_Script( HB_Script* s,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
FT_UShort n, m, count;
|
FT_UShort n, m, count;
|
||||||
FT_ULong cur_offset, new_offset, base_offset;
|
FT_ULong cur_offset, new_offset, base_offset;
|
||||||
|
@ -95,7 +95,7 @@ static FT_Error Load_Script( HB_Script* s,
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
if ( FILE_Seek( new_offset ) ||
|
||||||
( error = Load_LangSys( &s->DefaultLangSys,
|
( error = Load_LangSys( &s->DefaultLangSys,
|
||||||
stream ) ) != FT_Err_Ok )
|
stream ) ) != HB_Err_Ok )
|
||||||
return error;
|
return error;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
@ -144,12 +144,12 @@ static FT_Error Load_Script( HB_Script* s,
|
||||||
|
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
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;
|
goto Fail1;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail1:
|
Fail1:
|
||||||
for ( m = 0; m < n; m++ )
|
for ( m = 0; m < n; m++ )
|
||||||
|
@ -188,10 +188,10 @@ static void Free_Script( HB_Script* s,
|
||||||
|
|
||||||
/* ScriptList */
|
/* ScriptList */
|
||||||
|
|
||||||
FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
|
HB_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, script_count;
|
FT_UShort n, script_count;
|
||||||
|
@ -233,7 +233,7 @@ FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
error = Load_Script( &sr[sl->ScriptCount].Script, stream );
|
error = Load_Script( &sr[sl->ScriptCount].Script, stream );
|
||||||
if ( error == FT_Err_Ok )
|
if ( error == HB_Err_Ok )
|
||||||
sl->ScriptCount += 1;
|
sl->ScriptCount += 1;
|
||||||
else if ( error != HB_Err_Empty_Script )
|
else if ( error != HB_Err_Empty_Script )
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
@ -247,12 +247,12 @@ FT_Error _HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
|
||||||
#if 0
|
#if 0
|
||||||
if ( sl->ScriptCount == 0 )
|
if ( sl->ScriptCount == 0 )
|
||||||
{
|
{
|
||||||
error = HB_Err_Invalid_SubTable;
|
error = _hb_err(HB_Err_Invalid_SubTable);
|
||||||
goto Fail;
|
goto Fail;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
for ( n = 0; n < sl->ScriptCount; n++ )
|
for ( n = 0; n < sl->ScriptCount; n++ )
|
||||||
|
@ -292,10 +292,10 @@ void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl,
|
||||||
|
|
||||||
/* Feature */
|
/* Feature */
|
||||||
|
|
||||||
static FT_Error Load_Feature( HB_Feature* f,
|
static HB_Error Load_Feature( HB_Feature* f,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, count;
|
FT_UShort n, count;
|
||||||
|
@ -329,7 +329,7 @@ static FT_Error Load_Feature( HB_Feature* f,
|
||||||
|
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -342,10 +342,10 @@ static void Free_Feature( HB_Feature* f,
|
||||||
|
|
||||||
/* FeatureList */
|
/* FeatureList */
|
||||||
|
|
||||||
FT_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
|
HB_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, m, count;
|
FT_UShort n, m, count;
|
||||||
|
@ -386,12 +386,12 @@ FT_Error _HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
|
||||||
|
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
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;
|
goto Fail1;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail1:
|
Fail1:
|
||||||
for ( m = 0; m < n; m++ )
|
for ( m = 0; m < n; m++ )
|
||||||
|
@ -440,7 +440,7 @@ void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl,
|
||||||
|
|
||||||
/* SubTable */
|
/* SubTable */
|
||||||
|
|
||||||
static FT_Error Load_SubTable( HB_SubTable* st,
|
static HB_Error Load_SubTable( HB_SubTable* st,
|
||||||
FT_Stream stream,
|
FT_Stream stream,
|
||||||
HB_Type table_type,
|
HB_Type table_type,
|
||||||
FT_UShort lookup_type )
|
FT_UShort lookup_type )
|
||||||
|
@ -466,11 +466,11 @@ static void Free_SubTable( HB_SubTable* st,
|
||||||
|
|
||||||
/* Lookup */
|
/* Lookup */
|
||||||
|
|
||||||
static FT_Error Load_Lookup( HB_Lookup* l,
|
static HB_Error Load_Lookup( HB_Lookup* l,
|
||||||
FT_Stream stream,
|
FT_Stream stream,
|
||||||
HB_Type type )
|
HB_Type type )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, m, count;
|
FT_UShort n, m, count;
|
||||||
|
@ -530,12 +530,12 @@ static FT_Error Load_Lookup( HB_Lookup* l,
|
||||||
|
|
||||||
if ( FILE_Seek( new_offset ) ||
|
if ( FILE_Seek( new_offset ) ||
|
||||||
( error = Load_SubTable( &st[n], stream,
|
( error = Load_SubTable( &st[n], stream,
|
||||||
type, l->LookupType ) ) != FT_Err_Ok )
|
type, l->LookupType ) ) != HB_Err_Ok )
|
||||||
goto Fail;
|
goto Fail;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
for ( m = 0; m < n; m++ )
|
for ( m = 0; m < n; m++ )
|
||||||
|
@ -570,11 +570,11 @@ static void Free_Lookup( HB_Lookup* l,
|
||||||
|
|
||||||
/* LookupList */
|
/* LookupList */
|
||||||
|
|
||||||
FT_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
|
HB_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
|
||||||
FT_Stream stream,
|
FT_Stream stream,
|
||||||
HB_Type type )
|
HB_Type type )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, m, count;
|
FT_UShort n, m, count;
|
||||||
|
@ -612,12 +612,12 @@ FT_Error _HB_OPEN_Load_LookupList( HB_LookupList* ll,
|
||||||
|
|
||||||
cur_offset = FILE_Pos();
|
cur_offset = FILE_Pos();
|
||||||
if ( FILE_Seek( new_offset ) ||
|
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;
|
goto Fail1;
|
||||||
(void)FILE_Seek( cur_offset );
|
(void)FILE_Seek( cur_offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail1:
|
Fail1:
|
||||||
FREE( ll->Properties );
|
FREE( ll->Properties );
|
||||||
|
@ -663,10 +663,10 @@ void _HB_OPEN_Free_LookupList( HB_LookupList* ll,
|
||||||
|
|
||||||
/* CoverageFormat1 */
|
/* CoverageFormat1 */
|
||||||
|
|
||||||
static FT_Error Load_Coverage1( HB_CoverageFormat1* cf1,
|
static HB_Error Load_Coverage1( HB_CoverageFormat1* cf1,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, count;
|
FT_UShort n, count;
|
||||||
|
@ -699,7 +699,7 @@ static FT_Error Load_Coverage1( HB_CoverageFormat1* cf1,
|
||||||
|
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -712,10 +712,10 @@ static void Free_Coverage1( HB_CoverageFormat1* cf1,
|
||||||
|
|
||||||
/* CoverageFormat2 */
|
/* CoverageFormat2 */
|
||||||
|
|
||||||
static FT_Error Load_Coverage2( HB_CoverageFormat2* cf2,
|
static HB_Error Load_Coverage2( HB_CoverageFormat2* cf2,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, count;
|
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 ) >=
|
( rr[n].End - rr[n].Start + (long)rr[n].StartCoverageIndex ) >=
|
||||||
0x10000L )
|
0x10000L )
|
||||||
{
|
{
|
||||||
error = HB_Err_Invalid_SubTable;
|
error = _hb_err(HB_Err_Invalid_SubTable);
|
||||||
goto Fail;
|
goto Fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
FREE( cf2->RangeRecord );
|
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_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
|
|
||||||
if ( ACCESS_Frame( 2L ) )
|
if ( ACCESS_Frame( 2L ) )
|
||||||
return error;
|
return error;
|
||||||
|
@ -787,17 +787,12 @@ FT_Error _HB_OPEN_Load_Coverage( HB_Coverage* c,
|
||||||
|
|
||||||
switch ( c->CoverageFormat )
|
switch ( c->CoverageFormat )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1: return Load_Coverage1( &c->cf.cf1, stream );
|
||||||
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);
|
||||||
case 2:
|
|
||||||
return Load_Coverage2( &c->cf.cf2, stream );
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 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 )
|
switch ( c->CoverageFormat )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1: Free_Coverage1( &c->cf.cf1, memory ); break;
|
||||||
Free_Coverage1( &c->cf.cf1, memory );
|
case 2: Free_Coverage2( &c->cf.cf2, memory ); break;
|
||||||
break;
|
default: break;
|
||||||
|
|
||||||
case 2:
|
|
||||||
Free_Coverage2( &c->cf.cf2, memory );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static FT_Error Coverage_Index1( HB_CoverageFormat1* cf1,
|
static HB_Error Coverage_Index1( HB_CoverageFormat1* cf1,
|
||||||
FT_UShort glyphID,
|
FT_UShort glyphID,
|
||||||
FT_UShort* index )
|
FT_UShort* index )
|
||||||
{
|
{
|
||||||
|
@ -847,7 +838,7 @@ static FT_Error Coverage_Index1( HB_CoverageFormat1* cf1,
|
||||||
if ( glyphID == array[middle] )
|
if ( glyphID == array[middle] )
|
||||||
{
|
{
|
||||||
*index = middle;
|
*index = middle;
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
else if ( glyphID < array[middle] )
|
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 glyphID,
|
||||||
FT_UShort* index )
|
FT_UShort* index )
|
||||||
{
|
{
|
||||||
|
@ -897,7 +888,7 @@ static FT_Error Coverage_Index2( HB_CoverageFormat2* cf2,
|
||||||
if ( glyphID >= rr[middle].Start && glyphID <= rr[middle].End )
|
if ( glyphID >= rr[middle].Start && glyphID <= rr[middle].End )
|
||||||
{
|
{
|
||||||
*index = rr[middle].StartCoverageIndex + glyphID - rr[middle].Start;
|
*index = rr[middle].StartCoverageIndex + glyphID - rr[middle].Start;
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
else if ( glyphID < rr[middle].Start )
|
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 glyphID,
|
||||||
FT_UShort* index )
|
FT_UShort* index )
|
||||||
{
|
{
|
||||||
switch ( c->CoverageFormat )
|
switch ( c->CoverageFormat )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1: return Coverage_Index1( &c->cf.cf1, glyphID, index );
|
||||||
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);
|
||||||
case 2:
|
|
||||||
return Coverage_Index2( &c->cf.cf2, glyphID, index );
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 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 */
|
/* ClassDefFormat1 */
|
||||||
|
|
||||||
static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
|
static HB_Error Load_ClassDef1( HB_ClassDefinition* cd,
|
||||||
FT_UShort limit,
|
FT_UShort limit,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, count;
|
FT_UShort n, count;
|
||||||
|
@ -973,7 +959,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
|
||||||
/* sanity check; we are limited to 16bit integers */
|
/* sanity check; we are limited to 16bit integers */
|
||||||
|
|
||||||
if ( cdf1->StartGlyph + (long)count >= 0x10000L )
|
if ( cdf1->StartGlyph + (long)count >= 0x10000L )
|
||||||
return HB_Err_Invalid_SubTable;
|
return _hb_err(HB_Err_Invalid_SubTable);
|
||||||
|
|
||||||
cdf1->ClassValueArray = NULL;
|
cdf1->ClassValueArray = NULL;
|
||||||
|
|
||||||
|
@ -991,7 +977,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
|
||||||
cva[n] = GET_UShort();
|
cva[n] = GET_UShort();
|
||||||
if ( cva[n] >= limit )
|
if ( cva[n] >= limit )
|
||||||
{
|
{
|
||||||
error = HB_Err_Invalid_SubTable;
|
error = _hb_err(HB_Err_Invalid_SubTable);
|
||||||
goto Fail;
|
goto Fail;
|
||||||
}
|
}
|
||||||
d[cva[n]] = TRUE;
|
d[cva[n]] = TRUE;
|
||||||
|
@ -999,7 +985,7 @@ static FT_Error Load_ClassDef1( HB_ClassDefinition* cd,
|
||||||
|
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
FREE( cva );
|
FREE( cva );
|
||||||
|
@ -1017,11 +1003,11 @@ static void Free_ClassDef1( HB_ClassDefFormat1* cdf1,
|
||||||
|
|
||||||
/* ClassDefFormat2 */
|
/* ClassDefFormat2 */
|
||||||
|
|
||||||
static FT_Error Load_ClassDef2( HB_ClassDefinition* cd,
|
static HB_Error Load_ClassDef2( HB_ClassDefinition* cd,
|
||||||
FT_UShort limit,
|
FT_UShort limit,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, count;
|
FT_UShort n, count;
|
||||||
|
@ -1037,7 +1023,8 @@ static FT_Error Load_ClassDef2( HB_ClassDefinition* cd,
|
||||||
if ( ACCESS_Frame( 2L ) )
|
if ( ACCESS_Frame( 2L ) )
|
||||||
return error;
|
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();
|
FORGET_Frame();
|
||||||
|
|
||||||
|
@ -1063,15 +1050,22 @@ static FT_Error Load_ClassDef2( HB_ClassDefinition* cd,
|
||||||
if ( crr[n].Start > crr[n].End ||
|
if ( crr[n].Start > crr[n].End ||
|
||||||
crr[n].Class >= limit )
|
crr[n].Class >= limit )
|
||||||
{
|
{
|
||||||
error = HB_Err_Invalid_SubTable;
|
/* XXX
|
||||||
goto Fail;
|
* 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();
|
FORGET_Frame();
|
||||||
|
|
||||||
return FT_Err_Ok;
|
cdf2->ClassRangeCount = count;
|
||||||
|
|
||||||
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
FREE( crr );
|
FREE( crr );
|
||||||
|
@ -1089,11 +1083,11 @@ static void Free_ClassDef2( HB_ClassDefFormat2* cdf2,
|
||||||
|
|
||||||
/* ClassDefinition */
|
/* ClassDefinition */
|
||||||
|
|
||||||
FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
|
HB_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
|
||||||
FT_UShort limit,
|
FT_UShort limit,
|
||||||
FT_Stream stream )
|
FT_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1109,17 +1103,9 @@ FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
|
||||||
|
|
||||||
switch ( cd->ClassFormat )
|
switch ( cd->ClassFormat )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1: error = Load_ClassDef1( cd, limit, stream ); break;
|
||||||
error = Load_ClassDef1( cd, limit, stream );
|
case 2: error = Load_ClassDef2( cd, limit, stream ); break;
|
||||||
break;
|
default: error = _hb_err(HB_Err_Invalid_SubTable_Format); break;
|
||||||
|
|
||||||
case 2:
|
|
||||||
error = Load_ClassDef2( cd, limit, stream );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
error = HB_Err_Invalid_SubTable_Format;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( error )
|
if ( error )
|
||||||
|
@ -1127,7 +1113,7 @@ FT_Error _HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
|
||||||
|
|
||||||
cd->loaded = TRUE;
|
cd->loaded = TRUE;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
FREE( cd->Defined );
|
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_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
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 ) )
|
if ( ALLOC_ARRAY( cd->cd.cd1.ClassValueArray, 1, FT_UShort ) )
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
FREE( cd->Defined );
|
FREE( cd->Defined );
|
||||||
|
@ -1168,18 +1154,14 @@ void _HB_OPEN_Free_ClassDefinition( HB_ClassDefinition* cd,
|
||||||
|
|
||||||
switch ( cd->ClassFormat )
|
switch ( cd->ClassFormat )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1: Free_ClassDef1( &cd->cd.cd1, memory ); break;
|
||||||
Free_ClassDef1( &cd->cd.cd1, memory );
|
case 2: Free_ClassDef2( &cd->cd.cd2, memory ); break;
|
||||||
break;
|
default: break;
|
||||||
|
|
||||||
case 2:
|
|
||||||
Free_ClassDef2( &cd->cd.cd2, memory );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static FT_Error Get_Class1( HB_ClassDefFormat1* cdf1,
|
static HB_Error Get_Class1( HB_ClassDefFormat1* cdf1,
|
||||||
FT_UShort glyphID,
|
FT_UShort glyphID,
|
||||||
FT_UShort* class,
|
FT_UShort* class,
|
||||||
FT_UShort* index )
|
FT_UShort* index )
|
||||||
|
@ -1194,7 +1176,7 @@ static FT_Error Get_Class1( HB_ClassDefFormat1* cdf1,
|
||||||
glyphID < cdf1->StartGlyph + cdf1->GlyphCount )
|
glyphID < cdf1->StartGlyph + cdf1->GlyphCount )
|
||||||
{
|
{
|
||||||
*class = cva[glyphID - cdf1->StartGlyph];
|
*class = cva[glyphID - cdf1->StartGlyph];
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
else
|
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
|
/* we need the index value of the last searched class range record
|
||||||
in case of failure for constructed GDEF tables */
|
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 glyphID,
|
||||||
FT_UShort* class,
|
FT_UShort* class,
|
||||||
FT_UShort* index )
|
FT_UShort* index )
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
HB_Error error = HB_Err_Ok;
|
||||||
FT_UShort min, max, new_min, new_max, middle;
|
FT_UShort min, max, new_min, new_max, middle;
|
||||||
|
|
||||||
HB_ClassRangeRecord* crr = cdf2->ClassRangeRecord;
|
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 )
|
if ( glyphID >= crr[middle].Start && glyphID <= crr[middle].End )
|
||||||
{
|
{
|
||||||
*class = crr[middle].Class;
|
*class = crr[middle].Class;
|
||||||
error = FT_Err_Ok;
|
error = HB_Err_Ok;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ( glyphID < crr[middle].Start )
|
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 glyphID,
|
||||||
FT_UShort* class,
|
FT_UShort* class,
|
||||||
FT_UShort* index )
|
FT_UShort* index )
|
||||||
{
|
{
|
||||||
switch ( cd->ClassFormat )
|
switch ( cd->ClassFormat )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1: return Get_Class1( &cd->cd.cd1, glyphID, class, index );
|
||||||
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);
|
||||||
case 2:
|
|
||||||
return Get_Class2( &cd->cd.cd2, glyphID, class, index );
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 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_Stream stream )
|
||||||
{
|
{
|
||||||
FT_Error error;
|
HB_Error error;
|
||||||
FT_Memory memory = stream->memory;
|
FT_Memory memory = stream->memory;
|
||||||
|
|
||||||
FT_UShort n, count;
|
FT_UShort n, count;
|
||||||
|
@ -1324,11 +1301,18 @@ FT_Error _HB_OPEN_Load_Device( HB_Device* d,
|
||||||
|
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
|
|
||||||
|
d->DeltaValue = NULL;
|
||||||
|
|
||||||
if ( d->StartSize > d->EndSize ||
|
if ( d->StartSize > d->EndSize ||
|
||||||
d->DeltaFormat == 0 || d->DeltaFormat > 3 )
|
d->DeltaFormat == 0 || d->DeltaFormat > 3 )
|
||||||
return HB_Err_Invalid_SubTable;
|
{
|
||||||
|
/* XXX
|
||||||
d->DeltaValue = NULL;
|
* 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 ) >>
|
count = ( ( d->EndSize - d->StartSize + 1 ) >>
|
||||||
( 4 - d->DeltaFormat ) ) + 1;
|
( 4 - d->DeltaFormat ) ) + 1;
|
||||||
|
@ -1349,7 +1333,7 @@ FT_Error _HB_OPEN_Load_Device( HB_Device* d,
|
||||||
|
|
||||||
FORGET_Frame();
|
FORGET_Frame();
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1395,7 +1379,7 @@ void _HB_OPEN_Free_Device( HB_Device* d,
|
||||||
|
|
||||||
mask = 0x00FF */
|
mask = 0x00FF */
|
||||||
|
|
||||||
FT_Error _HB_OPEN_Get_Device( HB_Device* d,
|
HB_Error _HB_OPEN_Get_Device( HB_Device* d,
|
||||||
FT_UShort size,
|
FT_UShort size,
|
||||||
FT_Short* value )
|
FT_Short* value )
|
||||||
{
|
{
|
||||||
|
@ -1418,7 +1402,7 @@ FT_Error _HB_OPEN_Get_Device( HB_Device* d,
|
||||||
if ( *value >= ( ( mask + 1 ) >> 1 ) )
|
if ( *value >= ( ( mask + 1 ) >> 1 ) )
|
||||||
*value -= mask + 1;
|
*value -= mask + 1;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return HB_Err_Ok;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,12 +25,21 @@ FT_BEGIN_HEADER
|
||||||
|
|
||||||
#define HB_MAX_NESTING_LEVEL 100
|
#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_Format 0x1000
|
||||||
#define HB_Err_Invalid_SubTable 0x1001
|
#define HB_Err_Invalid_SubTable 0x1001
|
||||||
#define HB_Err_Not_Covered 0x1002
|
|
||||||
#define HB_Err_Too_Many_Nested_Contexts 0x1003
|
#define HB_Err_Too_Many_Nested_Contexts 0x1003
|
||||||
#define HB_Err_No_MM_Interpreter 0x1004
|
#define HB_Err_No_MM_Interpreter 0x1004
|
||||||
#define HB_Err_Empty_Script 0x1005
|
|
||||||
|
|
||||||
|
|
||||||
/* Script list related structures */
|
/* Script list related structures */
|
||||||
|
|
Loading…
Reference in New Issue