Move unicode_funcs to buffer

This commit is contained in:
Behdad Esfahbod 2009-11-03 15:15:07 -05:00
parent d5a8e46099
commit 5ebabecef3
7 changed files with 63 additions and 36 deletions

1
TODO
View File

@ -1,6 +1,5 @@
- cmap14 support in get_glyph callback
- Use size_t in sanitize?
- Move unicode_funcs to buffer
- Buffer error handling?
hb-ot:

View File

@ -30,6 +30,7 @@
#include "hb-private.h"
#include "hb-buffer.h"
#include "hb-unicode-private.h"
HB_BEGIN_DECLS
@ -69,6 +70,14 @@ ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
struct _hb_buffer_t {
hb_reference_count_t ref_count;
/* Information about how the text in the buffer should be treated */
hb_unicode_funcs_t *unicode;
hb_direction_t direction;
/* Buffer contents */
unsigned int allocated;
hb_bool_t have_output; /* weather we have an output buffer going on */
@ -81,7 +90,8 @@ struct _hb_buffer_t {
hb_internal_glyph_info_t *out_string;
hb_internal_glyph_position_t *positions;
hb_direction_t direction;
/* Other stuff */
unsigned int max_lig_id;
};

View File

@ -31,7 +31,9 @@
static hb_buffer_t _hb_buffer_nil = {
HB_REFERENCE_COUNT_INVALID /* ref_count */
HB_REFERENCE_COUNT_INVALID, /* ref_count */
&_hb_unicode_funcs_nil /* unicode */
};
/* Here is how the buffer works internally:
@ -84,6 +86,8 @@ hb_buffer_create (unsigned int pre_alloc_size)
if (pre_alloc_size)
hb_buffer_ensure(buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
return buffer;
}
@ -104,12 +108,45 @@ hb_buffer_destroy (hb_buffer_t *buffer)
{
HB_OBJECT_DO_DESTROY (buffer);
hb_unicode_funcs_destroy (buffer->unicode);
free (buffer->in_string);
free (buffer->positions);
free (buffer);
}
void
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
hb_unicode_funcs_t *unicode)
{
hb_unicode_funcs_reference (unicode);
hb_unicode_funcs_destroy (buffer->unicode);
buffer->unicode = unicode;
}
hb_unicode_funcs_t *
hb_buffer_get_unicode_funcs (hb_buffer_t *buffer)
{
return buffer->unicode;
}
void
hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction)
{
buffer->direction = direction;
}
hb_direction_t
hb_buffer_get_direction (hb_buffer_t *buffer)
{
return buffer->direction;
}
void
hb_buffer_clear (hb_buffer_t *buffer)
{
@ -171,14 +208,6 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
buffer->in_length++;
}
void
hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction)
{
buffer->direction = direction;
}
/* HarfBuzz-Internal API */

View File

@ -29,6 +29,7 @@
#define HB_BUFFER_H
#include "hb-common.h"
#include "hb-unicode.h"
HB_BEGIN_DECLS
@ -80,6 +81,14 @@ void
hb_buffer_destroy (hb_buffer_t *buffer);
void
hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
hb_unicode_funcs_t *unicode_funcs);
hb_unicode_funcs_t *
hb_buffer_get_unicode_funcs (hb_buffer_t *buffer);
void
hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction);
@ -88,6 +97,7 @@ hb_direction_t
hb_buffer_get_direction (hb_buffer_t *buffer);
void
hb_buffer_clear (hb_buffer_t *buffer);

View File

@ -31,7 +31,6 @@
#include "hb-font.h"
#include "hb-unicode-private.h"
#include "hb-ot-layout-private.h"
HB_BEGIN_DECLS
@ -68,8 +67,6 @@ struct _hb_face_t {
hb_destroy_func_t destroy;
void *user_data;
hb_unicode_funcs_t *unicode;
hb_ot_layout_t ot_layout;
};

View File

@ -27,7 +27,6 @@
#include "hb-private.h"
#include "hb-font-private.h"
#include "hb-unicode-private.h"
#include "hb-open-file-private.hh"
#include "hb-blob.h"
@ -138,8 +137,6 @@ static hb_face_t _hb_face_nil = {
NULL, /* destroy */
NULL, /* user_data */
&_hb_unicode_funcs_nil, /* unicode */
{} /* ot_layout */
};
@ -208,23 +205,9 @@ hb_face_destroy (hb_face_t *face)
if (face->destroy)
face->destroy (face->user_data);
hb_unicode_funcs_destroy (face->unicode);
free (face);
}
void
hb_face_set_unicode_funcs (hb_face_t *face,
hb_unicode_funcs_t *unicode)
{
if (HB_OBJECT_IS_INERT (face))
return;
hb_unicode_funcs_reference (unicode);
hb_unicode_funcs_destroy (face->unicode);
face->unicode = unicode;
}
hb_blob_t *
hb_face_get_table (hb_face_t *face,
hb_tag_t tag)

View File

@ -29,7 +29,6 @@
#include "hb-common.h"
#include "hb-blob.h"
#include "hb-unicode.h"
HB_BEGIN_DECLS
@ -61,10 +60,6 @@ hb_face_get_reference_count (hb_face_t *face);
void
hb_face_destroy (hb_face_t *face);
void
hb_face_set_unicode_funcs (hb_face_t *face,
hb_unicode_funcs_t *unicode_funcs);
hb_blob_t *
hb_face_get_table (hb_face_t *face,
hb_tag_t tag);
@ -158,6 +153,10 @@ void
hb_font_set_funcs (hb_font_t *font,
hb_font_funcs_t *klass);
hb_font_funcs_t *
hb_font_get_funcs (hb_font_t *font);
/*
* XXX
* should we decompose this to units_per_EM and font-size?