Misc minor fixes

This commit is contained in:
Behdad Esfahbod 2012-08-08 17:44:19 -04:00
parent 560d68af81
commit 4c8ac4f47e
12 changed files with 72 additions and 226 deletions

View File

@ -14,18 +14,12 @@ else
exit 77
fi
if which c++filt 2>/dev/null >/dev/null; then
cplusplusfilt=c++filt
else
cplusplusfilt=cat
fi
tested=false
for suffix in .so -*.dll; do
for suffix in .so; do
so=`echo .libs/libharfbuzz$suffix`
if test -f "$so"; then
echo "Checking that we are not exposing internal symbols"
if nm $so | grep ' [TW] ' | $cplusplusfilt | grep -v ' T _fini\>\| T _init\>\| T hb_'; then
if nm $so | grep ' [TW] ' | grep -v ' T _fini\>\| T _init\>\| T hb_'; then
echo "Ouch, internal symbols exposed"
stat=1
fi

View File

@ -94,12 +94,12 @@ struct hb_face_t {
hb_bool_t immutable;
hb_reference_table_func_t reference_table;
hb_reference_table_func_t reference_table_func;
void *user_data;
hb_destroy_func_t destroy;
unsigned int index;
unsigned int upem;
mutable unsigned int upem;
struct hb_shaper_data_t shaper_data;
@ -107,6 +107,31 @@ struct hb_face_t {
hb_shape_plan_t *shape_plan;
plan_node_t *next;
} *shape_plans;
inline hb_blob_t *reference_table (hb_tag_t tag) const
{
hb_blob_t *blob;
if (unlikely (!this || !reference_table_func))
return hb_blob_get_empty ();
blob = reference_table_func (/*XXX*/const_cast<hb_face_t *> (this), tag, user_data);
if (unlikely (!blob))
return hb_blob_get_empty ();
return blob;
}
inline unsigned int get_upem (void) const
{
if (unlikely (!upem))
load_upem ();
return upem;
}
private:
HB_INTERNAL void load_upem (void) const;
};
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS

View File

