[GPOS] Start filling apply() functions in
This commit is contained in:
parent
4fa77d3c43
commit
056c7ec1ae
|
@ -79,6 +79,7 @@ _hb_buffer_allocate_ligid( HB_Buffer buffer );
|
||||||
#define IN_LIGID( pos ) (buffer->in_string[(pos)].ligID)
|
#define IN_LIGID( pos ) (buffer->in_string[(pos)].ligID)
|
||||||
#define IN_COMPONENT( pos ) (buffer->in_string[(pos)].component)
|
#define IN_COMPONENT( pos ) (buffer->in_string[(pos)].component)
|
||||||
#define POSITION( pos ) (&buffer->positions[(pos)])
|
#define POSITION( pos ) (&buffer->positions[(pos)])
|
||||||
|
#define CURPOSITION() (&buffer->positions[buffer->in_pos])
|
||||||
#define OUT_GLYPH( pos ) (buffer->out_string[(pos)].gindex)
|
#define OUT_GLYPH( pos ) (buffer->out_string[(pos)].gindex)
|
||||||
#define OUT_ITEM( pos ) (&buffer->out_string[(pos)])
|
#define OUT_ITEM( pos ) (&buffer->out_string[(pos)])
|
||||||
|
|
||||||
|
|
|
@ -354,9 +354,6 @@ HB_INTERNAL HB_Error
|
||||||
_hb_buffer_replace_glyph( HB_Buffer buffer,
|
_hb_buffer_replace_glyph( HB_Buffer buffer,
|
||||||
HB_UInt glyph_index )
|
HB_UInt glyph_index )
|
||||||
{
|
{
|
||||||
|
|
||||||
HB_Error error;
|
|
||||||
|
|
||||||
if ( !buffer->separate_out )
|
if ( !buffer->separate_out )
|
||||||
{
|
{
|
||||||
buffer->out_string[buffer->out_pos].gindex = glyph_index;
|
buffer->out_string[buffer->out_pos].gindex = glyph_index;
|
||||||
|
|
|
@ -404,24 +404,31 @@ ASSERT_SIZE (ClassDef, 2);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct Device {
|
struct Device {
|
||||||
int get_delta (int ppem_size) const {
|
int get_delta (unsigned int ppem_size) const {
|
||||||
if (ppem_size >= startSize && ppem_size <= endSize &&
|
|
||||||
deltaFormat >= 1 && deltaFormat <= 3) {
|
|
||||||
int s = ppem_size - startSize;
|
|
||||||
int f = deltaFormat;
|
|
||||||
|
|
||||||
uint16_t byte = deltaValue[s >> (4 - f)];
|
unsigned int f = deltaFormat;
|
||||||
uint16_t bits = byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f));
|
if (HB_UNLIKELY (f < 1 || f > 3))
|
||||||
uint16_t mask = 0xFFFF >> (16 - (1 << f));
|
return 0;
|
||||||
|
|
||||||
int delta = bits & mask;
|
if (ppem_size < startSize || ppem_size > endSize)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (delta >= ((mask + 1) >> 1))
|
unsigned int s = ppem_size - startSize;
|
||||||
delta -= mask + 1;
|
|
||||||
|
|
||||||
return delta;
|
unsigned int byte = deltaValue[s >> (4 - f)];
|
||||||
}
|
unsigned int bits = byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f));
|
||||||
return 0;
|
unsigned int mask = 0xFFFF >> (16 - (1 << f));
|
||||||
|
|
||||||
|
int delta = bits & mask;
|
||||||
|
|
||||||
|
if (delta >= ((mask + 1) >> 1))
|
||||||
|
delta -= mask + 1;
|
||||||
|
|
||||||
|
return delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int operator() (unsigned int ppem_size) const {
|
||||||
|
return get_delta (ppem_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -67,32 +67,78 @@ struct ValueRecord {
|
||||||
* PosTable (may be NULL) */
|
* PosTable (may be NULL) */
|
||||||
};
|
};
|
||||||
ASSERT_SIZE (ValueRecord, 16);
|
ASSERT_SIZE (ValueRecord, 16);
|
||||||
|
|
||||||
struct ValueFormat {
|
|
||||||
/* TODO */
|
|
||||||
|
|
||||||
private:
|
|
||||||
0x0001 xPlacement; /* Includes horizontal adjustment
|
|
||||||
* for placement */
|
|
||||||
0x0002 yPlacement; /* Includes vertical adjustment for
|
|
||||||
* placement */
|
|
||||||
0x0004 xAdvance; /* Includes horizontal adjustment
|
|
||||||
* for advance */
|
|
||||||
0x0008 yAdvance; /* Includes vertical adjustment for
|
|
||||||
* advance */
|
|
||||||
0x0010 xPlaDevice; /* Includes horizontal Device table
|
|
||||||
* for placement */
|
|
||||||
0x0020 yPlaDevice; /* Includes vertical Device table
|
|
||||||
* for placement */
|
|
||||||
0x0040 xAdvDevice; /* Includes horizontal Device table
|
|
||||||
* for advance */
|
|
||||||
0x0080 yAdvDevice; /* Includes vertical Device table
|
|
||||||
* for advance */
|
|
||||||
0xF000 reserved; /* For future use */
|
|
||||||
};
|
|
||||||
ASSERT_SIZE (ValueFormat, 18);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct ValueFormat : USHORT {
|
||||||
|
|
||||||
|
enum {
|
||||||
|
xPlacement = 0x0001, /* Includes horizontal adjustment for placement */
|
||||||
|
yPlacement = 0x0002, /* Includes vertical adjustment for placement */
|
||||||
|
xAdvance = 0x0004, /* Includes horizontal adjustment for advance */
|
||||||
|
yAdvance = 0x0008, /* Includes vertical adjustment for advance */
|
||||||
|
xPlaDevice = 0x0010, /* Includes horizontal Device table for placement */
|
||||||
|
yPlaDevice = 0x0020, /* Includes vertical Device table for placement */
|
||||||
|
xAdvDevice = 0x0040, /* Includes horizontal Device table for advance */
|
||||||
|
yAdvDevice = 0x0080, /* Includes vertical Device table for advance */
|
||||||
|
reserved = 0xF000, /* For future use */
|
||||||
|
};
|
||||||
|
|
||||||
|
inline unsigned int get_len () const {
|
||||||
|
return _hb_popcount32 ((unsigned int) *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Value* apply_value (hb_ot_layout_t *layout,
|
||||||
|
const char *base,
|
||||||
|
const Value *values,
|
||||||
|
HB_Position glyph_pos) const
|
||||||
|
{
|
||||||
|
unsigned int x_ppem, y_ppem;
|
||||||
|
hb_16dot16_t x_scale, y_scale;
|
||||||
|
unsigned int pixel_value;
|
||||||
|
unsigned int format = *this;
|
||||||
|
|
||||||
|
if (!format)
|
||||||
|
return values;
|
||||||
|
|
||||||
|
x_scale = layout->gpos_info.x_scale;
|
||||||
|
y_scale = layout->gpos_info.y_scale;
|
||||||
|
/* design units -> fractional pixel */
|
||||||
|
if (format & xPlacement)
|
||||||
|
glyph_pos->x_pos += x_scale * *(USHORT*)values++ / 0x10000;
|
||||||
|
if (format & yPlacement)
|
||||||
|
glyph_pos->y_pos += y_scale * *(USHORT*)values++ / 0x10000;
|
||||||
|
if (format & xAdvance)
|
||||||
|
glyph_pos->x_advance += x_scale * *(USHORT*)values++ / 0x10000;
|
||||||
|
if (format & yAdvance)
|
||||||
|
glyph_pos->y_advance += y_scale * *(USHORT*)values++ / 0x10000;
|
||||||
|
|
||||||
|
if (HB_LIKELY (!layout->gpos_info.dvi))
|
||||||
|
{
|
||||||
|
x_ppem = layout->gpos_info.x_ppem;
|
||||||
|
y_ppem = layout->gpos_info.y_ppem;
|
||||||
|
/* pixel -> fractional pixel */
|
||||||
|
if (format & xPlaDevice)
|
||||||
|
glyph_pos->x_pos += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 6;
|
||||||
|
if (format & yPlaDevice)
|
||||||
|
glyph_pos->y_pos += (base+*(OffsetTo<Device>*)values++).get_delta (y_ppem) << 6;
|
||||||
|
if (format & xAdvDevice)
|
||||||
|
glyph_pos->x_advance += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 6;
|
||||||
|
if (format & yAdvDevice)
|
||||||
|
glyph_pos->y_advance += (base+*(OffsetTo<Device>*)values++).get_delta (y_ppem) << 6;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (format & xPlaDevice) values++;
|
||||||
|
if (format & yPlaDevice) values++;
|
||||||
|
if (format & xAdvDevice) values++;
|
||||||
|
if (format & yAdvDevice) values++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ASSERT_SIZE (ValueFormat, 2);
|
||||||
|
|
||||||
|
|
||||||
struct AnchorFormat1 {
|
struct AnchorFormat1 {
|
||||||
|
|
||||||
|
@ -212,8 +258,13 @@ struct SinglePosFormat1 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool apply (APPLY_ARG_DEF) const {
|
inline bool apply (APPLY_ARG_DEF) const {
|
||||||
/* TODO */
|
|
||||||
return false;
|
unsigned int index = (this+coverage) (IN_CURGLYPH ());
|
||||||
|
if (HB_LIKELY (index == NOT_COVERED))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
valueFormat.apply_value (layout, (const char *) this, values, CURPOSITION ());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -221,7 +272,7 @@ struct SinglePosFormat1 {
|
||||||
OffsetTo<Coverage>
|
OffsetTo<Coverage>
|
||||||
coverage; /* Offset to Coverage table--from
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of subtable */
|
* beginning of subtable */
|
||||||
USHORT valueFormat; /* Defines the types of data in the
|
ValueFormat valueFormat; /* Defines the types of data in the
|
||||||
* ValueRecord */
|
* ValueRecord */
|
||||||
ValueRecord values; /* Defines positioning
|
ValueRecord values; /* Defines positioning
|
||||||
* value(s)--applied to all glyphs in
|
* value(s)--applied to all glyphs in
|
||||||
|
@ -235,8 +286,18 @@ struct SinglePosFormat2 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool apply (APPLY_ARG_DEF) const {
|
inline bool apply (APPLY_ARG_DEF) const {
|
||||||
/* TODO */
|
|
||||||
return false;
|
unsigned int index = (this+coverage) (IN_CURGLYPH ());
|
||||||
|
if (HB_LIKELY (index == NOT_COVERED))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (HB_LIKELY (index >= valueCount))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
valueFormat.apply_value (layout, (const char *) this,
|
||||||
|
values + index * valueFormat.get_len (),
|
||||||
|
CURPOSITION ());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -244,7 +305,7 @@ struct SinglePosFormat2 {
|
||||||
OffsetTo<Coverage>
|
OffsetTo<Coverage>
|
||||||
coverage; /* Offset to Coverage table--from
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of subtable */
|
* beginning of subtable */
|
||||||
USHORT valueFormat; /* Defines the types of data in the
|
ValueFormat valueFormat; /* Defines the types of data in the
|
||||||
* ValueRecord */
|
* ValueRecord */
|
||||||
USHORT valueCount; /* Number of ValueRecords */
|
USHORT valueCount; /* Number of ValueRecords */
|
||||||
ValueRecord values; /* Array of ValueRecords--positioning
|
ValueRecord values; /* Array of ValueRecords--positioning
|
||||||
|
@ -307,10 +368,10 @@ struct PairPosFormat1 {
|
||||||
OffsetTo<Coverage>
|
OffsetTo<Coverage>
|
||||||
coverage; /* Offset to Coverage table--from
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of subtable */
|
* beginning of subtable */
|
||||||
USHORT valueFormat1; /* Defines the types of data in
|
ValueFormat valueFormat1; /* Defines the types of data in
|
||||||
* ValueRecord1--for the first glyph
|
* ValueRecord1--for the first glyph
|
||||||
* in the pair--may be zero (0) */
|
* in the pair--may be zero (0) */
|
||||||
USHORT valueFormat2; /* Defines the types of data in
|
ValueFormat valueFormat2; /* Defines the types of data in
|
||||||
* ValueRecord2--for the second glyph
|
* ValueRecord2--for the second glyph
|
||||||
* in the pair--may be zero (0) */
|
* in the pair--may be zero (0) */
|
||||||
OffsetArrayOf<PairSet>
|
OffsetArrayOf<PairSet>
|
||||||
|
@ -334,10 +395,10 @@ struct PairPosFormat2 {
|
||||||
OffsetTo<Coverage>
|
OffsetTo<Coverage>
|
||||||
coverage; /* Offset to Coverage table--from
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of subtable */
|
* beginning of subtable */
|
||||||
USHORT valueFormat1; /* ValueRecord definition--for the
|
ValueFormat valueFormat1; /* ValueRecord definition--for the
|
||||||
* first glyph of the pair--may be zero
|
* first glyph of the pair--may be zero
|
||||||
* (0) */
|
* (0) */
|
||||||
USHORT valueFormat2; /* ValueRecord definition--for the
|
ValueFormat valueFormat2; /* ValueRecord definition--for the
|
||||||
* second glyph of the pair--may be
|
* second glyph of the pair--may be
|
||||||
* zero (0) */
|
* zero (0) */
|
||||||
OffsetTo<ClassDef>
|
OffsetTo<ClassDef>
|
||||||
|
|
Loading…
Reference in New Issue