< prev index next >
src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-layout-gpos-table.hh
Print this page
*** 101,122 ****
inline unsigned int get_len (void) const
{ return _hb_popcount32 ((unsigned int) *this); }
inline unsigned int get_size (void) const
{ return get_len () * Value::static_size; }
! void apply_value (hb_font_t *font,
! hb_direction_t direction,
const void *base,
const Value *values,
hb_glyph_position_t &glyph_pos) const
{
- unsigned int x_ppem, y_ppem;
unsigned int format = *this;
- hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (direction);
-
if (!format) return;
if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short (values++));
if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short (values++));
if (format & xAdvance) {
if (likely (horizontal)) glyph_pos.x_advance += font->em_scale_x (get_short (values));
values++;
--- 101,121 ----
inline unsigned int get_len (void) const
{ return _hb_popcount32 ((unsigned int) *this); }
inline unsigned int get_size (void) const
{ return get_len () * Value::static_size; }
! void apply_value (hb_apply_context_t *c,
const void *base,
const Value *values,
hb_glyph_position_t &glyph_pos) const
{
unsigned int format = *this;
if (!format) return;
+ hb_font_t *font = c->font;
+ hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (c->direction);
+
if (format & xPlacement) glyph_pos.x_offset += font->em_scale_x (get_short (values++));
if (format & yPlacement) glyph_pos.y_offset += font->em_scale_y (get_short (values++));
if (format & xAdvance) {
if (likely (horizontal)) glyph_pos.x_advance += font->em_scale_x (get_short (values));
values++;
*** 127,157 ****
values++;
}
if (!has_device ()) return;
! x_ppem = font->x_ppem;
! y_ppem = font->y_ppem;
! if (!x_ppem && !y_ppem) return;
/* pixel -> fractional pixel */
if (format & xPlaDevice) {
! if (x_ppem) glyph_pos.x_offset += (base + get_device (values)).get_x_delta (font);
values++;
}
if (format & yPlaDevice) {
! if (y_ppem) glyph_pos.y_offset += (base + get_device (values)).get_y_delta (font);
values++;
}
if (format & xAdvDevice) {
! if (horizontal && x_ppem) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font);
values++;
}
if (format & yAdvDevice) {
/* y_advance values grow downward but font-space grows upward, hence negation */
! if (!horizontal && y_ppem) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font);
values++;
}
}
private:
--- 126,158 ----
values++;
}
if (!has_device ()) return;
! bool use_x_device = font->x_ppem || font->num_coords;
! bool use_y_device = font->y_ppem || font->num_coords;
! if (!use_x_device && !use_y_device) return;
!
! const VariationStore &store = c->var_store;
/* pixel -> fractional pixel */
if (format & xPlaDevice) {
! if (use_x_device) glyph_pos.x_offset += (base + get_device (values)).get_x_delta (font, store);
values++;
}
if (format & yPlaDevice) {
! if (use_y_device) glyph_pos.y_offset += (base + get_device (values)).get_y_delta (font, store);
values++;
}
if (format & xAdvDevice) {
! if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font, store);
values++;
}
if (format & yAdvDevice) {
/* y_advance values grow downward but font-space grows upward, hence negation */
! if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font, store);
values++;
}
}
private:
*** 229,241 ****
};
struct AnchorFormat1
{
! inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
*x = font->em_scale_x (xCoordinate);
*y = font->em_scale_y (yCoordinate);
}
inline bool sanitize (hb_sanitize_context_t *c) const
--- 230,243 ----
};
struct AnchorFormat1
{
! inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
+ hb_font_t *font = c->font;
*x = font->em_scale_x (xCoordinate);
*y = font->em_scale_y (yCoordinate);
}
inline bool sanitize (hb_sanitize_context_t *c) const
*** 252,264 ****
DEFINE_SIZE_STATIC (6);
};
struct AnchorFormat2
{
! inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
unsigned int x_ppem = font->x_ppem;
unsigned int y_ppem = font->y_ppem;
hb_position_t cx, cy;
hb_bool_t ret;
--- 254,267 ----
DEFINE_SIZE_STATIC (6);
};
struct AnchorFormat2
{
! inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id,
hb_position_t *x, hb_position_t *y) const
{
+ hb_font_t *font = c->font;
unsigned int x_ppem = font->x_ppem;
unsigned int y_ppem = font->y_ppem;
hb_position_t cx, cy;
hb_bool_t ret;
*** 283,302 ****
DEFINE_SIZE_STATIC (8);
};
struct AnchorFormat3
{
! inline void get_anchor (hb_font_t *font, hb_codepoint_t glyph_id HB_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
*x = font->em_scale_x (xCoordinate);
*y = font->em_scale_y (yCoordinate);
! if (font->x_ppem)
! *x += (this+xDeviceTable).get_x_delta (font);
! if (font->y_ppem)
! *y += (this+yDeviceTable).get_x_delta (font);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
--- 286,306 ----
DEFINE_SIZE_STATIC (8);
};
struct AnchorFormat3
{
! inline void get_anchor (hb_apply_context_t *c, hb_codepoint_t glyph_id HB_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
+ hb_font_t *font = c->font;
*x = font->em_scale_x (xCoordinate);
*y = font->em_scale_y (yCoordinate);
! if (font->x_ppem || font->num_coords)
! *x += (this+xDeviceTable).get_x_delta (font, c->var_store);
! if (font->y_ppem || font->num_coords)
! *y += (this+yDeviceTable).get_y_delta (font, c->var_store);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
*** 319,336 ****
DEFINE_SIZE_STATIC (10);
};
struct Anchor
{
! inline void get_anchor (hb_font_t *font, 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 (font, glyph_id, x, y); return;
! case 2: u.format2.get_anchor (font, glyph_id, x, y); return;
! case 3: u.format3.get_anchor (font, glyph_id, x, y); return;
default: return;
}
}
inline bool sanitize (hb_sanitize_context_t *c) const
--- 323,340 ----
DEFINE_SIZE_STATIC (10);
};
struct Anchor
{
! inline void get_anchor (hb_apply_context_t *c, 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 (c, glyph_id, x, y); return;
! case 2: u.format2.get_anchor (c, glyph_id, x, y); return;
! case 3: u.format3.get_anchor (c, glyph_id, x, y); return;
default: return;
}
}
inline bool sanitize (hb_sanitize_context_t *c) const
*** 368,378 ****
inline bool sanitize (hb_sanitize_context_t *c, unsigned int cols) const
{
TRACE_SANITIZE (this);
if (!c->check_struct (this)) return_trace (false);
! if (unlikely (rows > 0 && cols >= ((unsigned int) -1) / rows)) return_trace (false);
unsigned int count = rows * cols;
if (!c->check_array (matrixZ, matrixZ[0].static_size, count)) return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (!matrixZ[i].sanitize (c, this)) return_trace (false);
return_trace (true);
--- 372,382 ----
inline bool sanitize (hb_sanitize_context_t *c, unsigned int cols) const
{
TRACE_SANITIZE (this);
if (!c->check_struct (this)) return_trace (false);
! if (unlikely (_hb_unsigned_int_mul_overflows (rows, cols))) return_trace (false);
unsigned int count = rows * cols;
if (!c->check_array (matrixZ, matrixZ[0].static_size, count)) return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (!matrixZ[i].sanitize (c, this)) return_trace (false);
return_trace (true);
*** 426,437 ****
* return false such that the subsequent subtables have a chance at it. */
if (unlikely (!found)) return_trace (false);
hb_position_t mark_x, mark_y, base_x, base_y;
! mark_anchor.get_anchor (c->font, buffer->cur().codepoint, &mark_x, &mark_y);
! glyph_anchor.get_anchor (c->font, buffer->info[glyph_pos].codepoint, &base_x, &base_y);
hb_glyph_position_t &o = buffer->cur_pos();
o.x_offset = base_x - mark_x;
o.y_offset = base_y - mark_y;
o.attach_type() = ATTACH_TYPE_MARK;
--- 430,441 ----
* return false such that the subsequent subtables have a chance at it. */
if (unlikely (!found)) return_trace (false);
hb_position_t mark_x, mark_y, base_x, base_y;
! mark_anchor.get_anchor (c, buffer->cur().codepoint, &mark_x, &mark_y);
! glyph_anchor.get_anchor (c, buffer->info[glyph_pos].codepoint, &base_x, &base_y);
hb_glyph_position_t &o = buffer->cur_pos();
o.x_offset = base_x - mark_x;
o.y_offset = base_y - mark_y;
o.attach_type() = ATTACH_TYPE_MARK;
*** 470,481 ****
TRACE_APPLY (this);
hb_buffer_t *buffer = c->buffer;
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
! valueFormat.apply_value (c->font, c->direction, this,
! values, buffer->cur_pos());
buffer->idx++;
return_trace (true);
}
--- 474,484 ----
TRACE_APPLY (this);
hb_buffer_t *buffer = c->buffer;
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
! valueFormat.apply_value (c, this, values, buffer->cur_pos());
buffer->idx++;
return_trace (true);
}
*** 521,531 ****
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
if (likely (index >= valueCount)) return_trace (false);
! valueFormat.apply_value (c->font, c->direction, this,
&values[index * valueFormat.get_len ()],
buffer->cur_pos());
buffer->idx++;
return_trace (true);
--- 524,534 ----
unsigned int index = (this+coverage).get_coverage (buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
if (likely (index >= valueCount)) return_trace (false);
! valueFormat.apply_value (c, this,
&values[index * valueFormat.get_len ()],
buffer->cur_pos());
buffer->idx++;
return_trace (true);
*** 638,651 ****
max = mid - 1;
else if (x > mid_x)
min = mid + 1;
else
{
! valueFormats[0].apply_value (c->font, c->direction, this,
! &record->values[0], buffer->cur_pos());
! valueFormats[1].apply_value (c->font, c->direction, this,
! &record->values[len1], buffer->pos[pos]);
if (len2)
pos++;
buffer->idx = pos;
return_trace (true);
}
--- 641,652 ----
max = mid - 1;
else if (x > mid_x)
min = mid + 1;
else
{
! valueFormats[0].apply_value (c, this, &record->values[0], buffer->cur_pos());
! valueFormats[1].apply_value (c, this, &record->values[len1], buffer->pos[pos]);
if (len2)
pos++;
buffer->idx = pos;
return_trace (true);
}
*** 687,697 ****
{
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (c->input);
unsigned int count = pairSet.len;
for (unsigned int i = 0; i < count; i++)
! (this+pairSet[i]).collect_glyphs (c, &valueFormat1);
}
inline const Coverage &get_coverage (void) const
{
return this+coverage;
--- 688,698 ----
{
TRACE_COLLECT_GLYPHS (this);
(this+coverage).add_coverage (c->input);
unsigned int count = pairSet.len;
for (unsigned int i = 0; i < count; i++)
! (this+pairSet[i]).collect_glyphs (c, valueFormat);
}
inline const Coverage &get_coverage (void) const
{
return this+coverage;
*** 706,729 ****
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
if (!skippy_iter.next ()) return_trace (false);
! return_trace ((this+pairSet[index]).apply (c, &valueFormat1, skippy_iter.idx));
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
if (!c->check_struct (this)) return_trace (false);
! unsigned int len1 = valueFormat1.get_len ();
! unsigned int len2 = valueFormat2.get_len ();
PairSet::sanitize_closure_t closure = {
this,
! &valueFormat1,
len1,
1 + len1 + len2
};
return_trace (coverage.sanitize (c, this) && pairSet.sanitize (c, this, &closure));
--- 707,730 ----
hb_apply_context_t::skipping_iterator_t &skippy_iter = c->iter_input;
skippy_iter.reset (buffer->idx, 1);
if (!skippy_iter.next ()) return_trace (false);
! return_trace ((this+pairSet[index]).apply (c, valueFormat, skippy_iter.idx));
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
if (!c->check_struct (this)) return_trace (false);
! unsigned int len1 = valueFormat[0].get_len ();
! unsigned int len2 = valueFormat[1].get_len ();
PairSet::sanitize_closure_t closure = {
this,
! valueFormat,
len1,
1 + len1 + len2
};
return_trace (coverage.sanitize (c, this) && pairSet.sanitize (c, this, &closure));
*** 732,745 ****
protected:
USHORT format; /* Format identifier--format = 1 */
OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of subtable */
! ValueFormat valueFormat1; /* Defines the types of data in
* ValueRecord1--for the first glyph
* in the pair--may be zero (0) */
! ValueFormat valueFormat2; /* Defines the types of data in
* ValueRecord2--for the second glyph
* in the pair--may be zero (0) */
OffsetArrayOf<PairSet>
pairSet; /* Array of PairSet tables
* ordered by Coverage Index */
--- 733,746 ----
protected:
USHORT format; /* Format identifier--format = 1 */
OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of subtable */
! ValueFormat valueFormat[2]; /* [0] Defines the types of data in
* ValueRecord1--for the first glyph
* in the pair--may be zero (0) */
! /* [1] Defines the types of data in
* ValueRecord2--for the second glyph
* in the pair--may be zero (0) */
OffsetArrayOf<PairSet>
pairSet; /* Array of PairSet tables
* ordered by Coverage Index */
*** 788,801 ****
unsigned int klass1 = (this+classDef1).get_class (buffer->cur().codepoint);
unsigned int klass2 = (this+classDef2).get_class (buffer->info[skippy_iter.idx].codepoint);
if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return_trace (false);
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
! valueFormat1.apply_value (c->font, c->direction, this,
! v, buffer->cur_pos());
! valueFormat2.apply_value (c->font, c->direction, this,
! v + len1, buffer->pos[skippy_iter.idx]);
buffer->idx = skippy_iter.idx;
if (len2)
buffer->idx++;
--- 789,800 ----
unsigned int klass1 = (this+classDef1).get_class (buffer->cur().codepoint);
unsigned int klass2 = (this+classDef2).get_class (buffer->info[skippy_iter.idx].codepoint);
if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return_trace (false);
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
! valueFormat1.apply_value (c, this, v, buffer->cur_pos());
! valueFormat2.apply_value (c, this, v + len1, buffer->pos[skippy_iter.idx]);
buffer->idx = skippy_iter.idx;
if (len2)
buffer->idx++;
*** 929,940 ****
unsigned int i = buffer->idx;
unsigned int j = skippy_iter.idx;
hb_position_t entry_x, entry_y, exit_x, exit_y;
! (this+this_record.exitAnchor).get_anchor (c->font, buffer->info[i].codepoint, &exit_x, &exit_y);
! (this+next_record.entryAnchor).get_anchor (c->font, buffer->info[j].codepoint, &entry_x, &entry_y);
hb_glyph_position_t *pos = buffer->pos;
hb_position_t d;
/* Main-direction adjustment */
--- 928,939 ----
unsigned int i = buffer->idx;
unsigned int j = skippy_iter.idx;
hb_position_t entry_x, entry_y, exit_x, exit_y;
! (this+this_record.exitAnchor).get_anchor (c, buffer->info[i].codepoint, &exit_x, &exit_y);
! (this+next_record.entryAnchor).get_anchor (c, buffer->info[j].codepoint, &entry_x, &entry_y);
hb_glyph_position_t *pos = buffer->pos;
hb_position_t d;
/* Main-direction adjustment */
*** 1517,1528 ****
TRACE_SANITIZE (this);
if (unlikely (!GSUBGPOS::sanitize (c))) return_trace (false);
const OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
return_trace (list.sanitize (c, this));
}
- public:
- DEFINE_SIZE_STATIC (10);
};
static void
reverse_cursive_minor_offset (hb_glyph_position_t *pos, unsigned int i, hb_direction_t direction, unsigned int new_parent)
--- 1516,1525 ----
< prev index next >