[HB] Remove all references to the old code!

This commit is contained in:
Behdad Esfahbod 2009-05-20 05:35:14 -04:00
parent e1593a6e62
commit b857b49c82
6 changed files with 138 additions and 198 deletions

View File

@ -1,5 +1,7 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
NULL =
INCLUDES = \ INCLUDES = \
-I $(srcdir) \ -I $(srcdir) \
$(FREETYPE_CFLAGS) \ $(FREETYPE_CFLAGS) \
@ -8,63 +10,33 @@ CXX = gcc $(GCCOPTS) -g -fno-rtti -fno-exceptions -Wabi -Wpadded -Wcast-align
noinst_LTLIBRARIES = libharfbuzz-1.la noinst_LTLIBRARIES = libharfbuzz-1.la
MAINSOURCES = \ HBSOURCES = \
$(INCLUDEDSOURCES) \
hb-ot-layout.cc
# harfbuzz.c
# included from harfbuzz.c
INCLUDEDSOURCES = \
harfbuzz-buffer.c \ harfbuzz-buffer.c \
harfbuzz-gpos.c \ hb-private.h \
harfbuzz-gsub.c \ hb-ot-layout.cc \
harfbuzz-impl.c \ hb-ot-layout-common-private.h \
harfbuzz-open.c \ hb-ot-layout-gdef-private.h \
harfbuzz-stream.c hb-ot-layout-gpos-private.h \
hb-ot-layout-gsubgpos-private.h \
hb-ot-layout-gsub-private.h \
hb-ot-layout-open-private.h \
hb-ot-layout-private.h \
$(NULL)
PUBLICHEADERS = \ HBHEADERS = \
harfbuzz.h \ hb-common.h \
harfbuzz-global.h \
harfbuzz-buffer.h \ harfbuzz-buffer.h \
harfbuzz-gpos.h \ hb-ot-layout.h \
harfbuzz-gsub.h \ $(NULL)
harfbuzz-open.h
PRIVATEHEADERS = \ libharfbuzz_1_la_SOURCES = $(HBSOURCES) $(HBHEADERS)
harfbuzz-impl.h \ libharfbuzz_1_la_LIBADD = $(FREETYPE_LIBS)
harfbuzz-buffer-private.h \
harfbuzz-gpos-private.h \
harfbuzz-gsub-private.h \
harfbuzz-open-private.h \
harfbuzz-stream-private.h
libharfbuzz_1_la_SOURCES = \ noinst_PROGRAMS = main
$(MAINSOURCES) \
$(PUBLICHEADERS) \
$(PRIVATEHEADERS)
libharfbuzz_1_la_LIBADD = \ main_SOURCES = main.cc
$(FREETYPE_LIBS) main_LDADD = $(GLIB_LIBS)
noinst_PROGRAMS = harfbuzz-dump main EXTRA_DIST = README COPYING
harfbuzz_dump_SOURCES = \
harfbuzz-dump.c \
harfbuzz-dump.h \
harfbuzz-dump-main.c
harfbuzz_dump_LDADD = \
$(libharfbuzz_1_la_LIBADD) \
libharfbuzz-1.la
main_SOURCES = \
main.cc
main_LDADD = \
$(GLIB_LIBS)
EXTRA_DIST = \
README \
COPYING \
$(INCLUDEDSOURCES)
-include $(top_srcdir)/git.mk -include $(top_srcdir)/git.mk

View File

