diff --git a/TODO b/TODO index 08376e339..d206da191 100644 --- a/TODO +++ b/TODO @@ -3,8 +3,6 @@ General fixes: - Fix tt kern on/off -- Remove hb_internal_glyph_info_t, etc - - Remove synthesized GDEF - Remove fixed-size feature/lookup arrays in hb-ot-map diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index 585a82a43..b5ba57d87 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -36,30 +36,13 @@ HB_BEGIN_DECLS #define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF +#define component() var1.u16[0] +#define lig_id() var1.u16[1] +#define gproperty() var2.u32 +#define back() var.u16[0] /* number of glyphs to go back for drawing current glyph */ +#define cursive_chain() var.i16[1] /* character to which this connects, may be positive or negative */ - -typedef struct _hb_internal_glyph_info_t { - hb_codepoint_t codepoint; - hb_mask_t mask; - uint32_t cluster; - uint16_t component; - uint16_t lig_id; - uint32_t gproperty; -} hb_internal_glyph_info_t; - -typedef struct _hb_internal_glyph_position_t { - hb_position_t x_advance; - hb_position_t y_advance; - hb_position_t x_offset; - hb_position_t y_offset; - uint32_t back : 16; /* number of glyphs to go back - for drawing current glyph */ - int32_t cursive_chain : 16; /* character to which this connects, - may be positive or negative */ -} hb_internal_glyph_position_t; - -ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t)); -ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t)); +ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20); ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); typedef struct _hb_segment_properties_t { @@ -137,9 +120,9 @@ struct _hb_buffer_t { unsigned int len; /* Length of ->info and ->pos arrays */ unsigned int out_len; /* Length of ->out array */ - hb_internal_glyph_info_t *info; - hb_internal_glyph_info_t *out_info; - hb_internal_glyph_position_t *pos; + hb_glyph_info_t *info; + hb_glyph_info_t *out_info; + hb_glyph_position_t *pos; /* Other stuff */ diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 930f380ba..849ca2f7d 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -64,8 +64,8 @@ _hb_buffer_enlarge (hb_buffer_t *buffer, unsigned int size) return FALSE; unsigned int new_allocated = buffer->allocated; - hb_internal_glyph_position_t *new_pos; - hb_internal_glyph_info_t *new_info; + hb_glyph_position_t *new_pos; + hb_glyph_info_t *new_info; bool separate_out; separate_out = buffer->out_info != buffer->info; @@ -73,8 +73,8 @@ _hb_buffer_enlarge (hb_buffer_t *buffer, unsigned int size) while (size > new_allocated) new_allocated += (new_allocated >> 1) + 8; - new_pos = (hb_internal_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0])); - new_info = (hb_internal_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0])); + new_pos = (hb_glyph_position_t *) realloc (buffer->pos, new_allocated * sizeof (buffer->pos[0])); + new_info = (hb_glyph_info_t *) realloc (buffer->info, new_allocated * sizeof (buffer->info[0])); if (unlikely (!new_pos || !new_info)) buffer->in_error = TRUE; @@ -85,7 +85,7 @@ _hb_buffer_enlarge (hb_buffer_t *buffer, unsigned int size) if (likely (new_info)) buffer->info = new_info; - buffer->out_info = separate_out ? (hb_internal_glyph_info_t *) buffer->pos : buffer->info; + buffer->out_info = separate_out ? (hb_glyph_info_t *) buffer->pos : buffer->info; if (likely (!buffer->in_error)) buffer->allocated = new_allocated; @@ -107,7 +107,7 @@ _hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size) { assert (buffer->have_output); - buffer->out_info = (hb_internal_glyph_info_t *) buffer->pos; + buffer->out_info = (hb_glyph_info_t *) buffer->pos; memcpy (buffer->out_info, buffer->info, buffer->out_len * sizeof (buffer->out_info[0])); } @@ -243,7 +243,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer, hb_mask_t mask, unsigned int cluster) { - hb_internal_glyph_info_t *glyph; + hb_glyph_info_t *glyph; if (unlikely (!_hb_buffer_ensure (buffer, buffer->len + 1))) return; @@ -251,9 +251,9 @@ hb_buffer_add_glyph (hb_buffer_t *buffer, glyph->codepoint = codepoint; glyph->mask = mask; glyph->cluster = cluster; - glyph->component = 0; - glyph->lig_id = 0; - glyph->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; + glyph->component() = 0; + glyph->lig_id() = 0; + glyph->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; buffer->len++; } @@ -267,7 +267,7 @@ hb_buffer_clear_positions (hb_buffer_t *buffer) if (unlikely (!buffer->pos)) { - buffer->pos = (hb_internal_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0])); + buffer->pos = (hb_glyph_position_t *) calloc (buffer->allocated, sizeof (buffer->pos[0])); return; } @@ -296,11 +296,11 @@ _hb_buffer_swap (hb_buffer_t *buffer) if (buffer->out_info != buffer->info) { - hb_internal_glyph_info_t *tmp_string; + hb_glyph_info_t *tmp_string; tmp_string = buffer->info; buffer->info = buffer->out_info; buffer->out_info = tmp_string; - buffer->pos = (hb_internal_glyph_position_t *) buffer->out_info; + buffer->pos = (hb_glyph_position_t *) buffer->out_info; } tmp = buffer->len; @@ -352,19 +352,19 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer, mask = buffer->info[buffer->i].mask; cluster = buffer->info[buffer->i].cluster; if (component == 0xFFFF) - component = buffer->info[buffer->i].component; + component = buffer->info[buffer->i].component(); if (lig_id == 0xFFFF) - lig_id = buffer->info[buffer->i].lig_id; + lig_id = buffer->info[buffer->i].lig_id(); for (i = 0; i < num_out; i++) { - hb_internal_glyph_info_t *info = &buffer->out_info[buffer->out_len + i]; + hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i]; info->codepoint = glyph_data[i]; info->mask = mask; info->cluster = cluster; - info->component = component; - info->lig_id = lig_id; - info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; + info->component() = component; + info->lig_id() = lig_id; + info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; } buffer->i += num_in; @@ -393,19 +393,19 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer, mask = buffer->info[buffer->i].mask; cluster = buffer->info[buffer->i].cluster; if (component == 0xFFFF) - component = buffer->info[buffer->i].component; + component = buffer->info[buffer->i].component(); if (lig_id == 0xFFFF) - lig_id = buffer->info[buffer->i].lig_id; + lig_id = buffer->info[buffer->i].lig_id(); for (i = 0; i < num_out; i++) { - hb_internal_glyph_info_t *info = &buffer->out_info[buffer->out_len + i]; + hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i]; info->codepoint = hb_be_uint16 (glyph_data_be[i]); info->mask = mask; info->cluster = cluster; - info->component = component; - info->lig_id = lig_id; - info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; + info->component() = component; + info->lig_id() = lig_id; + info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; } buffer->i += num_in; @@ -418,7 +418,7 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer, unsigned short component, unsigned short lig_id) { - hb_internal_glyph_info_t *info; + hb_glyph_info_t *info; if (buffer->out_info != buffer->info) { @@ -431,10 +431,10 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer, info = &buffer->out_info[buffer->out_len]; info->codepoint = glyph_index; if (component != 0xFFFF) - info->component = component; + info->component() = component; if (lig_id != 0xFFFF) - info->lig_id = lig_id; - info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; + info->lig_id() = lig_id; + info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; buffer->i++; buffer->out_len++; @@ -548,7 +548,7 @@ reverse_range (hb_buffer_t *buffer, unsigned int i, j; for (i = start, j = end - 1; i < j; i++, j--) { - hb_internal_glyph_info_t t; + hb_glyph_info_t t; t = buffer->info[i]; buffer->info[i] = buffer->info[j]; @@ -557,7 +557,7 @@ reverse_range (hb_buffer_t *buffer, if (buffer->pos) { for (i = 0, j = end - 1; i < j; i++, j--) { - hb_internal_glyph_position_t t; + hb_glyph_position_t t; t = buffer->pos[i]; buffer->pos[i] = buffer->pos[j]; diff --git a/src/hb-buffer.h b/src/hb-buffer.h index c2dc29fb5..0185415c4 100644 --- a/src/hb-buffer.h +++ b/src/hb-buffer.h @@ -50,7 +50,7 @@ typedef struct _hb_glyph_position_t { hb_position_t y_advance; hb_position_t x_offset; hb_position_t y_offset; - hb_var_int_t var1; + hb_var_int_t var; } hb_glyph_position_t; diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index 187dc98a5..5cf937985 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -87,10 +87,10 @@ struct ValueFormat : USHORT inline unsigned int get_size (void) const { return get_len () * Value::static_size; } - void apply_value (hb_ot_layout_context_t *layout, - const void *base, - const Value *values, - hb_internal_glyph_position_t &glyph_pos) const + void apply_value (hb_ot_layout_context_t *layout, + const void *base, + const Value *values, + hb_glyph_position_t &glyph_pos) const { unsigned int x_ppem, y_ppem; unsigned int format = *this; @@ -399,10 +399,10 @@ struct MarkArray : ArrayOf /* Array of MarkRecords--in Coverage orde mark_anchor.get_anchor (c->layout, c->buffer->info[c->buffer->i].codepoint, &mark_x, &mark_y); glyph_anchor.get_anchor (c->layout, c->buffer->info[glyph_pos].codepoint, &base_x, &base_y); - hb_internal_glyph_position_t &o = c->buffer->pos[c->buffer->i]; + hb_glyph_position_t &o = c->buffer->pos[c->buffer->i]; o.x_offset = base_x - mark_x; o.y_offset = base_y - mark_y; - o.back = c->buffer->i - glyph_pos; + o.back() = c->buffer->i - glyph_pos; c->buffer->i++; return true; @@ -876,7 +876,7 @@ struct CursivePosFormat1 if (c->lookup_flag & LookupFlag::RightToLeft) { - c->buffer->pos[i].cursive_chain = j - i; + c->buffer->pos[i].cursive_chain() = j - i; if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) c->buffer->pos[i].y_offset = entry_y - exit_y; else @@ -884,7 +884,7 @@ struct CursivePosFormat1 } else { - c->buffer->pos[j].cursive_chain = i - j; + c->buffer->pos[j].cursive_chain() = i - j; if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) c->buffer->pos[j].y_offset = exit_y - entry_y; else @@ -1093,9 +1093,9 @@ struct MarkLigPosFormat1 * is identical to the ligature ID of the found ligature. If yes, we * can directly use the component index. If not, we attach the mark * glyph to the last component of the ligature. */ - if (c->buffer->info[j].lig_id && c->buffer->info[j].lig_id == c->buffer->info[c->buffer->i].lig_id && c->buffer->info[c->buffer->i].component) + if (c->buffer->info[j].lig_id() && c->buffer->info[j].lig_id() == c->buffer->info[c->buffer->i].lig_id() && c->buffer->info[c->buffer->i].component()) { - comp_index = c->buffer->info[c->buffer->i].component - 1; + comp_index = c->buffer->info[c->buffer->i].component() - 1; if (comp_index >= comp_count) comp_index = comp_count - 1; } @@ -1198,8 +1198,8 @@ struct MarkMarkPosFormat1 /* Two marks match only if they belong to the same base, or same component * of the same ligature. That is, the component numbers must match, and * if those are non-zero, the ligid number should also match. */ - if ((c->buffer->info[j].component != c->buffer->info[c->buffer->i].component) || - (c->buffer->info[j].component && c->buffer->info[j].lig_id != c->buffer->info[c->buffer->i].lig_id)) + if ((c->buffer->info[j].component() != c->buffer->info[c->buffer->i].component()) || + (c->buffer->info[j].component() && c->buffer->info[j].lig_id() != c->buffer->info[c->buffer->i].lig_id())) return false; unsigned int mark2_index = (this+mark2Coverage) (c->buffer->info[j].codepoint); diff --git a/src/hb-ot-layout-gsub-private.hh b/src/hb-ot-layout-gsub-private.hh index f09b4d26e..c51dd8f16 100644 --- a/src/hb-ot-layout-gsub-private.hh +++ b/src/hb-ot-layout-gsub-private.hh @@ -398,7 +398,7 @@ struct Ligature c->buffer->add_output_glyphs_be16 (i, 1, (const uint16_t *) &ligGlyph, 0, - c->buffer->info[c->buffer->i].lig_id && !c->buffer->info[c->buffer->i].component ? + c->buffer->info[c->buffer->i].lig_id() && !c->buffer->info[c->buffer->i].component() ? 0xFFFF : c->buffer->allocate_lig_id ()); else { diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 4cde08996..a26958d59 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -101,13 +101,13 @@ _hb_ot_layout_set_glyph_class (hb_face_t *face, HB_INTERNAL hb_bool_t _hb_ot_layout_check_glyph_property (hb_face_t *face, - hb_internal_glyph_info_t *ginfo, + hb_glyph_info_t *ginfo, unsigned int lookup_flags, unsigned int *property); HB_INTERNAL hb_bool_t _hb_ot_layout_skip_mark (hb_face_t *face, - hb_internal_glyph_info_t *ginfo, + hb_glyph_info_t *ginfo, unsigned int lookup_flags, unsigned int *property); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index f85bf8696..a705b6670 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -138,15 +138,15 @@ _hb_ot_layout_get_glyph_property (hb_face_t *face, hb_bool_t _hb_ot_layout_check_glyph_property (hb_face_t *face, - hb_internal_glyph_info_t *ginfo, + hb_glyph_info_t *ginfo, unsigned int lookup_flags, unsigned int *property_out) { unsigned int property; - if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) - ginfo->gproperty = _hb_ot_layout_get_glyph_property (face, ginfo->codepoint); - property = ginfo->gproperty; + if (ginfo->gproperty() == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) + ginfo->gproperty() = _hb_ot_layout_get_glyph_property (face, ginfo->codepoint); + property = ginfo->gproperty(); if (property_out) *property_out = property; @@ -177,15 +177,15 @@ _hb_ot_layout_check_glyph_property (hb_face_t *face, hb_bool_t _hb_ot_layout_skip_mark (hb_face_t *face, - hb_internal_glyph_info_t *ginfo, + hb_glyph_info_t *ginfo, unsigned int lookup_flags, unsigned int *property_out) { unsigned int property; - if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) - ginfo->gproperty = _hb_ot_layout_get_glyph_property (face, ginfo->codepoint); - property = ginfo->gproperty; + if (ginfo->gproperty() == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) + ginfo->gproperty() = _hb_ot_layout_get_glyph_property (face, ginfo->codepoint); + property = ginfo->gproperty(); if (property_out) *property_out = property; @@ -606,7 +606,7 @@ hb_ot_layout_position_finish (hb_font_t *font HB_UNUSED, { unsigned int i, j; unsigned int len = hb_buffer_get_length (buffer); - hb_internal_glyph_position_t *pos = (hb_internal_glyph_position_t *) hb_buffer_get_glyph_positions (buffer); + hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer); hb_direction_t direction = buffer->props.direction; /* TODO: Vertical */ @@ -616,35 +616,34 @@ hb_ot_layout_position_finish (hb_font_t *font HB_UNUSED, if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { for (j = 0; j < len; j++) { - if (pos[j].cursive_chain < 0) - pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset; + if (pos[j].cursive_chain() < 0) + pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset; } for (i = len; i > 0; i--) { j = i - 1; - if (pos[j].cursive_chain > 0) - pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset; + if (pos[j].cursive_chain() > 0) + pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset; } } else { for (j = 0; j < len; j++) { - if (pos[j].cursive_chain < 0) - pos[j].x_offset += pos[j + pos[j].cursive_chain].x_offset; + if (pos[j].cursive_chain() < 0) + pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset; } for (i = len; i > 0; i--) { j = i - 1; - if (pos[j].cursive_chain > 0) - pos[j].x_offset += pos[j + pos[j].cursive_chain].x_offset; + if (pos[j].cursive_chain() > 0) + pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset; } } /* Handle attachments */ for (i = 0; i < len; i++) - if (pos[i].back) + if (pos[i].back()) { - unsigned int back = i - pos[i].back; - pos[i].back = 0; + unsigned int back = i - pos[i].back(); pos[i].x_offset += pos[back].x_offset; pos[i].y_offset += pos[back].y_offset; diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 0c485bd47..2401c3606 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -690,16 +690,16 @@ _hb_ot_shape_complex_setup_masks_arabic (hb_ot_shape_context_t *c) unsigned int this_type = get_joining_type (c->buffer->info[i].codepoint, c->buffer->unicode->v.get_general_category (c->buffer->info[i].codepoint)); if (unlikely (this_type == JOINING_TYPE_T)) { - c->buffer->info[i].gproperty = NONE; + c->buffer->info[i].var2.u32 = NONE; continue; } const arabic_state_table_entry *entry = &arabic_state_table[state][this_type]; if (entry->prev_action != NONE) - c->buffer->info[prev].gproperty = entry->prev_action; + c->buffer->info[prev].var2.u32 = entry->prev_action; - c->buffer->info[i].gproperty = entry->curr_action; + c->buffer->info[i].var2.u32 = entry->curr_action; prev = i; state = entry->next_state; @@ -711,7 +711,7 @@ _hb_ot_shape_complex_setup_masks_arabic (hb_ot_shape_context_t *c) mask_array[i] = c->plan->map.get_1_mask (arabic_syriac_features[i]); for (unsigned int i = 0; i < count; i++) - c->buffer->info[i].mask |= mask_array[c->buffer->info[i].gproperty]; + c->buffer->info[i].mask |= mask_array[c->buffer->info[i].var2.u32]; }