提交 55520d2a 编写于 作者: B Behdad Esfahbod

XX

上级 f53d434b
...@@ -11,6 +11,8 @@ CXX = gcc -g -O2 -fno-rtti -fno-exceptions -Wabi -Wpadded -Wcast-align ...@@ -11,6 +11,8 @@ CXX = gcc -g -O2 -fno-rtti -fno-exceptions -Wabi -Wpadded -Wcast-align
noinst_LTLIBRARIES = libharfbuzz-1.la noinst_LTLIBRARIES = libharfbuzz-1.la
HBSOURCES = \ HBSOURCES = \
hb-common.c \
hb-common-private.h \
hb-buffer.c \ hb-buffer.c \
hb-buffer-private.h \ hb-buffer-private.h \
hb-private.h \ hb-private.h \
......
...@@ -163,6 +163,15 @@ hb_buffer_add_glyph (hb_buffer_t *buffer, ...@@ -163,6 +163,15 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
buffer->in_length++; buffer->in_length++;
} }
void
hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction)
{
buffer->direction = direction;
}
/* HarfBuzz-Internal API */ /* HarfBuzz-Internal API */
HB_INTERNAL void HB_INTERNAL void
......
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
HB_BEGIN_DECLS 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? */ /* XXX Hide structs? */
typedef struct _hb_glyph_info_t { typedef struct _hb_glyph_info_t {
...@@ -72,6 +79,8 @@ typedef struct _hb_buffer_t { ...@@ -72,6 +79,8 @@ typedef struct _hb_buffer_t {
hb_glyph_info_t *out_string; hb_glyph_info_t *out_string;
hb_glyph_info_t *alt_string; hb_glyph_info_t *alt_string;
hb_glyph_position_t *positions; hb_glyph_position_t *positions;
hb_direction_t direction;
unsigned int max_lig_id; unsigned int max_lig_id;
} hb_buffer_t; } hb_buffer_t;
...@@ -90,6 +99,11 @@ hb_buffer_add_glyph (hb_buffer_t *buffer, ...@@ -90,6 +99,11 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
unsigned int properties, unsigned int properties,
unsigned int cluster); unsigned int cluster);
void
hb_buffer_set_direction (hb_buffer_t *buffer,
hb_direction_t direction);
HB_END_DECLS HB_END_DECLS
#endif /* HB_BUFFER_H */ #endif /* HB_BUFFER_H */
...@@ -50,4 +50,7 @@ typedef uint32_t hb_codepoint_t; ...@@ -50,4 +50,7 @@ typedef uint32_t hb_codepoint_t;
typedef int32_t hb_position_t; typedef int32_t hb_position_t;
typedef int32_t hb_16dot16_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 */ #endif /* HB_COMMON_H */
...@@ -90,10 +90,10 @@ struct CaretValueFormat1 ...@@ -90,10 +90,10 @@ struct CaretValueFormat1
friend struct CaretValue; friend struct CaretValue;
private: 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 */ /* XXX vertical */
return layout->gpos_info.x_scale * coordinate / 0x10000; return context->font->x_scale * coordinate / 0x10000;
} }
private: private:
...@@ -107,7 +107,7 @@ struct CaretValueFormat2 ...@@ -107,7 +107,7 @@ struct CaretValueFormat2
friend struct CaretValue; friend struct CaretValue;
private: 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; return /* TODO contour point */ 0;
} }
...@@ -122,11 +122,11 @@ struct CaretValueFormat3 ...@@ -122,11 +122,11 @@ struct CaretValueFormat3
{ {
friend struct CaretValue; 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 */ /* XXX vertical */
return layout->gpos_info.x_scale * coordinate / 0x10000 + return context->font->x_scale * coordinate / 0x10000 +
(this+deviceTable).get_delta (layout->gpos_info.x_ppem) << 6; (this+deviceTable).get_delta (context->font->x_ppem) << 6;
} }
private: private:
...@@ -142,12 +142,12 @@ ASSERT_SIZE (CaretValueFormat3, 6); ...@@ -142,12 +142,12 @@ ASSERT_SIZE (CaretValueFormat3, 6);
struct CaretValue struct CaretValue
{ {
/* XXX we need access to a load-contour-point vfunc here */ /* 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) { switch (u.format) {
case 1: return u.format1->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 (layout, glyph_id); case 2: return u.format2->get_caret_value (context, glyph_id);
case 3: return u.format3->get_caret_value (layout, glyph_id); case 3: return u.format3->get_caret_value (context, glyph_id);
default:return 0; default:return 0;
} }
} }
...@@ -164,7 +164,7 @@ ASSERT_SIZE (CaretValue, 2); ...@@ -164,7 +164,7 @@ ASSERT_SIZE (CaretValue, 2);
struct LigGlyph 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, hb_codepoint_t glyph_id,
unsigned int *caret_count /* IN/OUT */, unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const int *caret_array /* OUT */) const
...@@ -172,7 +172,7 @@ struct LigGlyph ...@@ -172,7 +172,7 @@ struct LigGlyph
unsigned int count = MIN (carets.len, *caret_count); unsigned int count = MIN (carets.len, *caret_count);
for (unsigned int i = 0; i < count; i++) 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; *caret_count = carets.len;
} }
...@@ -187,7 +187,7 @@ ASSERT_SIZE (LigGlyph, 2); ...@@ -187,7 +187,7 @@ ASSERT_SIZE (LigGlyph, 2);
struct LigCaretList 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, hb_codepoint_t glyph_id,
unsigned int *caret_count /* IN/OUT */, unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const int *caret_array /* OUT */) const
...@@ -199,7 +199,7 @@ struct LigCaretList ...@@ -199,7 +199,7 @@ struct LigCaretList
return false; return false;
} }
const LigGlyph &lig_glyph = this+ligGlyph[index]; 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 true;
} }
...@@ -279,11 +279,11 @@ struct GDEF ...@@ -279,11 +279,11 @@ struct GDEF
{ return (this+attachList).get_attach_points (glyph_id, point_count, point_array); } { return (this+attachList).get_attach_points (glyph_id, point_count, point_array); }
inline bool has_lig_carets () const { return ligCaretList != 0; } 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, hb_codepoint_t glyph_id,
unsigned int *caret_count /* IN/OUT */, unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) const 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 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 bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
......
...@@ -55,7 +55,7 @@ struct ValueFormat : USHORT ...@@ -55,7 +55,7 @@ struct ValueFormat : USHORT
inline unsigned int get_len () const inline unsigned int get_len () const
{ return _hb_popcount32 ((unsigned int) *this); } { 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 char *base,
const Value *values, const Value *values,
hb_glyph_position_t *glyph_pos) const hb_glyph_position_t *glyph_pos) const
...@@ -97,8 +97,8 @@ struct ValueRecord { ...@@ -97,8 +97,8 @@ struct ValueRecord {
}; };
#endif #endif
x_scale = layout->gpos_info.x_scale; x_scale = context->font->x_scale;
y_scale = layout->gpos_info.y_scale; y_scale = context->font->y_scale;
/* design units -> fractional pixel */ /* design units -> fractional pixel */
if (format & xPlacement) if (format & xPlacement)
glyph_pos->x_pos += x_scale * *(SHORT*)values++ / 0x10000; glyph_pos->x_pos += x_scale * *(SHORT*)values++ / 0x10000;
...@@ -109,10 +109,10 @@ struct ValueRecord { ...@@ -109,10 +109,10 @@ struct ValueRecord {
if (format & yAdvance) if (format & yAdvance)
glyph_pos->y_advance += y_scale * *(SHORT*)values++ / 0x10000; 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; x_ppem = context->font->x_ppem;
y_ppem = layout->gpos_info.y_ppem; y_ppem = context->font->y_ppem;
/* pixel -> fractional pixel */ /* pixel -> fractional pixel */
if (format & xPlaDevice) if (format & xPlaDevice)
glyph_pos->x_pos += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 6; glyph_pos->x_pos += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 6;
...@@ -133,11 +133,11 @@ struct AnchorFormat1 ...@@ -133,11 +133,11 @@ struct AnchorFormat1
friend struct Anchor; friend struct Anchor;
private: 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 hb_position_t *x, hb_position_t *y) const
{ {
*x = layout->gpos_info.x_scale * xCoordinate / 0x10000; *x = context->font->x_scale * xCoordinate / 0x10000;
*y = layout->gpos_info.y_scale * yCoordinate / 0x10000; *y = context->font->y_scale * yCoordinate / 0x10000;
} }
private: private:
...@@ -152,12 +152,12 @@ struct AnchorFormat2 ...@@ -152,12 +152,12 @@ struct AnchorFormat2
friend struct Anchor; friend struct Anchor;
private: 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 hb_position_t *x, hb_position_t *y) const
{ {
/* TODO Contour */ /* TODO Contour */
*x = layout->gpos_info.x_scale * xCoordinate / 0x10000; *x = context->font->x_scale * xCoordinate / 0x10000;
*y = layout->gpos_info.y_scale * yCoordinate / 0x10000; *y = context->font->y_scale * yCoordinate / 0x10000;
} }
private: private:
...@@ -173,16 +173,16 @@ struct AnchorFormat3 ...@@ -173,16 +173,16 @@ struct AnchorFormat3
friend struct Anchor; friend struct Anchor;
private: 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 hb_position_t *x, hb_position_t *y) const
{ {
*x = layout->gpos_info.x_scale * xCoordinate / 0x10000; *x = context->font->x_scale * xCoordinate / 0x10000;
*y = layout->gpos_info.y_scale * yCoordinate / 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; *x += (this+xDeviceTable).get_delta (context->font->x_ppem) << 6;
*y += (this+yDeviceTable).get_delta (layout->gpos_info.y_ppem) << 6; *y += (this+yDeviceTable).get_delta (context->font->y_ppem) << 6;
} }
} }
...@@ -203,14 +203,14 @@ ASSERT_SIZE (AnchorFormat3, 10); ...@@ -203,14 +203,14 @@ ASSERT_SIZE (AnchorFormat3, 10);
struct Anchor 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 hb_position_t *x, hb_position_t *y) const
{ {
*x = *y = 0; *x = *y = 0;
switch (u.format) { switch (u.format) {
case 1: u.format1->get_anchor (layout, glyph_id, x, y); return; case 1: u.format1->get_anchor (context, glyph_id, x, y); return;
case 2: u.format2->get_anchor (layout, glyph_id, x, y); return; case 2: u.format2->get_anchor (context, glyph_id, x, y); return;
case 3: u.format3->get_anchor (layout, glyph_id, x, y); return; case 3: u.format3->get_anchor (context, glyph_id, x, y); return;
default: return; default: return;
} }
} }
...@@ -263,7 +263,7 @@ struct SinglePosFormat1 ...@@ -263,7 +263,7 @@ struct SinglePosFormat1
if (HB_LIKELY (index == NOT_COVERED)) if (HB_LIKELY (index == NOT_COVERED))
return false; return false;
valueFormat.apply_value (layout, (const char *) this, values, CURPOSITION ()); valueFormat.apply_value (context, (const char *) this, values, CURPOSITION ());
buffer->in_pos++; buffer->in_pos++;
return true; return true;
...@@ -296,7 +296,7 @@ struct SinglePosFormat2 ...@@ -296,7 +296,7 @@ struct SinglePosFormat2
if (HB_LIKELY (index >= valueCount)) if (HB_LIKELY (index >= valueCount))
return false; return false;
valueFormat.apply_value (layout, (const char *) this, valueFormat.apply_value (context, (const char *) this,
values + index * valueFormat.get_len (), values + index * valueFormat.get_len (),
CURPOSITION ()); CURPOSITION ());
...@@ -382,7 +382,7 @@ struct PairPosFormat1 ...@@ -382,7 +382,7 @@ struct PairPosFormat1
return false; return false;
unsigned int j = buffer->in_pos + 1; 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)) if (HB_UNLIKELY (j == end))
return false; return false;
...@@ -401,8 +401,8 @@ struct PairPosFormat1 ...@@ -401,8 +401,8 @@ struct PairPosFormat1
{ {
if (IN_GLYPH (j) == record->secondGlyph) if (IN_GLYPH (j) == record->secondGlyph)
{ {
valueFormat1.apply_value (layout, (const char *) this, record->values, CURPOSITION ()); valueFormat1.apply_value (context, (const char *) this, record->values, CURPOSITION ());
valueFormat2.apply_value (layout, (const char *) this, record->values + len1, POSITION (j)); valueFormat2.apply_value (context, (const char *) this, record->values + len1, POSITION (j));
if (len2) if (len2)
j++; j++;
buffer->in_pos = j; buffer->in_pos = j;
...@@ -447,7 +447,7 @@ struct PairPosFormat2 ...@@ -447,7 +447,7 @@ struct PairPosFormat2
return false; return false;
unsigned int j = buffer->in_pos + 1; 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)) if (HB_UNLIKELY (j == end))
return false; return false;
...@@ -464,8 +464,8 @@ struct PairPosFormat2 ...@@ -464,8 +464,8 @@ struct PairPosFormat2
return false; return false;
const Value *v = values + record_len * (klass1 * class2Count + klass2); const Value *v = values + record_len * (klass1 * class2Count + klass2);
valueFormat1.apply_value (layout, (const char *) this, v, CURPOSITION ()); valueFormat1.apply_value (context, (const char *) this, v, CURPOSITION ());
valueFormat2.apply_value (layout, (const char *) this, v + len1, POSITION (j)); valueFormat2.apply_value (context, (const char *) this, v + len1, POSITION (j));
if (len2) if (len2)
j++; j++;
...@@ -665,7 +665,7 @@ struct CursivePosFormat1 ...@@ -665,7 +665,7 @@ struct CursivePosFormat1
Since horizontal advance widths or vertical advance heights Since horizontal advance widths or vertical advance heights
can be used alone but not together, no ambiguity occurs. */ 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; hb_codepoint_t last_pos = gpi->last;
gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST; gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
...@@ -683,11 +683,11 @@ struct CursivePosFormat1 ...@@ -683,11 +683,11 @@ struct CursivePosFormat1
goto end; goto end;
hb_position_t entry_x, entry_y; 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 */ /* 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)->x_advance = entry_x - gpi->anchor_x;
POSITION (buffer->in_pos)->new_advance = TRUE; POSITION (buffer->in_pos)->new_advance = TRUE;
...@@ -713,7 +713,7 @@ struct CursivePosFormat1 ...@@ -713,7 +713,7 @@ struct CursivePosFormat1
if (record.exitAnchor) if (record.exitAnchor)
{ {
gpi->last = buffer->in_pos; 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++; buffer->in_pos++;
...@@ -782,7 +782,7 @@ struct MarkBasePosFormat1 ...@@ -782,7 +782,7 @@ struct MarkBasePosFormat1
/* now we search backwards for a non-mark glyph */ /* now we search backwards for a non-mark glyph */
unsigned int count = buffer->in_pos; unsigned int count = buffer->in_pos;
unsigned int i = 1, j = count - 1; 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)) if (HB_UNLIKELY (i == count))
return false; return false;
...@@ -809,9 +809,9 @@ struct MarkBasePosFormat1 ...@@ -809,9 +809,9 @@ struct MarkBasePosFormat1
hb_position_t mark_x, mark_y, base_x, base_y; 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; 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); hb_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = base_x - mark_x; o->x_pos = base_x - mark_x;
...@@ -900,7 +900,7 @@ struct MarkLigPosFormat1 ...@@ -900,7 +900,7 @@ struct MarkLigPosFormat1
/* now we search backwards for a non-mark glyph */ /* now we search backwards for a non-mark glyph */
unsigned int count = buffer->in_pos; unsigned int count = buffer->in_pos;
unsigned int i = 1, j = count - 1; 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)) if (HB_UNLIKELY (i == count))
return false; return false;
...@@ -946,9 +946,9 @@ struct MarkLigPosFormat1 ...@@ -946,9 +946,9 @@ struct MarkLigPosFormat1
hb_position_t mark_x, mark_y, lig_x, lig_y; 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; 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); hb_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = lig_x - mark_x; o->x_pos = lig_x - mark_x;
...@@ -1031,7 +1031,7 @@ struct MarkMarkPosFormat1 ...@@ -1031,7 +1031,7 @@ struct MarkMarkPosFormat1
/* now we search backwards for a suitable mark glyph until a non-mark glyph */ /* now we search backwards for a suitable mark glyph until a non-mark glyph */
unsigned int count = buffer->in_pos; unsigned int count = buffer->in_pos;
unsigned int i = 1, j = count - 1; 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)) if (HB_UNLIKELY (i == count))
return false; return false;
...@@ -1061,9 +1061,9 @@ struct MarkMarkPosFormat1 ...@@ -1061,9 +1061,9 @@ struct MarkMarkPosFormat1
hb_position_t mark1_x, mark1_y, mark2_x, mark2_y; 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; 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); hb_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = mark2_x - mark1_x; o->x_pos = mark2_x - mark1_x;
...@@ -1231,7 +1231,7 @@ struct PosLookup : Lookup ...@@ -1231,7 +1231,7 @@ struct PosLookup : Lookup
return type; 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, hb_buffer_t *buffer,
unsigned int context_length, unsigned int context_length,
unsigned int nesting_level_left) const unsigned int nesting_level_left) const
...@@ -1240,7 +1240,7 @@ struct PosLookup : Lookup ...@@ -1240,7 +1240,7 @@ struct PosLookup : Lookup
unsigned int lookup_flag = get_flag (); unsigned int lookup_flag = get_flag ();
unsigned int property; 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; return false;
for (unsigned int i = 0; i < get_subtable_count (); i++) for (unsigned int i = 0; i < get_subtable_count (); i++)
...@@ -1250,7 +1250,7 @@ struct PosLookup : Lookup ...@@ -1250,7 +1250,7 @@ struct PosLookup : Lookup
return false; return false;
} }
bool apply_string (hb_ot_layout_t *layout, bool apply_string (hb_ot_layout_context_t *context,
hb_buffer_t *buffer, hb_buffer_t *buffer,
hb_ot_layout_feature_mask_t mask) const hb_ot_layout_feature_mask_t mask) const
{ {
...@@ -1259,7 +1259,7 @@ struct PosLookup : Lookup ...@@ -1259,7 +1259,7 @@ struct PosLookup : Lookup
if (HB_UNLIKELY (!buffer->in_length)) if (HB_UNLIKELY (!buffer->in_length))
return false; 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; buffer->in_pos = 0;
while (buffer->in_pos < buffer->in_length) while (buffer->in_pos < buffer->in_length)
...@@ -1267,7 +1267,7 @@ struct PosLookup : Lookup ...@@ -1267,7 +1267,7 @@ struct PosLookup : Lookup
bool done; bool done;
if (~IN_PROPERTIES (buffer->in_pos) & mask) 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; ret |= done;
} }
else else
...@@ -1275,7 +1275,7 @@ struct PosLookup : Lookup ...@@ -1275,7 +1275,7 @@ struct PosLookup : Lookup
done = false; done = false;
/* Contrary to properties defined in GDEF, user-defined properties /* Contrary to properties defined in GDEF, user-defined properties
will always stop a possible cursive positioning. */ 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) if (!done)
...@@ -1302,11 +1302,11 @@ struct GPOS : GSUBGPOS ...@@ -1302,11 +1302,11 @@ struct GPOS : GSUBGPOS
inline const PosLookup& get_lookup (unsigned int i) const inline const PosLookup& get_lookup (unsigned int i) const
{ return (const PosLookup&) GSUBGPOS::get_lookup (i); } { 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, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
hb_ot_layout_feature_mask_t mask) const 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); ASSERT_SIZE (GPOS, 10);
...@@ -1326,7 +1326,7 @@ inline bool ExtensionPos::apply (APPLY_ARG_DEF) const ...@@ -1326,7 +1326,7 @@ inline bool ExtensionPos::apply (APPLY_ARG_DEF) const
static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index) 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); const PosLookup &l = gpos.get_lookup (lookup_index);
if (HB_UNLIKELY (nesting_level_left == 0)) if (HB_UNLIKELY (nesting_level_left == 0))
...@@ -1336,7 +1336,7 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index) ...@@ -1336,7 +1336,7 @@ static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
if (HB_UNLIKELY (context_length < 1)) if (HB_UNLIKELY (context_length < 1))
return false; return false;
return l.apply_once (layout, buffer, context_length, nesting_level_left); return l.apply_once (context, buffer, context_length, nesting_level_left);
} }
......
...@@ -46,8 +46,8 @@ struct SingleSubstFormat1 ...@@ -46,8 +46,8 @@ struct SingleSubstFormat1
_hb_buffer_replace_glyph (buffer, glyph_id); _hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */ /* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (layout)) if (_hb_ot_layout_has_new_glyph_classes (context->layout))
_hb_ot_layout_set_glyph_property (layout, glyph_id, property); _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
return true; return true;
} }
...@@ -81,8 +81,8 @@ struct SingleSubstFormat2 ...@@ -81,8 +81,8 @@ struct SingleSubstFormat2
_hb_buffer_replace_glyph (buffer, glyph_id); _hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */ /* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (layout)) if (_hb_ot_layout_has_new_glyph_classes (context->layout))
_hb_ot_layout_set_glyph_property (layout, glyph_id, property); _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
return true; return true;
} }
...@@ -137,14 +137,14 @@ struct Sequence ...@@ -137,14 +137,14 @@ struct Sequence
0xFFFF, 0xFFFF); 0xFFFF, 0xFFFF);
/* This is a guess only ... */ /* 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) if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH; property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
unsigned int count = substitute.len; unsigned int count = substitute.len;
for (unsigned int n = 0; n < count; n++) 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; return true;
...@@ -229,8 +229,8 @@ struct AlternateSubstFormat1 ...@@ -229,8 +229,8 @@ struct AlternateSubstFormat1
unsigned int alt_index = 0; unsigned int alt_index = 0;
/* XXX callback to user to choose alternate /* XXX callback to user to choose alternate
if (layout->altfunc) if (context->layout->altfunc)
alt_index = (layout->altfunc)(layout, buffer, alt_index = (context->layout->altfunc)(context->layout, buffer,
buffer->out_pos, glyph_id, buffer->out_pos, glyph_id,
alt_set.len, alt_set.array); alt_set.len, alt_set.array);
*/ */
...@@ -243,8 +243,8 @@ struct AlternateSubstFormat1 ...@@ -243,8 +243,8 @@ struct AlternateSubstFormat1
_hb_buffer_replace_glyph (buffer, glyph_id); _hb_buffer_replace_glyph (buffer, glyph_id);
/* We inherit the old glyph class to the substituted glyph */ /* We inherit the old glyph class to the substituted glyph */
if (_hb_ot_layout_has_new_glyph_classes (layout)) if (_hb_ot_layout_has_new_glyph_classes (context->layout))
_hb_ot_layout_set_glyph_property (layout, glyph_id, property); _hb_ot_layout_set_glyph_property (context->layout, glyph_id, property);
return true; return true;
} }
...@@ -297,7 +297,7 @@ struct Ligature ...@@ -297,7 +297,7 @@ struct Ligature
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) 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)) if (HB_UNLIKELY (j + count - i == end))
return false; return false;
...@@ -311,8 +311,8 @@ struct Ligature ...@@ -311,8 +311,8 @@ struct Ligature
return false; return false;
} }
/* This is just a guess ... */ /* This is just a guess ... */
if (_hb_ot_layout_has_new_glyph_classes (layout)) if (_hb_ot_layout_has_new_glyph_classes (context->layout))
hb_ot_layout_set_glyph_class (layout, ligGlyph, hb_ot_layout_set_glyph_class (context->layout, ligGlyph,
is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
: HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE); : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
...@@ -338,7 +338,7 @@ struct Ligature ...@@ -338,7 +338,7 @@ struct Ligature
for ( i = 1; i < count; i++ ) 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); _hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i - 1, lig_id);
(buffer->in_pos)++; (buffer->in_pos)++;
...@@ -627,7 +627,7 @@ struct SubstLookup : Lookup ...@@ -627,7 +627,7 @@ struct SubstLookup : Lookup
inline bool is_reverse (void) const inline bool is_reverse (void) const
{ return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle); } { 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, hb_buffer_t *buffer,
unsigned int context_length, unsigned int context_length,
unsigned int nesting_level_left) const unsigned int nesting_level_left) const
...@@ -636,7 +636,7 @@ struct SubstLookup : Lookup ...@@ -636,7 +636,7 @@ struct SubstLookup : Lookup
unsigned int lookup_flag = get_flag (); unsigned int lookup_flag = get_flag ();
unsigned int property; 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; return false;
for (unsigned int i = 0; i < get_subtable_count (); i++) for (unsigned int i = 0; i < get_subtable_count (); i++)
...@@ -646,7 +646,7 @@ struct SubstLookup : Lookup ...@@ -646,7 +646,7 @@ struct SubstLookup : Lookup
return false; return false;
} }
bool apply_string (hb_ot_layout_t *layout, bool apply_string (hb_ot_layout_context_t *context,
hb_buffer_t *buffer, hb_buffer_t *buffer,
hb_ot_layout_feature_mask_t mask) const hb_ot_layout_feature_mask_t mask) const
{ {
...@@ -663,7 +663,7 @@ struct SubstLookup : Lookup ...@@ -663,7 +663,7 @@ struct SubstLookup : Lookup
while (buffer->in_pos < buffer->in_length) while (buffer->in_pos < buffer->in_length)
{ {
if ((~IN_PROPERTIES (buffer->in_pos) & mask) && 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; ret = true;
else else
_hb_buffer_next_glyph (buffer); _hb_buffer_next_glyph (buffer);
...@@ -681,7 +681,7 @@ struct SubstLookup : Lookup ...@@ -681,7 +681,7 @@ struct SubstLookup : Lookup
do do
{ {
if ((~IN_PROPERTIES (buffer->in_pos) & mask) && 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; ret = true;
else else
buffer->in_pos--; buffer->in_pos--;
...@@ -710,11 +710,11 @@ struct GSUB : GSUBGPOS ...@@ -710,11 +710,11 @@ struct GSUB : GSUBGPOS
inline const SubstLookup& get_lookup (unsigned int i) const inline const SubstLookup& get_lookup (unsigned int i) const
{ return (const SubstLookup&) GSUBGPOS::get_lookup (i); } { 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, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
hb_ot_layout_feature_mask_t mask) const 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); ASSERT_SIZE (GSUB, 10);
...@@ -734,7 +734,7 @@ inline bool ExtensionSubst::apply (APPLY_ARG_DEF) const ...@@ -734,7 +734,7 @@ inline bool ExtensionSubst::apply (APPLY_ARG_DEF) const
static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index) 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); const SubstLookup &l = gsub.get_lookup (lookup_index);
if (HB_UNLIKELY (nesting_level_left == 0)) if (HB_UNLIKELY (nesting_level_left == 0))
...@@ -744,7 +744,7 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index) ...@@ -744,7 +744,7 @@ static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
if (HB_UNLIKELY (context_length < 1)) if (HB_UNLIKELY (context_length < 1))
return false; return false;
return l.apply_once (layout, buffer, context_length, nesting_level_left); return l.apply_once (context, buffer, context_length, nesting_level_left);
} }
......
...@@ -32,14 +32,14 @@ ...@@ -32,14 +32,14 @@
#define APPLY_ARG_DEF \ #define APPLY_ARG_DEF \
hb_ot_layout_t *layout, \ hb_ot_layout_context_t *context, \
hb_buffer_t *buffer, \ hb_buffer_t *buffer, \
unsigned int context_length HB_GNUC_UNUSED, \ unsigned int context_length HB_GNUC_UNUSED, \
unsigned int nesting_level_left HB_GNUC_UNUSED, \ unsigned int nesting_level_left HB_GNUC_UNUSED, \
unsigned int lookup_flag, \ unsigned int lookup_flag, \
unsigned int property HB_GNUC_UNUSED /* propety of first glyph */ unsigned int property HB_GNUC_UNUSED /* propety of first glyph */
#define APPLY_ARG \ #define APPLY_ARG \
layout, \ context, \
buffer, \ buffer, \
context_length, \ context_length, \
nesting_level_left, \ nesting_level_left, \
...@@ -89,7 +89,7 @@ static inline bool match_input (APPLY_ARG_DEF, ...@@ -89,7 +89,7 @@ static inline bool match_input (APPLY_ARG_DEF,
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) 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)) if (HB_UNLIKELY (j + count - i == end))
return false; return false;
...@@ -116,7 +116,7 @@ static inline bool match_backtrack (APPLY_ARG_DEF, ...@@ -116,7 +116,7 @@ static inline bool match_backtrack (APPLY_ARG_DEF,
for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--) 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)) if (HB_UNLIKELY (j + 1 == count - i))
return false; return false;
...@@ -144,7 +144,7 @@ static inline bool match_lookahead (APPLY_ARG_DEF, ...@@ -144,7 +144,7 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++) 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)) if (HB_UNLIKELY (j + count - i == end))
return false; return false;
...@@ -182,7 +182,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF, ...@@ -182,7 +182,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
* Should be easy for in_place ones at least. */ * Should be easy for in_place ones at least. */
for (unsigned int i = 0; i < count; i++) 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)) if (HB_UNLIKELY (buffer->in_pos == end))
return true; return true;
...@@ -232,16 +232,16 @@ static inline bool context_lookup (APPLY_ARG_DEF, ...@@ -232,16 +232,16 @@ static inline bool context_lookup (APPLY_ARG_DEF,
const USHORT input[], /* Array of input values--start with second glyph */ const USHORT input[], /* Array of input values--start with second glyph */
unsigned int lookupCount, unsigned int lookupCount,
const LookupRecord lookupRecord[], const LookupRecord lookupRecord[],
ContextLookupContext &context) ContextLookupContext &lookup_context)
{ {
return match_input (APPLY_ARG, return match_input (APPLY_ARG,
inputCount, input, inputCount, input,
context.funcs.match, context.match_data, lookup_context.funcs.match, lookup_context.match_data,
&context_length) && &context_length) &&
apply_lookup (APPLY_ARG, apply_lookup (APPLY_ARG,
inputCount, inputCount,
lookupCount, lookupRecord, lookupCount, lookupRecord,
context.funcs.apply); lookup_context.funcs.apply);
} }
struct Rule struct Rule
...@@ -249,7 +249,7 @@ struct Rule ...@@ -249,7 +249,7 @@ struct Rule
friend struct RuleSet; friend struct RuleSet;
private: 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 LookupRecord *lookupRecord = (const LookupRecord *)
((const char *) input + ((const char *) input +
...@@ -257,7 +257,7 @@ struct Rule ...@@ -257,7 +257,7 @@ struct Rule
return context_lookup (APPLY_ARG, return context_lookup (APPLY_ARG,
inputCount, input, inputCount, input,
lookupCount, lookupRecord, lookupCount, lookupRecord,
context); lookup_context);
} }
private: private:
...@@ -274,12 +274,12 @@ ASSERT_SIZE (Rule, 4); ...@@ -274,12 +274,12 @@ ASSERT_SIZE (Rule, 4);
struct RuleSet 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; unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++) 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 true;
} }
...@@ -305,11 +305,11 @@ struct ContextFormat1 ...@@ -305,11 +305,11 @@ struct ContextFormat1
return false; return false;
const RuleSet &rule_set = this+ruleSet[index]; const RuleSet &rule_set = this+ruleSet[index];
struct ContextLookupContext context = { struct ContextLookupContext lookup_context = {
{match_glyph, apply_func}, {match_glyph, apply_func},
NULL NULL
}; };
return rule_set.apply (APPLY_ARG, context); return rule_set.apply (APPLY_ARG, lookup_context);
} }
private: private:
...@@ -341,11 +341,11 @@ struct ContextFormat2 ...@@ -341,11 +341,11 @@ struct ContextFormat2
/* LONGTERMTODO: Old code fetches glyph classes at most once and caches /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
* them across subrule lookups. Not sure it's worth it. * them across subrule lookups. Not sure it's worth it.
*/ */
struct ContextLookupContext context = { struct ContextLookupContext lookup_context = {
{match_class, apply_func}, {match_class, apply_func},
(char *) &class_def (char *) &class_def
}; };
return rule_set.apply (APPLY_ARG, context); return rule_set.apply (APPLY_ARG, lookup_context);
} }
private: private:
...@@ -377,14 +377,14 @@ struct ContextFormat3 ...@@ -377,14 +377,14 @@ struct ContextFormat3
const LookupRecord *lookupRecord = (const LookupRecord *) const LookupRecord *lookupRecord = (const LookupRecord *)
((const char *) coverage + ((const char *) coverage +
sizeof (coverage[0]) * glyphCount); sizeof (coverage[0]) * glyphCount);
struct ContextLookupContext context = { struct ContextLookupContext lookup_context = {
{match_coverage, apply_func}, {match_coverage, apply_func},
(char *) this (char *) this
}; };
return context_lookup (APPLY_ARG, return context_lookup (APPLY_ARG,
glyphCount, (const USHORT *) (coverage + 1), glyphCount, (const USHORT *) (coverage + 1),
lookupCount, lookupRecord, lookupCount, lookupRecord,
context); lookup_context);
} }
private: private:
...@@ -441,7 +441,7 @@ static inline bool chain_context_lookup (APPLY_ARG_DEF, ...@@ -441,7 +441,7 @@ static inline bool chain_context_lookup (APPLY_ARG_DEF,
const USHORT lookahead[], const USHORT lookahead[],
unsigned int lookupCount, unsigned int lookupCount,
const LookupRecord lookupRecord[], const LookupRecord lookupRecord[],
ChainContextLookupContext &context) ChainContextLookupContext &lookup_context)
{ {
/* First guess */ /* First guess */
if (HB_UNLIKELY (buffer->out_pos < backtrackCount || if (HB_UNLIKELY (buffer->out_pos < backtrackCount ||
...@@ -452,20 +452,20 @@ static inline bool chain_context_lookup (APPLY_ARG_DEF, ...@@ -452,20 +452,20 @@ static inline bool chain_context_lookup (APPLY_ARG_DEF,
unsigned int offset; unsigned int offset;
return match_backtrack (APPLY_ARG, return match_backtrack (APPLY_ARG,
backtrackCount, backtrack, backtrackCount, backtrack,
context.funcs.match, context.match_data[0]) && lookup_context.funcs.match, lookup_context.match_data[0]) &&
match_input (APPLY_ARG, match_input (APPLY_ARG,
inputCount, input, inputCount, input,
context.funcs.match, context.match_data[1], lookup_context.funcs.match, lookup_context.match_data[1],
&offset) && &offset) &&
match_lookahead (APPLY_ARG, match_lookahead (APPLY_ARG,
lookaheadCount, lookahead, lookaheadCount, lookahead,
context.funcs.match, context.match_data[2], lookup_context.funcs.match, lookup_context.match_data[2],
offset) && offset) &&
(context_length = offset, true) && (context_length = offset, true) &&
apply_lookup (APPLY_ARG, apply_lookup (APPLY_ARG,
inputCount, inputCount,
lookupCount, lookupRecord, lookupCount, lookupRecord,
context.funcs.apply); lookup_context.funcs.apply);
} }
struct ChainRule struct ChainRule
...@@ -473,7 +473,7 @@ struct ChainRule ...@@ -473,7 +473,7 @@ struct ChainRule
friend struct ChainRuleSet; friend struct ChainRuleSet;
private: 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 HeadlessArrayOf<USHORT> &input = *(const HeadlessArrayOf<USHORT>*)
((const char *) &backtrack + backtrack.get_size ()); ((const char *) &backtrack + backtrack.get_size ());
...@@ -486,7 +486,7 @@ struct ChainRule ...@@ -486,7 +486,7 @@ struct ChainRule
input.len, input.array + 1, input.len, input.array + 1,
lookahead.len, lookahead.array, lookahead.len, lookahead.array,
lookup.len, lookup.array, lookup.len, lookup.array,
context); lookup_context);
return false; return false;
} }
...@@ -510,12 +510,12 @@ ASSERT_SIZE (ChainRule, 8); ...@@ -510,12 +510,12 @@ ASSERT_SIZE (ChainRule, 8);
struct ChainRuleSet 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; unsigned int num_rules = rule.len;
for (unsigned int i = 0; i < num_rules; i++) 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 true;
} }
...@@ -541,11 +541,11 @@ struct ChainContextFormat1 ...@@ -541,11 +541,11 @@ struct ChainContextFormat1
return false; return false;
const ChainRuleSet &rule_set = this+ruleSet[index]; const ChainRuleSet &rule_set = this+ruleSet[index];
struct ChainContextLookupContext context = { struct ChainContextLookupContext lookup_context = {
{match_glyph, apply_func}, {match_glyph, apply_func},
{NULL, NULL, NULL} {NULL, NULL, NULL}
}; };
return rule_set.apply (APPLY_ARG, context); return rule_set.apply (APPLY_ARG, lookup_context);
} }
private: private:
USHORT format; /* Format identifier--format = 1 */ USHORT format; /* Format identifier--format = 1 */
...@@ -578,13 +578,13 @@ struct ChainContextFormat2 ...@@ -578,13 +578,13 @@ struct ChainContextFormat2
/* LONGTERMTODO: Old code fetches glyph classes at most once and caches /* LONGTERMTODO: Old code fetches glyph classes at most once and caches
* them across subrule lookups. Not sure it's worth it. * them across subrule lookups. Not sure it's worth it.
*/ */
struct ChainContextLookupContext context = { struct ChainContextLookupContext lookup_context = {
{match_class, apply_func}, {match_class, apply_func},
{(char *) &backtrack_class_def, {(char *) &backtrack_class_def,
(char *) &input_class_def, (char *) &input_class_def,
(char *) &lookahead_class_def} (char *) &lookahead_class_def}
}; };
return rule_set.apply (APPLY_ARG, context); return rule_set.apply (APPLY_ARG, lookup_context);
} }
private: private:
...@@ -629,7 +629,7 @@ struct ChainContextFormat3 ...@@ -629,7 +629,7 @@ struct ChainContextFormat3
((const char *) &input + input.get_size ()); ((const char *) &input + input.get_size ());
const ArrayOf<LookupRecord> &lookup = *(const ArrayOf<LookupRecord>*) const ArrayOf<LookupRecord> &lookup = *(const ArrayOf<LookupRecord>*)
((const char *) &lookahead + lookahead.get_size ()); ((const char *) &lookahead + lookahead.get_size ());
struct ChainContextLookupContext context = { struct ChainContextLookupContext lookup_context = {
{match_coverage, apply_func}, {match_coverage, apply_func},
{(char *) this, (char *) this, (char *) this} {(char *) this, (char *) this, (char *) this}
}; };
...@@ -638,7 +638,7 @@ struct ChainContextFormat3 ...@@ -638,7 +638,7 @@ struct ChainContextFormat3
input.len, (USHORT *) input.array, input.len, (USHORT *) input.array,
lookahead.len, (USHORT *) lookahead.array, lookahead.len, (USHORT *) lookahead.array,
lookup.len, lookup.array, lookup.len, lookup.array,
context); lookup_context);
return false; return false;
} }
......
...@@ -44,20 +44,24 @@ struct _hb_ot_layout_t ...@@ -44,20 +44,24 @@ struct _hb_ot_layout_t
unsigned char *klasses; unsigned char *klasses;
unsigned int len; unsigned int len;
} new_gdef; } new_gdef;
};
/* TODO full-matrix transformation? */ typedef struct _hb_ot_layout_context_t hb_ot_layout_context_t;
struct gpos_info_t struct _hb_ot_layout_context_t
{ {
unsigned int x_ppem, y_ppem; hb_ot_layout_t *layout;
hb_16dot16_t x_scale, y_scale; hb_face_t *face;
hb_font_t *font;
hb_bool_t dvi;
hb_bool_t r2l;
union info_t
{
struct gpos_t
{
unsigned int last; /* the last valid glyph--used with cursive positioning */ 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_x; /* the coordinates of the anchor point */
hb_position_t anchor_y; /* of the last valid glyph */ hb_position_t anchor_y; /* of the last valid glyph */
} gpos_info; } gpos;
} info;
}; };
......
...@@ -83,36 +83,6 @@ hb_ot_layout_destroy (hb_ot_layout_t *layout) ...@@ -83,36 +83,6 @@ hb_ot_layout_destroy (hb_ot_layout_t *layout)
free (layout); 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 * GDEF
......
...@@ -48,11 +48,6 @@ hb_ot_layout_create_for_data (const char *font_data, ...@@ -48,11 +48,6 @@ hb_ot_layout_create_for_data (const char *font_data,
void void
hb_ot_layout_destroy (hb_ot_layout_t *layout); 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 void
hb_ot_layout_set_hinting (hb_ot_layout_t *layout, hb_ot_layout_set_hinting (hb_ot_layout_t *layout,
hb_bool_t hinted); hb_bool_t hinted);
......
...@@ -100,4 +100,20 @@ _hb_popcount32 (uint32_t mask) ...@@ -100,4 +100,20 @@ _hb_popcount32 (uint32_t mask)
#endif #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 */ #endif /* HB_PRIVATE_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册