@ -59,11 +59,12 @@
/* Internal API */ /* Internal API */
/*static XXX */ HB_Error /*static XXX */ void
hb_buffer_ensure( HB_Buffer buffer, hb_buffer_ensure (hb_buffer_t *buffer,
HB_UInt size ) unsigned int size)
{ {
HB_UInt new_allocated = buffer->allocated; HB_UInt new_allocated = buffer->allocated;
/* XXX err handling */
if (size > new_allocated) if (size > new_allocated)
{ {
@ -72,52 +73,39 @@ hb_buffer_ensure( HB_Buffer buffer,
while (size > new_allocated) while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8; new_allocated += (new_allocated >> 1) + 8;
if ( buffer->positions ) if (buffer->positions)
buffer->positions = realloc (buffer->positions, new_allocated * sizeof (buffer->positions[0]));
buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
if (buffer->separate_out)
{ {
if ( REALLOC_ARRAY( buffer->positions, new_allocated, HB_PositionRec ) ) buffer->alt_string = realloc (buffer->alt_string, new_allocated * sizeof (buffer->alt_string[0]));
return error;
}
if ( REALLOC_ARRAY( buffer->in_string, new_allocated, HB_GlyphItemRec ) )
return error;
if ( buffer->separate_out )
{
if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) )
return error;
buffer->out_string = buffer->alt_string; buffer->out_string = buffer->alt_string;
} }
else else
{ {
buffer->out_string = buffer->in_string; buffer->out_string = buffer->in_string;
if ( buffer->alt_string ) if (buffer->alt_string)
{ {
if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) ) free (buffer->alt_string);
return error; buffer->alt_string = NULL;
} }
} }
buffer->allocated = new_allocated; buffer->allocated = new_allocated;
} }
return HB_Err_Ok;
} }
static HB_Error static HB_Error
hb_buffer_duplicate_out_buffer( HB_Buffer buffer ) hb_buffer_duplicate_out_buffer (HB_Buffer buffer)
{ {
if ( !buffer->alt_string ) if (!buffer->alt_string)
{ buffer->alt_string = malloc (buffer->allocated * sizeof (buffer->alt_string[0]));
HB_Error error;
if ( ALLOC_ARRAY( buffer->alt_string, buffer->allocated, HB_GlyphItemRec ) )
return error;
}
buffer->out_string = buffer->alt_string; buffer->out_string = buffer->alt_string;
memcpy( buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]) ); memcpy (buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]));
buffer->separate_out = TRUE; buffer->separate_out = TRUE;
return HB_Err_Ok; return HB_Err_Ok;
@ -125,39 +113,36 @@ hb_buffer_duplicate_out_buffer( HB_Buffer buffer )
/* Public API */ /* Public API */
HB_Error hb_buffer_t *
hb_buffer_new( HB_Buffer *pbuffer ) hb_buffer_new (void)
{ {
HB_Buffer buffer; hb_buffer_t *buffer;
HB_Error error;
buffer = malloc (sizeof (hb_buffer_t));
if ( ALLOC( buffer, sizeof( HB_BufferRec ) ) ) if (HB_UNLIKELY (!buffer))
return error; return NULL;
buffer->allocated = 0; buffer->allocated = 0;
buffer->in_string = NULL; buffer->in_string = NULL;
buffer->alt_string = NULL; buffer->alt_string = NULL;
buffer->positions = NULL; buffer->positions = NULL;
hb_buffer_clear( buffer ); hb_buffer_clear (buffer);
*pbuffer = buffer; return buffer;
return HB_Err_Ok;
} }
void void
hb_buffer_free( HB_Buffer buffer ) hb_buffer_free (HB_Buffer buffer)
{ {
FREE( buffer->in_string ); free (buffer->in_string);
FREE( buffer->alt_string ); free (buffer->alt_string);
buffer->out_string = NULL; free (buffer->positions);
FREE( buffer->positions ); free (buffer);
FREE( buffer );
} }
void 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;
@ -168,18 +153,16 @@ hb_buffer_clear( HB_Buffer buffer )
buffer->max_ligID = 0; buffer->max_ligID = 0;
} }
HB_Error void
hb_buffer_add_glyph( HB_Buffer buffer, hb_buffer_add_glyph (HB_Buffer buffer,
HB_UInt glyph_index, HB_UInt glyph_index,
HB_UInt properties, HB_UInt properties,
HB_UInt cluster ) HB_UInt cluster)
{ {
HB_Error error; HB_Error error;
HB_GlyphItem glyph; HB_GlyphItem glyph;
error = hb_buffer_ensure( buffer, buffer->in_length + 1 ); hb_buffer_ensure (buffer, buffer->in_length + 1);
if ( error )
return error;
glyph = &buffer->in_string[buffer->in_length]; glyph = &buffer->in_string[buffer->in_length];
glyph->gindex = glyph_index; glyph->gindex = glyph_index;
@ -188,16 +171,14 @@ hb_buffer_add_glyph( HB_Buffer buffer,
glyph->component = 0; glyph->component = 0;
glyph->ligID = 0; glyph->ligID = 0;
glyph->gproperty = HB_GLYPH_PROPERTY_UNKNOWN; glyph->gproperty = HB_GLYPH_PROPERTY_UNKNOWN;
buffer->in_length++;
return HB_Err_Ok; buffer->in_length++;
} }
/* HarfBuzz-Internal API */ /* HarfBuzz-Internal API */
HB_INTERNAL void HB_INTERNAL void
_hb_buffer_clear_output( HB_Buffer buffer ) _hb_buffer_clear_output (HB_Buffer buffer)
{ {
buffer->out_length = 0; buffer->out_length = 0;
buffer->out_pos = 0; buffer->out_pos = 0;
@ -206,17 +187,12 @@ _hb_buffer_clear_output( HB_Buffer buffer )
} }
HB_INTERNAL HB_Error HB_INTERNAL HB_Error
_hb_buffer_clear_positions( HB_Buffer buffer ) _hb_buffer_clear_positions (HB_Buffer buffer)
{ {
_hb_buffer_clear_output (buffer); _hb_buffer_clear_output (buffer);
if ( !buffer->positions ) if (!buffer->positions)
{ buffer->positions = malloc (buffer->allocated * sizeof (buffer->positions[0]));
HB_Error error;
if ( ALLOC_ARRAY( buffer->positions, buffer->allocated, HB_PositionRec ) )
return error;
}
memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length); memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length);
@ -224,13 +200,13 @@ _hb_buffer_clear_positions( HB_Buffer buffer )
} }
HB_INTERNAL void HB_INTERNAL 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_length;
int tmp_pos; int tmp_pos;
if ( buffer->separate_out ) if (buffer->separate_out)
{ {
tmp_string = buffer->in_string; tmp_string = buffer->in_string;
buffer->in_string = buffer->out_string; buffer->in_string = buffer->out_string;
@ -267,37 +243,35 @@ _hb_buffer_swap( 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 */
HB_INTERNAL HB_Error HB_INTERNAL HB_Error
_hb_buffer_add_output_glyphs( HB_Buffer buffer, _hb_buffer_add_output_glyphs (HB_Buffer buffer,
HB_UShort num_in, HB_UShort num_in,
HB_UShort num_out, HB_UShort num_out,
HB_UShort *glyph_data, HB_UShort *glyph_data,
HB_UShort component, HB_UShort component,
HB_UShort ligID ) HB_UShort ligID)
{ {
HB_Error error; HB_Error error;
HB_UShort i; HB_UShort i;
HB_UInt properties; HB_UInt properties;
HB_UInt cluster; HB_UInt cluster;
error = hb_buffer_ensure( buffer, buffer->out_pos + num_out ); hb_buffer_ensure (buffer, buffer->out_pos + num_out);
if ( error )
return error;
if ( !buffer->separate_out ) if (!buffer->separate_out)
{ {
error = hb_buffer_duplicate_out_buffer( buffer ); error = hb_buffer_duplicate_out_buffer (buffer);
if ( error ) if (error)
return 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)
component = buffer->in_string[buffer->in_pos].component; component = buffer->in_string[buffer->in_pos].component;
if ( ligID == 0xFFFF ) if (ligID == 0xFFFF)
ligID = buffer->in_string[buffer->in_pos].ligID; ligID = buffer->in_string[buffer->in_pos].ligID;
for ( i = 0; i < num_out; i++ ) for (i = 0; i < num_out; i++)
{ {
HB_GlyphItem item = &buffer->out_string[buffer->out_pos + i]; HB_GlyphItem item = &buffer->out_string[buffer->out_pos + i];
@ -318,27 +292,25 @@ _hb_buffer_add_output_glyphs( HB_Buffer buffer,
} }
HB_INTERNAL HB_Error HB_INTERNAL HB_Error
_hb_buffer_add_output_glyph( HB_Buffer buffer, _hb_buffer_add_output_glyph (HB_Buffer buffer,
HB_UInt glyph_index, HB_UInt glyph_index,
HB_UShort component, HB_UShort component,
HB_UShort ligID ) HB_UShort ligID)
{ {
HB_UShort glyph_data = glyph_index; HB_UShort glyph_data = glyph_index;
return _hb_buffer_add_output_glyphs ( buffer, 1, 1, return _hb_buffer_add_output_glyphs (buffer, 1, 1,
&glyph_data, component, ligID ); &glyph_data, component, ligID);
} }
HB_INTERNAL HB_Error HB_INTERNAL HB_Error
_hb_buffer_next_glyph ( HB_Buffer buffer ) _hb_buffer_next_glyph (HB_Buffer buffer)
{ {
HB_Error error; HB_Error error;
if ( buffer->separate_out ) if (buffer->separate_out)
{ {
error = hb_buffer_ensure( buffer, buffer->out_pos + 1 ); hb_buffer_ensure (buffer, buffer->out_pos + 1);
if ( error )
return error;
buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
} }
@ -351,10 +323,10 @@ _hb_buffer_next_glyph ( HB_Buffer buffer )
} }
HB_INTERNAL HB_Error HB_INTERNAL HB_Error
_hb_buffer_replace_glyph( HB_Buffer buffer, _hb_buffer_replace_glyph (HB_Buffer buffer,
HB_UInt glyph_index ) HB_UInt glyph_index)
{ {
if ( !buffer->separate_out ) if (!buffer->separate_out)
{ {
buffer->out_string[buffer->out_pos].gindex = glyph_index; buffer->out_string[buffer->out_pos].gindex = glyph_index;
@ -364,14 +336,14 @@ _hb_buffer_replace_glyph( HB_Buffer buffer,
} }
else else
{ {
return _hb_buffer_add_output_glyph( buffer, glyph_index, 0xFFFF, 0xFFFF ); return _hb_buffer_add_output_glyph (buffer, glyph_index, 0xFFFF, 0xFFFF);
} }
return HB_Err_Ok; return HB_Err_Ok;
} }
HB_INTERNAL HB_UShort HB_INTERNAL HB_UShort
_hb_buffer_allocate_ligid( HB_Buffer buffer ) _hb_buffer_allocate_ligid (HB_Buffer buffer)
{ {
return ++buffer->max_ligID; return ++buffer->max_ligID;
} }

View File

@ -28,67 +28,67 @@
#ifndef HARFBUZZ_BUFFER_H #ifndef HARFBUZZ_BUFFER_H
#define HARFBUZZ_BUFFER_H #define HARFBUZZ_BUFFER_H
#include "harfbuzz-global.h" #include "hb-common.h"
HB_BEGIN_HEADER HB_BEGIN_DECLS();
typedef struct HB_GlyphItemRec_ { typedef struct HB_GlyphItemRec_ {
HB_UInt gindex; hb_codepoint_t gindex;
HB_UInt properties; unsigned int properties;
HB_UInt cluster; unsigned int cluster;
HB_UShort component; unsigned short component;
HB_UShort ligID; unsigned short ligID;
HB_UShort gproperty; unsigned short gproperty;
} HB_GlyphItemRec, *HB_GlyphItem; } HB_GlyphItemRec, *HB_GlyphItem;
typedef struct HB_PositionRec_ { typedef struct HB_PositionRec_ {
HB_Fixed x_pos; hb_position_t x_pos;
HB_Fixed y_pos; hb_position_t y_pos;
HB_Fixed x_advance; hb_position_t x_advance;
HB_Fixed y_advance; hb_position_t y_advance;
HB_UShort back; /* number of glyphs to go back unsigned short back; /* number of glyphs to go back
for drawing current glyph */ for drawing current glyph */
HB_Bool new_advance; /* if set, the advance width values are hb_bool_t new_advance; /* if set, the advance width values are
absolute, i.e., they won't be absolute, i.e., they won't be
added to the original glyph's value added to the original glyph's value
but rather replace them. */ but rather replace them. */
HB_Short cursive_chain; /* character to which this connects, short cursive_chain; /* character to which this connects,
may be positive or negative; used may be positive or negative; used
only internally */ only internally */
} HB_PositionRec, *HB_Position; } HB_PositionRec, *HB_Position;
typedef struct HB_BufferRec_{ typedef struct _hb_buffer_t {
HB_UInt allocated; unsigned int allocated;
HB_UInt in_length; unsigned int in_length;
HB_UInt out_length; unsigned int out_length;
HB_UInt in_pos; unsigned int in_pos;
HB_UInt out_pos; unsigned int out_pos;
HB_Bool separate_out; hb_bool_t separate_out;
HB_GlyphItem in_string; HB_GlyphItem in_string;
HB_GlyphItem out_string; HB_GlyphItem out_string;
HB_GlyphItem alt_string; HB_GlyphItem alt_string;
HB_Position positions; HB_Position positions;
HB_UShort max_ligID; unsigned int max_ligID;
} HB_BufferRec, *HB_Buffer; } HB_BufferRec, *HB_Buffer, hb_buffer_t;
HB_Error hb_buffer_t *
hb_buffer_new( HB_Buffer *buffer ); hb_buffer_new (void);
void void
hb_buffer_free( HB_Buffer buffer ); hb_buffer_free (hb_buffer_t *buffer);
void void
hb_buffer_clear( HB_Buffer buffer ); hb_buffer_clear (hb_buffer_t *buffer);
HB_Error void
hb_buffer_add_glyph( HB_Buffer buffer, hb_buffer_add_glyph (hb_buffer_t *buffer,
HB_UInt glyph_index, hb_codepoint_t glyph_index,
HB_UInt properties, unsigned int properties,
HB_UInt cluster ); unsigned int cluster);
HB_END_HEADER HB_END_DECLS();
#endif /* HARFBUZZ_BUFFER_H */ #endif /* HARFBUZZ_BUFFER_H */

View File

@ -92,9 +92,9 @@ _hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
unsigned int *property); unsigned int *property);
/* XXX */ /* XXX */
HB_Error void
hb_buffer_ensure( HB_Buffer buffer, hb_buffer_ensure (hb_buffer_t *buffer,
HB_UInt size ); unsigned int size);
HB_END_DECLS(); HB_END_DECLS();

View File

@ -582,16 +582,11 @@ hb_ot_layout_position_lookup (hb_ot_layout_t *layout,
static HB_Error static HB_Error
hb_buffer_duplicate_out_buffer( HB_Buffer buffer ) hb_buffer_duplicate_out_buffer( HB_Buffer buffer )
{ {
if ( !buffer->alt_string ) if (!buffer->alt_string)
{ buffer->alt_string = (HB_GlyphItemRec_ *) malloc (buffer->allocated * sizeof (buffer->out_string[0]));
HB_Error error;
if ( ALLOC_ARRAY( buffer->alt_string, buffer->allocated, HB_GlyphItemRec ) )
return error;
}
buffer->out_string = buffer->alt_string; buffer->out_string = buffer->alt_string;
memcpy( buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]) ); memcpy (buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]));
buffer->separate_out = TRUE; buffer->separate_out = TRUE;
return HB_Err_Ok; return HB_Err_Ok;
@ -599,6 +594,7 @@ hb_buffer_duplicate_out_buffer( HB_Buffer buffer )
/* XXX */
HB_INTERNAL HB_Error HB_INTERNAL HB_Error
_hb_buffer_add_output_glyph_ids( HB_Buffer buffer, _hb_buffer_add_output_glyph_ids( HB_Buffer buffer,
HB_UShort num_in, HB_UShort num_in,
@ -612,9 +608,8 @@ _hb_buffer_add_output_glyph_ids( HB_Buffer buffer,
HB_UInt properties; HB_UInt properties;
HB_UInt cluster; HB_UInt cluster;
error = hb_buffer_ensure( buffer, buffer->out_pos + num_out ); hb_buffer_ensure( buffer, buffer->out_pos + num_out );
if ( error ) /* XXX */
return error;
if ( !buffer->separate_out ) if ( !buffer->separate_out )
{ {

View File

@ -28,6 +28,7 @@
#define HB_OT_LAYOUT_H #define HB_OT_LAYOUT_H
#include "hb-common.h" #include "hb-common.h"
#include "harfbuzz-buffer.h"
HB_BEGIN_DECLS(); HB_BEGIN_DECLS();