noinst_LTLIBRARIES = libharfbuzz-1.la
HBSOURCES = \
+ hb-common.c \
+ hb-common-private.h \
hb-buffer.c \
hb-buffer-private.h \
hb-private.h \
buffer->in_length++;
}
+void
+hb_buffer_set_direction (hb_buffer_t *buffer,
+ hb_direction_t direction)
+
+{
+ buffer->direction = direction;
+}
+
+
/* HarfBuzz-Internal API */
HB_INTERNAL void
HB_BEGIN_DECLS
+typedef enum _hb_direction_t {
+ HB_DIRECTION_LTR,
+ HB_DIRECTION_RTL,
+ HB_DIRECTION_TTB,
+ HB_DIRECTION_BTT
+} hb_direction_t;
+
/* XXX Hide structs? */
typedef struct _hb_glyph_info_t {
hb_glyph_info_t *out_string;
hb_glyph_info_t *alt_string;
hb_glyph_position_t *positions;
+
+ hb_direction_t direction;
unsigned int max_lig_id;
} hb_buffer_t;
unsigned int properties,
unsigned int cluster);
+void
+hb_buffer_set_direction (hb_buffer_t *buffer,
+ hb_direction_t direction);
+
+
HB_END_DECLS
#endif /* HB_BUFFER_H */
typedef int32_t hb_position_t;
typedef int32_t hb_16dot16_t;
+typedef struct _hb_face_t hb_face_t;
+typedef struct _hb_font_t hb_font_t;
+
#endif /* HB_COMMON_H */
friend struct CaretValue;
private:
- inline int get_caret_value (hb_ot_layout_t *layout, hb_codepoint_t glyph_id) const
+ inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
{
/* XXX vertical */
- return layout->gpos_info.x_scale * coordinate / 0x10000;
+ return context->font->x_scale * coordinate / 0x10000;
}
private:
friend struct CaretValue;
private:
- inline int get_caret_value (hb_ot_layout_t *layout, hb_codepoint_t glyph_id) const
+ inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
{
return /* TODO contour point */ 0;
}
{
friend struct CaretValue;
- inline int get_caret_value (hb_ot_layout_t *layout, hb_codepoint_t glyph_id) const
+ inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
{
/* XXX vertical */
- return layout->gpos_info.x_scale * coordinate / 0x10000 +
- (this+deviceTable).get_delta (layout->gpos_info.x_ppem) << 6;
+ return context->font->x_scale * coordinate / 0x10000 +
+ (this+deviceTable).get_delta (context->font->x_ppem) << 6;
}
private:
struct CaretValue
{
/* XXX we need access to a load-contour-point vfunc here */
- int get_caret_value (hb_ot_layout_t *layout, hb_codepoint_t glyph_id) const
+ int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
{
switch (u.format) {
- case 1: return u.format1->get_caret_value (layout, glyph_id);
- case 2: return u.format2->get_caret_value (layout, glyph_id);
- case 3: return u.format3->get_caret_value (layout, glyph_id);
+ case 1: return u.format1->get_caret_value (context, glyph_id);
+ case 2: return u.format2->get_caret_value (context, glyph_id);
+ case 3: return u.format3->get_caret_value (context, glyph_id);
default:return 0;
}
}
struct LigGlyph
{
- inline void get_lig_carets (hb_ot_layout_t *layout,
+ inline void get_lig_carets (hb_ot_layout_context_t *context,
hb_codepoint_t glyph_id,
unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const
unsigned int count = MIN (carets.len, *caret_count);
for (unsigned int i = 0; i < count; i++)
- caret_array[i] = (this+carets[i]).get_caret_value (layout, glyph_id);
+ caret_array[i] = (this+carets[i]).get_caret_value (context, glyph_id);
*caret_count = carets.len;
}
struct LigCaretList
{
- inline bool get_lig_carets (hb_ot_layout_t *layout,
+ inline bool get_lig_carets (hb_ot_layout_context_t *context,
hb_codepoint_t glyph_id,
unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const
return false;
}
const LigGlyph &lig_glyph = this+ligGlyph[index];
- lig_glyph.get_lig_carets (layout, glyph_id, caret_count, caret_array);
+ lig_glyph.get_lig_carets (context, glyph_id, caret_count, caret_array);
return true;
}
{ return (this+attachList).get_attach_points (glyph_id, point_count, point_array); }
inline bool has_lig_carets () const { return ligCaretList != 0; }
- inline bool get_lig_carets (hb_ot_layout_t *layout,
+ inline bool get_lig_carets (hb_ot_layout_context_t *context,
hb_codepoint_t glyph_id,
unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const
- { return (this+ligCaretList).get_lig_carets (layout, glyph_id, caret_count, caret_array); }
+ { return (this+ligCaretList).get_lig_carets (context, glyph_id, caret_count, caret_array); }
inline bool has_mark_sets () const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }
inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
inline unsigned int get_len () const
{ return _hb_popcount32 ((unsigned int) *this); }
- const void apply_value (hb_ot_layout_t *layout,
+ const void apply_value (hb_ot_layout_context_t *context,
const char *base,
const Value *values,
hb_glyph_position_t *glyph_pos) const
};
#endif
- x_scale = layout->gpos_info.x_scale;
- y_scale = layout->gpos_info.y_scale;
+ x_scale = context->font->x_scale;
+ y_scale = context->font->y_scale;
/* design units -> fractional pixel */
if (format & xPlacement)
glyph_pos->x_pos += x_scale * *(SHORT*)values++ / 0x10000;
if (format & yAdvance)
glyph_pos->y_advance += y_scale * *(SHORT*)values++ / 0x10000;
- if (HB_LIKELY (!layout->gpos_info.dvi))
+ if (HB_LIKELY (!context->font->dvi))
{
- x_ppem = layout->gpos_info.x_ppem;
- y_ppem = layout->gpos_info.y_ppem;
+ x_ppem = context->font->x_ppem;
+ y_ppem = context->font->y_ppem;
/* pixel -> fractional pixel */
if (format & xPlaDevice)
glyph_pos->x_pos += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 6;
friend struct Anchor;
private:
- inline void get_anchor (hb_ot_layout_t *layout, hb_codepoint_t glyph_id,
+ inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
- *x = layout->gpos_info.x_scale * xCoordinate / 0x10000;
- *y = layout->gpos_info.y_scale * yCoordinate / 0x10000;
+ *x = context->font->x_scale * xCoordinate / 0x10000;
+ *y = context->font->y_scale * yCoordinate / 0x10000;
}
private:
friend struct Anchor;
private:
- inline void get_anchor (hb_ot_layout_t *layout, hb_codepoint_t glyph_id,
+ inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
/* TODO Contour */
- *x = layout->gpos_info.x_scale * xCoordinate / 0x10000;
- *y = layout->gpos_info.y_scale * yCoordinate / 0x10000;
+ *x = context->font->x_scale * xCoordinate / 0x10000;
+ *y = context->font->y_scale * yCoordinate / 0x10000;
}
private:
friend struct Anchor;
private:
- inline void get_anchor (hb_ot_layout_t *layout, hb_codepoint_t glyph_id,
+ inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
- *x = layout->gpos_info.x_scale * xCoordinate / 0x10000;
- *y = layout->gpos_info.y_scale * yCoordinate / 0x10000;
+ *x = context->font->x_scale * xCoordinate / 0x10000;
+ *y = context->font->y_scale * yCoordinate / 0x10000;
- if (!layout->gpos_info.dvi)
+ if (!context->font->dvi)
{
- *x += (this+xDeviceTable).get_delta (layout->gpos_info.x_ppem) << 6;
- *y += (this+yDeviceTable).get_delta (layout->gpos_info.y_ppem) << 6;
+ *x += (this+xDeviceTable).get_delta (context->font->x_ppem) << 6;
+ *y += (this+yDeviceTable).get_delta (context->font->y_ppem) << 6;
}
}
struct Anchor
{
- inline void get_anchor (hb_ot_layout_t *layout, hb_codepoint_t glyph_id,
+ inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
*x = *y = 0;
switch (u.format) {
- case 1: u.format1->get_anchor (layout, glyph_id, x, y); return;
- case 2: u.format2->get_anchor (layout, glyph_id, x, y); return;
- case 3: u.format3->get_anchor (layout, glyph_id, x, y); return;
- default: return;
+ case 1: u.format1->get_anchor (context, glyph_id, x, y); return;
+ case 2: u.format2->get_anchor (context, glyph_id, x, y); return;
+ case 3: u.format3->get_anchor (context, glyph_id, x, y); return;
+ default: return;
}
}
if (HB_LIKELY (index == NOT_COVERED))
return false;
- valueFormat.apply_value (layout, (const char *) this, values, CURPOSITION ());
+ valueFormat.apply_value (context, (const char *) this, values, CURPOSITION ());
buffer->in_pos++;
return true;
if (HB_LIKELY (index >= valueCount))
return false;
- valueFormat.apply_value (layout, (const char *) this,
+ valueFormat.apply_value (context, (const char *) this,
values + index * valueFormat.get_len (),
CURPOSITION ());
return false;
unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, NULL))
{
if (HB_UNLIKELY (j == end))
return false;
{
if (IN_GLYPH (j) == record->secondGlyph)
{
- valueFormat1.apply_value (layout, (const char *) this, record->values, CURPOSITION ());
- valueFormat2.apply_value (layout, (const char *) this, record->values + len1, POSITION (j));
+ valueFormat1.apply_value (context, (const char *) this, record->values, CURPOSITION ());
+ valueFormat2.apply_value (context, (const char *) this, record->values + len1, POSITION (j));
if (len2)
j++;
buffer->in_pos = j;
return false;
unsigned int j = buffer->in_pos + 1;
- while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, NULL))
{
if (HB_UNLIKELY (j == end))
return false;
return false;
const Value *v = values + record_len * (klass1 * class2Count + klass2);
- valueFormat1.apply_value (layout, (const char *) this, v, CURPOSITION ());
- valueFormat2.apply_value (layout, (const char *) this, v + len1, POSITION (j));
+ valueFormat1.apply_value (context, (const char *) this, v, CURPOSITION ());
+ valueFormat2.apply_value (context, (const char *) this, v + len1, POSITION (j));
if (len2)
j++;
Since horizontal advance widths or vertical advance heights
can be used alone but not together, no ambiguity occurs. */
- struct hb_ot_layout_t::gpos_info_t *gpi = &layout->gpos_info;
+ struct hb_ot_layout_context_t::info_t::gpos_t *gpi = &context->info.gpos;
hb_codepoint_t last_pos = gpi->last;
gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
goto end;
hb_position_t entry_x, entry_y;
- (this+record.entryAnchor).get_anchor (layout, IN_CURGLYPH (), &entry_x, &entry_y);
+ (this+record.entryAnchor).get_anchor (context, IN_CURGLYPH (), &entry_x, &entry_y);
/* TODO vertical */
- if (gpi->r2l)
+ if (buffer->direction == HB_DIRECTION_RTL)
{
POSITION (buffer->in_pos)->x_advance = entry_x - gpi->anchor_x;
POSITION (buffer->in_pos)->new_advance = TRUE;
if (record.exitAnchor)
{
gpi->last = buffer->in_pos;
- (this+record.exitAnchor).get_anchor (layout, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
+ (this+record.exitAnchor).get_anchor (context, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y);
}
buffer->in_pos++;
/* now we search backwards for a non-mark glyph */
unsigned int count = buffer->in_pos;
unsigned int i = 1, j = count - 1;
- while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), LookupFlag::IgnoreMarks, &property))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), LookupFlag::IgnoreMarks, &property))
{
if (HB_UNLIKELY (i == count))
return false;
hb_position_t mark_x, mark_y, base_x, base_y;
- mark_anchor.get_anchor (layout, IN_CURGLYPH (), &mark_x, &mark_y);
+ mark_anchor.get_anchor (context, IN_CURGLYPH (), &mark_x, &mark_y);
unsigned int index = base_index * classCount + mark_class;
- (&base_array+base_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &base_x, &base_y);
+ (&base_array+base_array.matrix[index]).get_anchor (context, IN_GLYPH (j), &base_x, &base_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = base_x - mark_x;
/* now we search backwards for a non-mark glyph */
unsigned int count = buffer->in_pos;
unsigned int i = 1, j = count - 1;
- while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), LookupFlag::IgnoreMarks, &property))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), LookupFlag::IgnoreMarks, &property))
{
if (HB_UNLIKELY (i == count))
return false;
hb_position_t mark_x, mark_y, lig_x, lig_y;
- mark_anchor.get_anchor (layout, IN_CURGLYPH (), &mark_x, &mark_y);
+ mark_anchor.get_anchor (context, IN_CURGLYPH (), &mark_x, &mark_y);
unsigned int index = comp_index * classCount + mark_class;
- (&lig_attach+lig_attach.matrix[index]).get_anchor (layout, IN_GLYPH (j), &lig_x, &lig_y);
+ (&lig_attach+lig_attach.matrix[index]).get_anchor (context, IN_GLYPH (j), &lig_x, &lig_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = lig_x - mark_x;
/* now we search backwards for a suitable mark glyph until a non-mark glyph */
unsigned int count = buffer->in_pos;
unsigned int i = 1, j = count - 1;
- while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, &property))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, &property))
{
if (HB_UNLIKELY (i == count))
return false;
hb_position_t mark1_x, mark1_y, mark2_x, mark2_y;
- mark1_anchor.get_anchor (layout, IN_CURGLYPH (), &mark1_x, &mark1_y);
+ mark1_anchor.get_anchor (context, IN_CURGLYPH (), &mark1_x, &mark1_y);
unsigned int index = mark2_index * classCount + mark1_class;
- (&mark2_array+mark2_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &mark2_x, &mark2_y);
+ (&mark2_array+mark2_array.matrix[index]).get_anchor (context, IN_GLYPH (j), &mark2_x, &mark2_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = mark2_x - mark1_x;
return type;
}
- inline bool apply_once (hb_ot_layout_t *layout,
+ inline bool apply_once (hb_ot_layout_context_t *context,
hb_buffer_t *buffer,
unsigned int context_length,
unsigned int nesting_level_left) const
unsigned int lookup_flag = get_flag ();
unsigned int property;
- if (!_hb_ot_layout_check_glyph_property (layout, IN_CURINFO (), lookup_flag, &property))
+ if (!_hb_ot_layout_check_glyph_property (context->layout, IN_CURINFO (), lookup_flag, &property))
return false;
for (unsigned int i = 0; i < get_subtable_count (); i++)
return false;
}
- bool apply_string (hb_ot_layout_t *layout,
+ bool apply_string (hb_ot_layout_context_t *context,
hb_buffer_t *buffer,
hb_ot_layout_feature_mask_t mask) const
{
if (HB_UNLIKELY (!buffer->in_length))
return false;
- layout->gpos_info.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
+ context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
buffer->in_pos = 0;
while (buffer->in_pos < buffer->in_length)
bool done;
if (~IN_PROPERTIES (buffer->in_pos) & mask)
{
- done = apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL);
+ done = apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL);
ret |= done;
}
else
done = false;
/* Contrary to properties defined in GDEF, user-defined properties
will always stop a possible cursive positioning. */
- layout->gpos_info.last = HB_OT_LAYOUT_GPOS_NO_LAST;
+ context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST;
}
if (!done)
inline const PosLookup& get_lookup (unsigned int i) const
{ return (const PosLookup&) GSUBGPOS::get_lookup (i); }
- inline bool position_lookup (hb_ot_layout_t *layout,
+ inline bool position_lookup (hb_ot_layout_context_t *context,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_ot_layout_feature_mask_t mask) const
- { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
+ { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
};
ASSERT_SIZE (GPOS, 10);
static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
{
- const GPOS &gpos = *(layout->gpos);
+ const GPOS &gpos = *(context->layout->gpos);
const PosLookup &l = gpos.get_lookup (lookup_index);
if (HB_UNLIKELY (nesting_level_left == 0))
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (layout, buffer, context_length, nesting_level_left);
+ return l.apply_once (context, buffer, context_length, nesting_level_left);
}
_hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (layout))
- _hb_ot_layout_set_glyph_property (layout, glyph_id, property);
+ if (_hb_ot_layout_has_new_glyph_classes (context->layout))
+ _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
return true;
}
_hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (layout))
- _hb_ot_layout_set_glyph_property (layout, glyph_id, property);
+ if (_hb_ot_layout_has_new_glyph_classes (context->layout))
+ _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
return true;
}
0xFFFF, 0xFFFF);
/* This is a guess only ... */
- if (_hb_ot_layout_has_new_glyph_classes (layout))
+ if (_hb_ot_layout_has_new_glyph_classes (context->layout))
{
if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
unsigned int count = substitute.len;
for (unsigned int n = 0; n < count; n++)
- _hb_ot_layout_set_glyph_property (layout, substitute[n], property);
+ _hb_ot_layout_set_glyph_property (context->layout, substitute[n], property);
}
return true;
unsigned int alt_index = 0;
/* XXX callback to user to choose alternate
- if (layout->altfunc)
- alt_index = (layout->altfunc)(layout, buffer,
+ if (context->layout->altfunc)
+ alt_index = (context->layout->altfunc)(context->layout, buffer,
buffer->out_pos, glyph_id,
alt_set.len, alt_set.array);
*/
_hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (layout))
- _hb_ot_layout_set_glyph_property (layout, glyph_id, property);
+ if (_hb_ot_layout_has_new_glyph_classes (context->layout))
+ _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
return true;
}
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, &property))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, &property))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
return false;
}
/* This is just a guess ... */
- if (_hb_ot_layout_has_new_glyph_classes (layout))
- hb_ot_layout_set_glyph_class (layout, ligGlyph,
+ if (_hb_ot_layout_has_new_glyph_classes (context->layout))
+ hb_ot_layout_set_glyph_class (context->layout, ligGlyph,
is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
: HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
for ( i = 1; i < count; i++ )
{
- while (_hb_ot_layout_skip_mark (layout, IN_CURINFO (), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_CURINFO (), lookup_flag, NULL))
_hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i - 1, lig_id);
(buffer->in_pos)++;
inline bool is_reverse (void) const
{ return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle); }
- inline bool apply_once (hb_ot_layout_t *layout,
+ inline bool apply_once (hb_ot_layout_context_t *context,
hb_buffer_t *buffer,
unsigned int context_length,
unsigned int nesting_level_left) const
unsigned int lookup_flag = get_flag ();
unsigned int property;
- if (!_hb_ot_layout_check_glyph_property (layout, IN_CURINFO (), lookup_flag, &property))
+ if (!_hb_ot_layout_check_glyph_property (context->layout, IN_CURINFO (), lookup_flag, &property))
return false;
for (unsigned int i = 0; i < get_subtable_count (); i++)
return false;
}
- bool apply_string (hb_ot_layout_t *layout,
+ bool apply_string (hb_ot_layout_context_t *context,
hb_buffer_t *buffer,
hb_ot_layout_feature_mask_t mask) const
{
while (buffer->in_pos < buffer->in_length)
{
if ((~IN_PROPERTIES (buffer->in_pos) & mask) &&
- apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+ apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true;
else
_hb_buffer_next_glyph (buffer);
do
{
if ((~IN_PROPERTIES (buffer->in_pos) & mask) &&
- apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+ apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true;
else
buffer->in_pos--;
inline const SubstLookup& get_lookup (unsigned int i) const
{ return (const SubstLookup&) GSUBGPOS::get_lookup (i); }
- inline bool substitute_lookup (hb_ot_layout_t *layout,
+ inline bool substitute_lookup (hb_ot_layout_context_t *context,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_ot_layout_feature_mask_t mask) const
- { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
+ { return get_lookup (lookup_index).apply_string (context, buffer, mask); }
};
ASSERT_SIZE (GSUB, 10);
static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
{
- const GSUB &gsub = *(layout->gsub);
+ const GSUB &gsub = *(context->layout->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
if (HB_UNLIKELY (nesting_level_left == 0))
if (HB_UNLIKELY (context_length < 1))
return false;
- return l.apply_once (layout, buffer, context_length, nesting_level_left);
+ return l.apply_once (context, buffer, context_length, nesting_level_left);
}
#define APPLY_ARG_DEF \
- hb_ot_layout_t *layout, \
+ hb_ot_layout_context_t *context, \
hb_buffer_t *buffer, \
unsigned int context_length HB_GNUC_UNUSED, \
unsigned int nesting_level_left HB_GNUC_UNUSED, \
unsigned int lookup_flag, \
unsigned int property HB_GNUC_UNUSED /* propety of first glyph */
#define APPLY_ARG \
- layout, \
+ context, \
buffer, \
context_length, \
nesting_level_left, \
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (layout, IN_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_INFO (j), lookup_flag, NULL))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
{
- while (_hb_ot_layout_skip_mark (layout, OUT_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->layout, OUT_INFO (j), lookup_flag, NULL))
{
if (HB_UNLIKELY (j + 1 == count - i))
return false;
for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
{
- while (_hb_ot_layout_skip_mark (layout, OUT_INFO (j), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->layout, OUT_INFO (j), lookup_flag, NULL))
{
if (HB_UNLIKELY (j + count - i == end))
return false;
* Should be easy for in_place ones at least. */
for (unsigned int i = 0; i < count; i++)
{
- while (_hb_ot_layout_skip_mark (layout, IN_CURINFO (), lookup_flag, NULL))
+ while (_hb_ot_layout_skip_mark (context->layout, IN_CURINFO (), lookup_flag, NULL))
{
if (HB_UNLIKELY (buffer->in_pos == end))
return true;
const USHORT input[], /* Array of input values--start with second glyph */
unsigned int lookupCount,
const LookupRecord lookupRecord[],
- ContextLookupContext &context)
+ ContextLookupContext &lookup_context)
{
return match_input (APPLY_ARG,
inputCount, input,
- context.funcs.match, context.match_data,
+ lookup_context.funcs.match, lookup_context.match_data,
&context_length) &&
apply_lookup (APPLY_ARG,
inputCount,
lookupCount, lookupRecord,
- context.funcs.apply);
+ lookup_context.funcs.apply);
}
struct Rule
friend struct RuleSet;
private:
- inline bool apply (APPLY_ARG_DEF, ContextLookupContext &context) const
+ inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
{
const LookupRecord *lookupRecord = (const LookupRecord *)
((const char *) input +
return context_lookup (APPLY_ARG,
inputCount, input,
lookupCount, lookupRecord,
- context);
+ lookup_context);
}
private:
struct RuleSet
{
- inline bool apply (APPLY_ARG_DEF, ContextLookupContext &context) const
+ inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const
{
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
{
- if ((this+rule[i]).apply (APPLY_ARG, context))
+ if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
return true;
}
return false;
const RuleSet &rule_set = this+ruleSet[index];
- struct ContextLookupContext context = {
+ struct ContextLookupContext lookup_context = {
{match_glyph, apply_func},
NULL
};
- return rule_set.apply (APPLY_ARG, context);
+ return rule_set.apply (APPLY_ARG, lookup_context);
}
private:
/* LONGTERMTODO: Old code fetches glyph classes at most once and caches
* them across subrule lookups. Not sure it's worth it.
*/
- struct ContextLookupContext context = {
+ struct ContextLookupContext lookup_context = {
{match_class, apply_func},
(char *) &class_def
};
- return rule_set.apply (APPLY_ARG, context);
+ return rule_set.apply (APPLY_ARG, lookup_context);
}
private:
const LookupRecord *lookupRecord = (const LookupRecord *)
((const char *) coverage +
sizeof (coverage[0]) * glyphCount);
- struct ContextLookupContext context = {
+ struct ContextLookupContext lookup_context = {
{match_coverage, apply_func},
(char *) this
};
return context_lookup (APPLY_ARG,
glyphCount, (const USHORT *) (coverage + 1),
lookupCount, lookupRecord,
- context);
+ lookup_context);
}
private:
const USHORT lookahead[],
unsigned int lookupCount,
const LookupRecord lookupRecord[],
- ChainContextLookupContext &context)
+ ChainContextLookupContext &lookup_context)
{
/* First guess */
if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
unsigned int offset;
return match_backtrack (APPLY_ARG,
backtrackCount, backtrack,
- context.funcs.match, context.match_data[0]) &&
+ lookup_context.funcs.match, lookup_context.match_data[0]) &&
match_input (APPLY_ARG,
inputCount, input,
- context.funcs.match, context.match_data[1],
+ lookup_context.funcs.match, lookup_context.match_data[1],
&offset) &&
match_lookahead (APPLY_ARG,
lookaheadCount, lookahead,
- context.funcs.match, context.match_data[2],
+ lookup_context.funcs.match, lookup_context.match_data[2],
offset) &&
(context_length = offset, true) &&
apply_lookup (APPLY_ARG,
inputCount,
lookupCount, lookupRecord,
- context.funcs.apply);
+ lookup_context.funcs.apply);
}
struct ChainRule
friend struct ChainRuleSet;
private:
- inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &context) const
+ inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
{
const HeadlessArrayOf<USHORT> &input = *(const HeadlessArrayOf<USHORT>*)
((const char *) &backtrack + backtrack.get_size ());
input.len, input.array + 1,
lookahead.len, lookahead.array,
lookup.len, lookup.array,
- context);
+ lookup_context);
return false;
}
struct ChainRuleSet
{
- inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &context) const
+ inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const
{
unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++)
{
- if ((this+rule[i]).apply (APPLY_ARG, context))
+ if ((this+rule[i]).apply (APPLY_ARG, lookup_context))
return true;
}
return false;
const ChainRuleSet &rule_set = this+ruleSet[index];
- struct ChainContextLookupContext context = {
+ struct ChainContextLookupContext lookup_context = {
{match_glyph, apply_func},
{NULL, NULL, NULL}
};
- return rule_set.apply (APPLY_ARG, context);
+ return rule_set.apply (APPLY_ARG, lookup_context);
}
private:
USHORT format; /* Format identifier--format = 1 */
/* LONGTERMTODO: Old code fetches glyph classes at most once and caches
* them across subrule lookups. Not sure it's worth it.
*/
- struct ChainContextLookupContext context = {
+ struct ChainContextLookupContext lookup_context = {
{match_class, apply_func},
{(char *) &backtrack_class_def,
(char *) &input_class_def,
(char *) &lookahead_class_def}
};
- return rule_set.apply (APPLY_ARG, context);
+ return rule_set.apply (APPLY_ARG, lookup_context);
}
private:
((const char *) &input + input.get_size ());
const ArrayOf<LookupRecord> &lookup = *(const ArrayOf<LookupRecord>*)
((const char *) &lookahead + lookahead.get_size ());
- struct ChainContextLookupContext context = {
+ struct ChainContextLookupContext lookup_context = {
{match_coverage, apply_func},
{(char *) this, (char *) this, (char *) this}
};
input.len, (USHORT *) input.array,
lookahead.len, (USHORT *) lookahead.array,
lookup.len, lookup.array,
- context);
+ lookup_context);
return false;
}
unsigned char *klasses;
unsigned int len;
} new_gdef;
+};
- /* TODO full-matrix transformation? */
- struct gpos_info_t
- {
- unsigned int x_ppem, y_ppem;
- hb_16dot16_t x_scale, y_scale;
-
- hb_bool_t dvi;
- hb_bool_t r2l;
+typedef struct _hb_ot_layout_context_t hb_ot_layout_context_t;
+struct _hb_ot_layout_context_t
+{
+ hb_ot_layout_t *layout;
+ hb_face_t *face;
+ hb_font_t *font;
- unsigned int last; /* the last valid glyph--used with cursive positioning */
- hb_position_t anchor_x; /* the coordinates of the anchor point */
- hb_position_t anchor_y; /* of the last valid glyph */
- } gpos_info;
+ union info_t
+ {
+ struct gpos_t
+ {
+ unsigned int last; /* the last valid glyph--used with cursive positioning */
+ hb_position_t anchor_x; /* the coordinates of the anchor point */
+ hb_position_t anchor_y; /* of the last valid glyph */
+ } gpos;
+ } info;
};
free (layout);
}
-void
-hb_ot_layout_set_direction (hb_ot_layout_t *layout,
- hb_bool_t r2l)
-{
- layout->gpos_info.r2l = !!r2l;
-}
-
-void
-hb_ot_layout_set_hinting (hb_ot_layout_t *layout,
- hb_bool_t hinted)
-{
- layout->gpos_info.dvi = !hinted;
-}
-
-void
-hb_ot_layout_set_scale (hb_ot_layout_t *layout,
- hb_16dot16_t x_scale, hb_16dot16_t y_scale)
-{
- layout->gpos_info.x_scale = x_scale;
- layout->gpos_info.y_scale = y_scale;
-}
-
-void
-hb_ot_layout_set_ppem (hb_ot_layout_t *layout,
- unsigned int x_ppem, unsigned int y_ppem)
-{
- layout->gpos_info.x_ppem = x_ppem;
- layout->gpos_info.y_ppem = y_ppem;
-}
-
/*
* GDEF
void
hb_ot_layout_destroy (hb_ot_layout_t *layout);
-/* XXX */
-void
-hb_ot_layout_set_direction (hb_ot_layout_t *layout,
- hb_bool_t r2l);
-
void
hb_ot_layout_set_hinting (hb_ot_layout_t *layout,
hb_bool_t hinted);
#endif
}
+
+struct _hb_face_t
+{
+ struct _hb_ot_layout_t *layout;
+};
+
+struct _hb_font_t
+{
+ hb_face_t *face;
+
+ unsigned int x_ppem, y_ppem;
+ hb_16dot16_t x_scale, y_scale;
+
+ hb_bool_t dvi;
+};
+
#endif /* HB_PRIVATE_H */