Remove hb_ot_layout_context_t, simplify code

This commit is contained in:
Behdad Esfahbod 2011-05-11 00:02:02 -04:00
parent 1ded6d8bbf
commit abcfe9b59b
9 changed files with 118 additions and 126 deletions

View File

@ -85,9 +85,9 @@ struct _hb_face_t {
void *user_data; void *user_data;
hb_destroy_func_t destroy; hb_destroy_func_t destroy;
hb_blob_t *head_blob;
struct hb_ot_layout_t *ot_layout; struct hb_ot_layout_t *ot_layout;
unsigned int upem;
}; };
@ -112,6 +112,14 @@ struct _hb_font_t {
hb_font_funcs_t *klass; hb_font_funcs_t *klass;
void *user_data; void *user_data;
hb_destroy_func_t destroy; hb_destroy_func_t destroy;
/* Convert from font-space to user-space */
inline hb_position_t scale_x (int16_t v) { return scale (v, this->x_scale); }
inline hb_position_t scale_y (int16_t v) { return scale (v, this->y_scale); }
private:
inline hb_position_t scale (int16_t v, int scale) { return v * (int64_t) scale / this->face->upem; }
}; };

View File

@ -299,7 +299,9 @@ static hb_face_t _hb_face_nil = {
NULL, /* user_data */ NULL, /* user_data */
NULL, /* destroy */ NULL, /* destroy */
NULL /* ot_layout */ NULL, /* ot_layout */
1000
}; };
@ -322,6 +324,8 @@ hb_face_create_for_tables (hb_get_table_func_t get_table,
face->ot_layout = _hb_ot_layout_create (face); face->ot_layout = _hb_ot_layout_create (face);
face->upem = _hb_ot_layout_get_upem (face);
return face; return face;
} }

View File