@ -54,7 +54,7 @@ hb_font_get_glyph_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent)
return hb_font_get_glyph (font->parent, unicode, variation_selector, glyph);
return font->parent->get_glyph (unicode, variation_selector, glyph);
*glyph = 0;
return false;
@ -67,7 +67,7 @@ hb_font_get_glyph_h_advance_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent)
return font->parent_scale_x_distance (hb_font_get_glyph_h_advance (font->parent, glyph));
return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph));
return font->x_scale;
}
@ -79,7 +79,7 @@ hb_font_get_glyph_v_advance_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent)
return font->parent_scale_y_distance (hb_font_get_glyph_v_advance (font->parent, glyph));
return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph));
return font->y_scale;
}
@ -93,7 +93,7 @@ hb_font_get_glyph_h_origin_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_h_origin (font->parent, glyph, x, y);
hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y);
if (ret)
font->parent_scale_position (x, y);
return ret;
@ -112,7 +112,7 @@ hb_font_get_glyph_v_origin_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_v_origin (font->parent, glyph, x, y);
hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y);
if (ret)
font->parent_scale_position (x, y);
return ret;
@ -130,7 +130,7 @@ hb_font_get_glyph_h_kerning_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent)
return font->parent_scale_x_distance (hb_font_get_glyph_h_kerning (font->parent, left_glyph, right_glyph));
return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph));
return 0;
}
@ -143,7 +143,7 @@ hb_font_get_glyph_v_kerning_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent)
return font->parent_scale_y_distance (hb_font_get_glyph_v_kerning (font->parent, top_glyph, bottom_glyph));
return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph));
return 0;
}
@ -156,9 +156,7 @@ hb_font_get_glyph_extents_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_extents (font->parent,
glyph,
extents);
hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents);
if (ret) {
font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
font->parent_scale_distance (&extents->width, &extents->height);
@ -180,7 +178,7 @@ hb_font_get_glyph_contour_point_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_contour_point (font->parent, glyph, point_index, x, y);
hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y);
if (ret)
font->parent_scale_position (x, y);
return ret;
@ -198,7 +196,7 @@ hb_font_get_glyph_name_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent)
return hb_font_get_glyph_name (font->parent, glyph, name, size);
return font->parent->get_glyph_name (glyph, name, size);
if (size) *name = '\0';
return false;
@ -212,7 +210,7 @@ hb_font_get_glyph_from_name_nil (hb_font_t *font,
void *user_data HB_UNUSED)
{
if (font->parent)
return hb_font_get_glyph_from_name (font->parent, name, len, glyph);
return font->parent->get_glyph_from_name (name, len, glyph);
*glyph = 0;
return false;
@ -516,7 +514,7 @@ static const hb_face_t _hb_face_nil = {
true, /* immutable */
NULL, /* reference_table */
NULL, /* reference_table_func */
NULL, /* user_data */
NULL, /* destroy */
@ -534,19 +532,19 @@ static const hb_face_t _hb_face_nil = {
hb_face_t *
hb_face_create_for_tables (hb_reference_table_func_t reference_table,
hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
void *user_data,
hb_destroy_func_t destroy)
{
hb_face_t *face;
if (!reference_table || !(face = hb_object_create<hb_face_t> ())) {
if (!reference_table_func || !(face = hb_object_create<hb_face_t> ())) {
if (destroy)
destroy (user_data);
return hb_face_get_empty ();
}
face->reference_table = reference_table;
face->reference_table_func = reference_table_func;
face->user_data = user_data;
face->destroy = destroy;
@ -697,22 +695,13 @@ hb_blob_t *
hb_face_reference_table (hb_face_t *face,
hb_tag_t tag)
{
hb_blob_t *blob;
if (unlikely (!face || !face->reference_table))
return hb_blob_get_empty ();
blob = face->reference_table (face, tag, face->user_data);
if (unlikely (!blob))
return hb_blob_get_empty ();
return blob;
return face->reference_table (tag);
}
hb_blob_t *
hb_face_reference_blob (hb_face_t *face)
{
return hb_face_reference_table (face, HB_TAG_NONE);
return face->reference_table (HB_TAG_NONE);
}
void
@ -744,13 +733,17 @@ hb_face_set_upem (hb_face_t *face,
unsigned int
hb_face_get_upem (hb_face_t *face)
{
if (unlikely (!face->upem)) {
hb_blob_t *head_blob = Sanitizer<head>::sanitize (hb_face_reference_table (face, HB_OT_TAG_head));
const head *head_table = Sanitizer<head>::lock_instance (head_blob);
face->upem = head_table->get_upem ();
hb_blob_destroy (head_blob);
}
return face->upem;
return face->get_upem ();
}
void
hb_face_t::load_upem (void) const
{
hb_blob_t *head_blob = Sanitizer<head>::sanitize (reference_table (HB_OT_TAG_head));
const head *head_table = Sanitizer<head>::lock_instance (head_blob);
upem = head_table->get_upem ();
hb_blob_destroy (head_blob);
}

View File

@ -52,7 +52,7 @@ typedef hb_blob_t * (*hb_reference_table_func_t) (hb_face_t *face, hb_tag_t tag
/* calls destroy() when not needing user_data anymore */
hb_face_t *
hb_face_create_for_tables (hb_reference_table_func_t reference_table,
hb_face_create_for_tables (hb_reference_table_func_t reference_table_func,
void *user_data,
hb_destroy_func_t destroy);

View File

@ -73,7 +73,7 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s
if (unlikely (!blob))
{
blob = hb_face_reference_table (face_data->face, tag);
blob = face_data->face->reference_table (tag);
hb_graphite2_tablelist_t *p = (hb_graphite2_tablelist_t *) calloc (1, sizeof (hb_graphite2_tablelist_t));
if (unlikely (!p)) {
@ -98,7 +98,7 @@ static const void *hb_graphite2_get_table (const void *data, unsigned int tag, s
hb_graphite2_shaper_face_data_t *
_hb_graphite2_shaper_face_data_create (hb_face_t *face)
{
hb_blob_t *silf_blob = hb_face_reference_table (face, HB_GRAPHITE2_TAG_SILF);
hb_blob_t *silf_blob = face->reference_table (HB_GRAPHITE2_TAG_SILF);
/* Umm, we just reference the table to check whether it exists.
* Maybe add better API for this? */
if (!hb_blob_get_length (silf_blob))

View File

@ -188,7 +188,7 @@ static HB_Error
table_func (void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length)
{
hb_face_t *face = (hb_face_t *) font;
hb_blob_t *blob = hb_face_reference_table (face, (hb_tag_t) tag);
hb_blob_t *blob = face->reference_table ((hb_tag_t) tag);
unsigned int capacity = *length;
*length = hb_blob_get_length (blob);
memcpy (buffer, hb_blob_get_data (blob, NULL), MIN (capacity, *length));

View File

@ -49,13 +49,13 @@ _hb_ot_layout_create (hb_face_t *face)
if (unlikely (!layout))
return NULL;
layout->gdef_blob = Sanitizer<GDEF>::sanitize (hb_face_reference_table (face, HB_OT_TAG_GDEF));
layout->gdef_blob = Sanitizer<GDEF>::sanitize (face->reference_table (HB_OT_TAG_GDEF));
layout->gdef = Sanitizer<GDEF>::lock_instance (layout->gdef_blob);
layout->gsub_blob = Sanitizer<GSUB>::sanitize (hb_face_reference_table (face, HB_OT_TAG_GSUB));
layout->gsub_blob = Sanitizer<GSUB>::sanitize (face->reference_table (HB_OT_TAG_GSUB));
layout->gsub = Sanitizer<GSUB>::lock_instance (layout->gsub_blob);
layout->gpos_blob = Sanitizer<GPOS>::sanitize (hb_face_reference_table (face, HB_OT_TAG_GPOS));
layout->gpos_blob = Sanitizer<GPOS>::sanitize (face->reference_table (HB_OT_TAG_GPOS));
layout->gpos = Sanitizer<GPOS>::lock_instance (layout->gpos_blob);
layout->gsub_lookup_count = layout->gsub->get_lookup_count ();

View File

@ -109,9 +109,8 @@ position_mark (const hb_ot_shape_plan_t *plan,
unsigned int combining_class)
{
hb_glyph_extents_t mark_extents;
if (!hb_font_get_glyph_extents (font,
buffer->info[i].codepoint,
&mark_extents))
if (!font->get_glyph_extents (buffer->info[i].codepoint,
&mark_extents))
return;
hb_position_t y_gap = font->y_scale / 16;
@ -193,9 +192,8 @@ position_around_base (const hb_ot_shape_plan_t *plan,
unsigned int end)
{
hb_glyph_extents_t base_extents;
if (!hb_font_get_glyph_extents (font,
buffer->info[base].codepoint,
&base_extents))
if (!font->get_glyph_extents (buffer->info[base].codepoint,
&base_extents))
{
/* If extents don't work, zero marks and go home. */
zero_mark_advances (buffer, base + 1, end);

View File

@ -578,7 +578,7 @@ hb_ot_shape_glyphs_closure (hb_font_t *font,
* if that's what they desire. */
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
hb_set_add (glyphs, buffer->info[i].codepoint);
glyphs->add (buffer->info[i].codepoint);
/* And find transitive closure. */
hb_set_t copy;

View File

@ -37,7 +37,7 @@
#undef HB_SHAPER_IMPLEMENT
void
static void
hb_shape_plan_plan (hb_shape_plan_t *shape_plan,
const hb_feature_t *user_features,
unsigned int num_user_features,

View File

@ -47,7 +47,7 @@ hb_shape_plan_create (hb_face_t *face,
unsigned int num_user_features,
const char * const *shaper_list);
hb_shape_plan_t *
HB_INTERNAL hb_shape_plan_t *
hb_shape_plan_create_cached (hb_face_t *face,
const hb_segment_properties_t *props,
const hb_feature_t *user_features,

View File

@ -51,7 +51,7 @@ _hb_tt_font_create (hb_font_t *font)
/* TODO Remove this object altogether */
hb_tt_font_t *tt = (hb_tt_font_t *) calloc (1, sizeof (hb_tt_font_t));
tt->hhea_blob = Sanitizer<hhea>::sanitize (hb_face_reference_table (font->face, HB_OT_TAG_hhea));
tt->hhea_blob = Sanitizer<hhea>::sanitize (font->face->reference_table (HB_OT_TAG_hhea));
tt->hhea = Sanitizer<hhea>::lock_instance (tt->hhea_blob);
return tt;
@ -76,168 +76,4 @@ _get_hhea (hb_face_t *face)
* hb_tt_font_funcs_t
*/
static hb_bool_t
hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t unicode,
hb_codepoint_t variation_selector,
hb_codepoint_t *glyph,
void *user_data HB_UNUSED)
{
if (font->parent)
return hb_font_get_glyph (font->parent, unicode, variation_selector, glyph);
*glyph = 0;
return false;
}
static hb_position_t
hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
void *user_data HB_UNUSED)
{
if (font->parent)
return font->parent_scale_x_distance (hb_font_get_glyph_h_advance (font->parent, glyph));
return font->x_scale;
}
static hb_position_t
hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
void *user_data HB_UNUSED)
{
if (font->parent)
return font->parent_scale_y_distance (hb_font_get_glyph_v_advance (font->parent, glyph));
return font->y_scale;
}
static hb_bool_t
hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
hb_position_t *x,
hb_position_t *y,
void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_h_origin (font->parent,
glyph,
x, y);
if (ret)
font->parent_scale_position (x, y);
return ret;
}
*x = *y = 0;
return false;
}
static hb_bool_t
hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
hb_position_t *x,
hb_position_t *y,
void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_v_origin (font->parent,
glyph,
x, y);
if (ret)
font->parent_scale_position (x, y);
return ret;
}
*x = *y = 0;
return false;
}
static hb_position_t
hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t left_glyph,
hb_codepoint_t right_glyph,
void *user_data HB_UNUSED)
{
if (font->parent)
return font->parent_scale_x_distance (hb_font_get_glyph_h_kerning (font->parent, left_glyph, right_glyph));
return 0;
}
static hb_position_t
hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t top_glyph,
hb_codepoint_t bottom_glyph,
void *user_data HB_UNUSED)
{
if (font->parent)
return font->parent_scale_y_distance (hb_font_get_glyph_v_kerning (font->parent, top_glyph, bottom_glyph));
return 0;
}
static hb_bool_t
hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
hb_glyph_extents_t *extents,
void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_extents (font->parent,
glyph,
extents);
if (ret) {
font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
font->parent_scale_distance (&extents->width, &extents->height);
}
return ret;
}
memset (extents, 0, sizeof (*extents));
return false;
}
static hb_bool_t
hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
unsigned int point_index,
hb_position_t *x,
hb_position_t *y,
void *user_data HB_UNUSED)
{
if (font->parent) {
hb_bool_t ret = hb_font_get_glyph_contour_point (font->parent,
glyph, point_index,
x, y);
if (ret)
font->parent_scale_position (x, y);
return ret;
}
*x = *y = 0;
return false;
}
static hb_font_funcs_t _hb_font_funcs_nil = {
HB_OBJECT_HEADER_STATIC,
true, /* immutable */
{
#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil,
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_FONT_FUNC_IMPLEMENT
}
};
#endif