@ -526,11 +526,11 @@ struct ClassDef
struct Device struct Device
{ {
inline hb_position_t get_x_delta (hb_ot_layout_context_t *c) const inline hb_position_t get_x_delta (hb_font_t *font) const
{ return get_delta (c->font->x_ppem, c->font->x_scale); } { return get_delta (font->x_ppem, font->x_scale); }
inline hb_position_t get_y_delta (hb_ot_layout_context_t *c) const inline hb_position_t get_y_delta (hb_font_t *font) const
{ return get_delta (c->font->y_ppem, c->font->y_scale); } { return get_delta (font->y_ppem, font->y_scale); }
inline int get_delta (unsigned int ppem, int scale) const inline int get_delta (unsigned int ppem, int scale) const
{ {

View File

@ -96,9 +96,9 @@ struct CaretValueFormat1
friend struct CaretValue; friend struct CaretValue;
private: private:
inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id HB_UNUSED) const
{ {
return HB_DIRECTION_IS_HORIZONTAL (direction) ? c->scale_x (coordinate) : c->scale_y (coordinate); return HB_DIRECTION_IS_HORIZONTAL (direction) ? font->scale_x (coordinate) : font->scale_y (coordinate);
} }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
@ -118,10 +118,10 @@ struct CaretValueFormat2
friend struct CaretValue; friend struct CaretValue;
private: private:
inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t direction, hb_codepoint_t glyph_id) const inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{ {
hb_position_t x, y; hb_position_t x, y;
if (hb_font_get_contour_point (c->font, caretValuePoint, glyph_id, &x, &y)) if (hb_font_get_contour_point (font, caretValuePoint, glyph_id, &x, &y))
return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y;
else else
return 0; return 0;
@ -143,11 +143,11 @@ struct CaretValueFormat3
{ {
friend struct CaretValue; friend struct CaretValue;
inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t direction, hb_codepoint_t glyph_id) const inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{ {
return HB_DIRECTION_IS_HORIZONTAL (direction) ? return HB_DIRECTION_IS_HORIZONTAL (direction) ?
c->scale_x (coordinate) + (this+deviceTable).get_x_delta (c) : font->scale_x (coordinate) + (this+deviceTable).get_x_delta (font) :
c->scale_y (coordinate) + (this+deviceTable).get_y_delta (c); font->scale_y (coordinate) + (this+deviceTable).get_y_delta (font);
} }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
@ -169,12 +169,12 @@ struct CaretValueFormat3
struct CaretValue struct CaretValue
{ {
inline int get_caret_value (hb_ot_layout_context_t *c, hb_direction_t direction, hb_codepoint_t glyph_id) const inline int get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const
{ {
switch (u.format) { switch (u.format) {
case 1: return u.format1.get_caret_value (c, direction, glyph_id); case 1: return u.format1.get_caret_value (font, direction, glyph_id);
case 2: return u.format2.get_caret_value (c, direction, glyph_id); case 2: return u.format2.get_caret_value (font, direction, glyph_id);
case 3: return u.format3.get_caret_value (c, direction, glyph_id); case 3: return u.format3.get_caret_value (font, direction, glyph_id);
default:return 0; default:return 0;
} }
} }
@ -203,7 +203,7 @@ struct CaretValue
struct LigGlyph struct LigGlyph
{ {
inline unsigned int get_lig_carets (hb_ot_layout_context_t *c, inline unsigned int get_lig_carets (hb_font_t *font,
hb_direction_t direction, hb_direction_t direction,
hb_codepoint_t glyph_id, hb_codepoint_t glyph_id,
unsigned int start_offset, unsigned int start_offset,
@ -214,7 +214,7 @@ struct LigGlyph
const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_count); const OffsetTo<CaretValue> *array = carets.sub_array (start_offset, caret_count);
unsigned int count = *caret_count; unsigned int count = *caret_count;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
caret_array[i] = (this+array[i]).get_caret_value (c, direction, glyph_id); caret_array[i] = (this+array[i]).get_caret_value (font, direction, glyph_id);
} }
return carets.len; return carets.len;
@ -236,7 +236,7 @@ struct LigGlyph
struct LigCaretList struct LigCaretList
{ {
inline unsigned int get_lig_carets (hb_ot_layout_context_t *c, inline unsigned int get_lig_carets (hb_font_t *font,
hb_direction_t direction, hb_direction_t direction,
hb_codepoint_t glyph_id, hb_codepoint_t glyph_id,
unsigned int start_offset, unsigned int start_offset,
@ -251,7 +251,7 @@ struct LigCaretList
return 0; return 0;
} }
const LigGlyph &lig_glyph = this+ligGlyph[index]; const LigGlyph &lig_glyph = this+ligGlyph[index];
return lig_glyph.get_lig_carets (c, direction, glyph_id, start_offset, caret_count, caret_array); return lig_glyph.get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array);
} }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
@ -352,13 +352,13 @@ struct GDEF
{ return (this+attachList).get_attach_points (glyph_id, start_offset, point_count, point_array); } { return (this+attachList).get_attach_points (glyph_id, start_offset, point_count, point_array); }
inline bool has_lig_carets (void) const { return ligCaretList != 0; } inline bool has_lig_carets (void) const { return ligCaretList != 0; }
inline unsigned int get_lig_carets (hb_ot_layout_context_t *c, inline unsigned int get_lig_carets (hb_font_t *font,
hb_direction_t direction, hb_direction_t direction,
hb_codepoint_t glyph_id, hb_codepoint_t glyph_id,
unsigned int start_offset, unsigned int start_offset,
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 (c, direction, glyph_id, start_offset, caret_count, caret_array); } { return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); }
inline bool has_mark_sets (void) const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; } inline bool has_mark_sets (void) 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

View File

@ -94,7 +94,7 @@ struct ValueFormat : USHORT
inline unsigned int get_size (void) const inline unsigned int get_size (void) const
{ return get_len () * Value::static_size; } { return get_len () * Value::static_size; }
void apply_value (hb_ot_layout_context_t *layout, void apply_value (hb_font_t *font,
const void *base, const void *base,
const Value *values, const Value *values,
hb_glyph_position_t &glyph_pos) const hb_glyph_position_t &glyph_pos) const
@ -105,30 +105,30 @@ struct ValueFormat : USHORT
if (!format) return; if (!format) return;
/* design units -> fractional pixel */ /* design units -> fractional pixel */
if (format & xPlacement) glyph_pos.x_offset += layout->scale_x (get_short (values++)); if (format & xPlacement) glyph_pos.x_offset += font->scale_x (get_short (values++));
if (format & yPlacement) glyph_pos.y_offset += layout->scale_y (get_short (values++)); if (format & yPlacement) glyph_pos.y_offset += font->scale_y (get_short (values++));
if (format & xAdvance) glyph_pos.x_advance += layout->scale_x (get_short (values++)); if (format & xAdvance) glyph_pos.x_advance += font->scale_x (get_short (values++));
if (format & yAdvance) glyph_pos.y_advance += layout->scale_y (get_short (values++)); if (format & yAdvance) glyph_pos.y_advance += font->scale_y (get_short (values++));
if (!has_device ()) return; if (!has_device ()) return;
x_ppem = layout->font->x_ppem; x_ppem = font->x_ppem;
y_ppem = layout->font->y_ppem; y_ppem = font->y_ppem;
if (!x_ppem && !y_ppem) return; if (!x_ppem && !y_ppem) return;
/* pixel -> fractional pixel */ /* pixel -> fractional pixel */
if (format & xPlaDevice) { if (format & xPlaDevice) {
if (x_ppem) glyph_pos.x_offset += (base + get_device (values++)).get_x_delta (layout); else values++; if (x_ppem) glyph_pos.x_offset += (base + get_device (values++)).get_x_delta (font); else values++;
} }
if (format & yPlaDevice) { if (format & yPlaDevice) {
if (y_ppem) glyph_pos.y_offset += (base + get_device (values++)).get_y_delta (layout); else values++; if (y_ppem) glyph_pos.y_offset += (base + get_device (values++)).get_y_delta (font); else values++;
} }
if (format & xAdvDevice) { if (format & xAdvDevice) {
if (x_ppem) glyph_pos.x_advance += (base + get_device (values++)).get_x_delta (layout); else values++; if (x_ppem) glyph_pos.x_advance += (base + get_device (values++)).get_x_delta (font); else values++;
} }
if (format & yAdvDevice) { if (format & yAdvDevice) {
if (y_ppem) glyph_pos.y_advance += (base + get_device (values++)).get_y_delta (layout); else values++; if (y_ppem) glyph_pos.y_advance += (base + get_device (values++)).get_y_delta (font); else values++;
} }
} }
@ -209,11 +209,11 @@ struct AnchorFormat1
friend struct Anchor; friend struct Anchor;
private: private:
inline void get_anchor (hb_ot_layout_context_t *layout, hb_codepoint_t glyph_id HB_UNUSED, inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
*x = layout->scale_x (xCoordinate); *x = font->scale_x (xCoordinate);
*y = layout->scale_y (yCoordinate); *y = font->scale_y (yCoordinate);
} }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
@ -234,18 +234,18 @@ struct AnchorFormat2
friend struct Anchor; friend struct Anchor;
private: private:
inline void get_anchor (hb_ot_layout_context_t *layout, hb_codepoint_t glyph_id, inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
unsigned int x_ppem = layout->font->x_ppem; unsigned int x_ppem = font->x_ppem;
unsigned int y_ppem = layout->font->y_ppem; unsigned int y_ppem = font->y_ppem;
hb_position_t cx, cy; hb_position_t cx, cy;
hb_bool_t ret = false; hb_bool_t ret = false;
if (x_ppem || y_ppem) if (x_ppem || y_ppem)
ret = hb_font_get_contour_point (layout->font, anchorPoint, glyph_id, &cx, &cy); ret = hb_font_get_contour_point (font, anchorPoint, glyph_id, &cx, &cy);
*x = x_ppem && ret ? cx : layout->scale_x (xCoordinate); *x = x_ppem && ret ? cx : font->scale_x (xCoordinate);
*y = y_ppem && ret ? cy : layout->scale_y (yCoordinate); *y = y_ppem && ret ? cy : font->scale_y (yCoordinate);
} }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
@ -267,17 +267,17 @@ struct AnchorFormat3
friend struct Anchor; friend struct Anchor;
private: private:
inline void get_anchor (hb_ot_layout_context_t *layout, hb_codepoint_t glyph_id HB_UNUSED, inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
*x = layout->scale_x (xCoordinate); *x = font->scale_x (xCoordinate);
*y = layout->scale_y (yCoordinate); *y = font->scale_y (yCoordinate);
/* pixel -> fractional pixel */ /* pixel -> fractional pixel */
if (layout->font->x_ppem) if (font->x_ppem)
*x += (this+xDeviceTable).get_x_delta (layout); *x += (this+xDeviceTable).get_x_delta (font);
if (layout->font->y_ppem) if (font->y_ppem)
*y += (this+yDeviceTable).get_x_delta (layout); *y += (this+yDeviceTable).get_x_delta (font);
} }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
@ -305,14 +305,14 @@ struct AnchorFormat3
struct Anchor struct Anchor
{ {
inline void get_anchor (hb_ot_layout_context_t *layout, hb_codepoint_t glyph_id, inline void get_anchor (hb_font_t *font, 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 (font, glyph_id, x, y); return;
case 2: u.format2.get_anchor (layout, glyph_id, x, y); return; case 2: u.format2.get_anchor (font, glyph_id, x, y); return;
case 3: u.format3.get_anchor (layout, glyph_id, x, y); return; case 3: u.format3.get_anchor (font, glyph_id, x, y); return;
default: return; default: return;
} }
} }
@ -403,8 +403,8 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
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 (c->layout, c->buffer->info[c->buffer->i].codepoint, &mark_x, &mark_y); mark_anchor.get_anchor (c->font, 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); glyph_anchor.get_anchor (c->font, c->buffer->info[glyph_pos].codepoint, &base_x, &base_y);
hb_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.x_offset = base_x - mark_x;
@ -436,7 +436,7 @@ struct SinglePosFormat1
if (likely (index == NOT_COVERED)) if (likely (index == NOT_COVERED))
return false; return false;
valueFormat.apply_value (c->layout, this, values, c->buffer->pos[c->buffer->i]); valueFormat.apply_value (c->font, this, values, c->buffer->pos[c->buffer->i]);
c->buffer->i++; c->buffer->i++;
return true; return true;
@ -478,7 +478,7 @@ struct SinglePosFormat2
if (likely (index >= valueCount)) if (likely (index >= valueCount))
return false; return false;
valueFormat.apply_value (c->layout, this, valueFormat.apply_value (c->font, this,
&values[index * valueFormat.get_len ()], &values[index * valueFormat.get_len ()],
c->buffer->pos[c->buffer->i]); c->buffer->pos[c->buffer->i]);
@ -574,8 +574,8 @@ struct PairSet
{ {
if (c->buffer->info[pos].codepoint == record->secondGlyph) if (c->buffer->info[pos].codepoint == record->secondGlyph)
{ {
valueFormats[0].apply_value (c->layout, this, &record->values[0], c->buffer->pos[c->buffer->i]); valueFormats[0].apply_value (c->font, this, &record->values[0], c->buffer->pos[c->buffer->i]);
valueFormats[1].apply_value (c->layout, this, &record->values[len1], c->buffer->pos[pos]); valueFormats[1].apply_value (c->font, this, &record->values[len1], c->buffer->pos[pos]);
if (len2) if (len2)
pos++; pos++;
c->buffer->i = pos; c->buffer->i = pos;
@ -630,7 +630,7 @@ struct PairPosFormat1
return false; return false;
unsigned int j = c->buffer->i + 1; unsigned int j = c->buffer->i + 1;
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_props, NULL)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, NULL))
{ {
if (unlikely (j == end)) if (unlikely (j == end))
return false; return false;
@ -692,7 +692,7 @@ struct PairPosFormat2
return false; return false;
unsigned int j = c->buffer->i + 1; unsigned int j = c->buffer->i + 1;
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_props, NULL)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, NULL))
{ {
if (unlikely (j == end)) if (unlikely (j == end))
return false; return false;
@ -709,8 +709,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 (c->layout, this, v, c->buffer->pos[c->buffer->i]); valueFormat1.apply_value (c->font, this, v, c->buffer->pos[c->buffer->i]);
valueFormat2.apply_value (c->layout, this, v + len1, c->buffer->pos[j]); valueFormat2.apply_value (c->font, this, v + len1, c->buffer->pos[j]);
if (len2) if (len2)
j++; j++;
@ -845,7 +845,7 @@ struct CursivePosFormat1
return false; return false;
unsigned int j = c->buffer->i + 1; unsigned int j = c->buffer->i + 1;
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_props, NULL)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, NULL))
{ {
if (unlikely (j == end)) if (unlikely (j == end))
return false; return false;
@ -859,8 +859,8 @@ struct CursivePosFormat1
unsigned int i = c->buffer->i; unsigned int i = c->buffer->i;
hb_position_t entry_x, entry_y, exit_x, exit_y; hb_position_t entry_x, entry_y, exit_x, exit_y;
(this+this_record.exitAnchor).get_anchor (c->layout, c->buffer->info[i].codepoint, &exit_x, &exit_y); (this+this_record.exitAnchor).get_anchor (c->font, c->buffer->info[i].codepoint, &exit_x, &exit_y);
(this+next_record.entryAnchor).get_anchor (c->layout, c->buffer->info[j].codepoint, &entry_x, &entry_y); (this+next_record.entryAnchor).get_anchor (c->font, c->buffer->info[j].codepoint, &entry_x, &entry_y);
hb_direction_t direction = c->buffer->props.direction; hb_direction_t direction = c->buffer->props.direction;
@ -976,7 +976,7 @@ struct MarkBasePosFormat1
if (unlikely (!j)) if (unlikely (!j))
return false; return false;
j--; j--;
} while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], LookupFlag::IgnoreMarks, &property)); } while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], LookupFlag::IgnoreMarks, &property));
/* The following assertion is too strong, so we've disabled it. */ /* The following assertion is too strong, so we've disabled it. */
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH)) if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH))
@ -1078,7 +1078,7 @@ struct MarkLigPosFormat1
if (unlikely (!j)) if (unlikely (!j))
return false; return false;
j--; j--;
} while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], LookupFlag::IgnoreMarks, &property)); } while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], LookupFlag::IgnoreMarks, &property));
/* The following assertion is too strong, so we've disabled it. */ /* The following assertion is too strong, so we've disabled it. */
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)) if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE))
@ -1197,7 +1197,7 @@ struct MarkMarkPosFormat1
if (unlikely (!j)) if (unlikely (!j))
return false; return false;
j--; j--;
} while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_props, &property)); } while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, &property));
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
return false; return false;
@ -1402,7 +1402,7 @@ struct PosLookup : Lookup
inline const PosLookupSubTable& get_subtable (unsigned int i) const inline const PosLookupSubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; } { return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; }
inline bool apply_once (hb_ot_layout_context_t *layout, inline bool apply_once (hb_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
hb_mask_t lookup_mask, hb_mask_t lookup_mask,
unsigned int context_length, unsigned int context_length,
@ -1411,14 +1411,15 @@ struct PosLookup : Lookup
unsigned int lookup_type = get_type (); unsigned int lookup_type = get_type ();
hb_apply_context_t c[1] = {{0}}; hb_apply_context_t c[1] = {{0}};
c->layout = layout; c->font = font;
c->face = font->face;
c->buffer = buffer; c->buffer = buffer;
c->lookup_mask = lookup_mask; c->lookup_mask = lookup_mask;
c->context_length = context_length; c->context_length = context_length;
c->nesting_level_left = nesting_level_left; c->nesting_level_left = nesting_level_left;
c->lookup_props = get_props (); c->lookup_props = get_props ();
if (!_hb_ot_layout_check_glyph_property (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_props, &c->property)) if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->info[c->buffer->i], c->lookup_props, &c->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++)
@ -1428,7 +1429,7 @@ struct PosLookup : Lookup
return false; return false;
} }
inline bool apply_string (hb_ot_layout_context_t *layout, inline bool apply_string (hb_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
hb_mask_t mask) const hb_mask_t mask) const
{ {
@ -1441,7 +1442,7 @@ struct PosLookup : Lookup
while (buffer->i < buffer->len) while (buffer->i < buffer->len)
{ {
if ((buffer->info[buffer->i].mask & mask) && if ((buffer->info[buffer->i].mask & mask) &&
apply_once (layout, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL)) apply_once (font, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true; ret = true;
else else
buffer->i++; buffer->i++;
@ -1471,11 +1472,11 @@ struct GPOS : GSUBGPOS
inline const PosLookup& get_lookup (unsigned int i) const inline const PosLookup& get_lookup (unsigned int i) const
{ return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); } { return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }
inline bool position_lookup (hb_ot_layout_context_t *layout, inline bool position_lookup (hb_font_t *font,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
hb_mask_t mask) const hb_mask_t mask) const
{ return get_lookup (lookup_index).apply_string (layout, buffer, mask); } { return get_lookup (lookup_index).apply_string (font, buffer, mask); }
static inline void position_finish (hb_buffer_t *buffer); static inline void position_finish (hb_buffer_t *buffer);
@ -1566,7 +1567,7 @@ inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c)
static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index) static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index)
{ {
const GPOS &gpos = *(c->layout->face->ot_layout->gpos); const GPOS &gpos = *(c->face->ot_layout->gpos);
const PosLookup &l = gpos.get_lookup (lookup_index); const PosLookup &l = gpos.get_lookup (lookup_index);
if (unlikely (c->nesting_level_left == 0)) if (unlikely (c->nesting_level_left == 0))
@ -1575,7 +1576,7 @@ static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_i
if (unlikely (c->context_length < 1)) if (unlikely (c->context_length < 1))
return false; return false;
return l.apply_once (c->layout, c->buffer, c->lookup_mask, c->context_length, c->nesting_level_left - 1); return l.apply_once (c->font, c->buffer, c->lookup_mask, c->context_length, c->nesting_level_left - 1);
} }

View File

@ -354,7 +354,7 @@ struct Ligature
for (i = 1, j = c->buffer->i + 1; i < count; i++, j++) for (i = 1, j = c->buffer->i + 1; i < count; i++, j++)
{ {
unsigned int property; unsigned int property;
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_props, &property)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, &property))
{ {
if (unlikely (j + count - i == end)) if (unlikely (j + count - i == end))
return false; return false;
@ -392,7 +392,7 @@ struct Ligature
for (i = 1; i < count; i++) for (i = 1; i < count; i++)
{ {
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_props, NULL)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[c->buffer->i], c->lookup_props, NULL))
{ {
c->buffer->info[c->buffer->i].lig_comp() = i; c->buffer->info[c->buffer->i].lig_comp() = i;
c->buffer->info[c->buffer->i].lig_id() = lig_id; c->buffer->info[c->buffer->i].lig_id() = lig_id;
@ -762,7 +762,7 @@ struct SubstLookup : Lookup
} }
inline bool apply_once (hb_ot_layout_context_t *layout, inline bool apply_once (hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
hb_mask_t lookup_mask, hb_mask_t lookup_mask,
unsigned int context_length, unsigned int context_length,
@ -771,14 +771,14 @@ struct SubstLookup : Lookup
unsigned int lookup_type = get_type (); unsigned int lookup_type = get_type ();
hb_apply_context_t c[1] = {{0}}; hb_apply_context_t c[1] = {{0}};
c->layout = layout; c->face = face;
c->buffer = buffer; c->buffer = buffer;
c->lookup_mask = lookup_mask; c->lookup_mask = lookup_mask;
c->context_length = context_length; c->context_length = context_length;
c->nesting_level_left = nesting_level_left; c->nesting_level_left = nesting_level_left;
c->lookup_props = get_props (); c->lookup_props = get_props ();
if (!_hb_ot_layout_check_glyph_property (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_props, &c->property)) if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->info[c->buffer->i], c->lookup_props, &c->property))
return false; return false;
if (unlikely (lookup_type == SubstLookupSubTable::Extension)) if (unlikely (lookup_type == SubstLookupSubTable::Extension))
@ -803,7 +803,7 @@ struct SubstLookup : Lookup
return false; return false;
} }
inline bool apply_string (hb_ot_layout_context_t *layout, inline bool apply_string (hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
hb_mask_t mask) const hb_mask_t mask) const
{ {
@ -820,7 +820,7 @@ struct SubstLookup : Lookup
while (buffer->i < buffer->len) while (buffer->i < buffer->len)
{ {
if ((buffer->info[buffer->i].mask & mask) && if ((buffer->info[buffer->i].mask & mask) &&
apply_once (layout, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL)) apply_once (face, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true; ret = true;
else else
buffer->next_glyph (); buffer->next_glyph ();
@ -836,7 +836,7 @@ struct SubstLookup : Lookup
do do
{ {
if ((buffer->info[buffer->i].mask & mask) && if ((buffer->info[buffer->i].mask & mask) &&
apply_once (layout, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL)) apply_once (face, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true; ret = true;
else else
buffer->i--; buffer->i--;
@ -869,11 +869,11 @@ struct GSUB : GSUBGPOS
inline const SubstLookup& get_lookup (unsigned int i) const inline const SubstLookup& get_lookup (unsigned int i) const
{ return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); } { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
inline bool substitute_lookup (hb_ot_layout_context_t *layout, inline bool substitute_lookup (hb_face_t *face,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int lookup_index, unsigned int lookup_index,
hb_mask_t mask) const hb_mask_t mask) const
{ return get_lookup (lookup_index).apply_string (layout, buffer, mask); } { return get_lookup (lookup_index).apply_string (face, buffer, mask); }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
@ -913,7 +913,7 @@ inline bool ExtensionSubst::is_reverse (void) const
static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index) static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index)
{ {
const GSUB &gsub = *(c->layout->face->ot_layout->gsub); const GSUB &gsub = *(c->face->ot_layout->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index); const SubstLookup &l = gsub.get_lookup (lookup_index);
if (unlikely (c->nesting_level_left == 0)) if (unlikely (c->nesting_level_left == 0))
@ -922,7 +922,7 @@ static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup
if (unlikely (c->context_length < 1)) if (unlikely (c->context_length < 1))
return false; return false;
return l.apply_once (c->layout, c->buffer, c->lookup_mask, c->context_length, c->nesting_level_left - 1); return l.apply_once (c->face, c->buffer, c->lookup_mask, c->context_length, c->nesting_level_left - 1);
} }

View File

@ -53,7 +53,8 @@ HB_BEGIN_DECLS
struct hb_apply_context_t struct hb_apply_context_t
{ {
unsigned int debug_depth; unsigned int debug_depth;
hb_ot_layout_context_t *layout; hb_font_t *font;
hb_face_t *face;
hb_buffer_t *buffer; hb_buffer_t *buffer;
hb_mask_t lookup_mask; hb_mask_t lookup_mask;
unsigned int context_length; unsigned int context_length;
@ -133,7 +134,7 @@ static inline bool match_input (hb_apply_context_t *c,
for (i = 1, j = c->buffer->i + 1; i < count; i++, j++) for (i = 1, j = c->buffer->i + 1; i < count; i++, j++)
{ {
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_props, NULL)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, NULL))
{ {
if (unlikely (j + count - i == end)) if (unlikely (j + count - i == end))
return false; return false;
@ -160,7 +161,7 @@ static inline bool match_backtrack (hb_apply_context_t *c,
for (unsigned int i = 0, j = c->buffer->backtrack_len () - 1; i < count; i++, j--) for (unsigned int i = 0, j = c->buffer->backtrack_len () - 1; i < count; i++, j--)
{ {
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->out_info[j], c->lookup_props, NULL)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->out_info[j], c->lookup_props, NULL))
{ {
if (unlikely (j + 1 == count - i)) if (unlikely (j + 1 == count - i))
return false; return false;
@ -188,7 +189,7 @@ static inline bool match_lookahead (hb_apply_context_t *c,
for (i = 0, j = c->buffer->i + offset; i < count; i++, j++) for (i = 0, j = c->buffer->i + offset; i < count; i++, j++)
{ {
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_props, NULL)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[j], c->lookup_props, NULL))
{ {
if (unlikely (j + count - i == end)) if (unlikely (j + count - i == end))
return false; return false;
@ -242,7 +243,7 @@ static inline bool apply_lookup (hb_apply_context_t *c,
*/ */
for (unsigned int i = 0; i < count; /* NOP */) for (unsigned int i = 0; i < count; /* NOP */)
{ {
while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_props, NULL)) while (_hb_ot_layout_skip_mark (c->face, &c->buffer->info[c->buffer->i], c->lookup_props, NULL))
{ {
if (unlikely (c->buffer->i == end)) if (unlikely (c->buffer->i == end))
return true; return true;

View File

@ -96,19 +96,6 @@ struct hb_ot_layout_t
const struct head *head; const struct head *head;
}; };
struct hb_ot_layout_context_t
{
hb_face_t *face;
hb_font_t *font;
/* Convert from font-space to user-space */
inline hb_position_t scale_x (int16_t v) { return scale (v, this->font->x_scale); }
inline hb_position_t scale_y (int16_t v) { return scale (v, this->font->y_scale); }
private:
inline hb_position_t scale (int16_t v, int scale) { return v * (int64_t) scale / _hb_ot_layout_get_upem (this->face); }
};
HB_INTERNAL hb_ot_layout_t * HB_INTERNAL hb_ot_layout_t *
_hb_ot_layout_create (hb_face_t *face); _hb_ot_layout_create (hb_face_t *face);

View File

@ -203,10 +203,7 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font,
unsigned int *caret_count /* IN/OUT */, unsigned int *caret_count /* IN/OUT */,
int *caret_array /* OUT */) int *caret_array /* OUT */)
{ {
hb_ot_layout_context_t c; return _get_gdef (font->face).get_lig_carets (font, direction, glyph, start_offset, caret_count, caret_array);
c.font = font;
c.face = font->face;
return _get_gdef (c.face).get_lig_carets (&c, direction, glyph, start_offset, caret_count, caret_array);
} }
/* /*
@ -448,10 +445,7 @@ hb_ot_layout_substitute_lookup (hb_face_t *face,
unsigned int lookup_index, unsigned int lookup_index,
hb_mask_t mask) hb_mask_t mask)
{ {
hb_ot_layout_context_t c; return _get_gsub (face).substitute_lookup (face, buffer, lookup_index, mask);
c.font = NULL;
c.face = face;
return _get_gsub (face).substitute_lookup (&c, buffer, lookup_index, mask);
} }
@ -477,10 +471,7 @@ hb_ot_layout_position_lookup (hb_font_t *font,
unsigned int lookup_index, unsigned int lookup_index,
hb_mask_t mask) hb_mask_t mask)
{ {
hb_ot_layout_context_t c; return _get_gpos (font->face).position_lookup (font, buffer, lookup_index, mask);
c.font = font;
c.face = font->face;
return _get_gpos (c.face).position_lookup (&c, buffer, lookup_index, mask);
} }
void void