[trak] More

This commit is contained in:
Behdad Esfahbod 2018-10-11 10:29:02 -04:00
parent d06c4a867f
commit a5be380cae
1 changed files with 18 additions and 10 deletions

View File

@ -98,33 +98,41 @@ struct TrackData
unsigned int sizes = nSizes;
const TrackTableEntry *trackTableEntry = nullptr;
for (unsigned int i = 0; i < sizes; ++i)
// For now we only seek for track entries with zero tracking value
if (trackTable[i].get_track_value () == 0.f)
trackTableEntry = &trackTable[0];
for (unsigned int i = 0; i < sizes; i++)
{
/* Note: Seems like the track entries are sorted by values. But the
* spec doesn't explicitly say that. It just mentions it in the example. */
/* For now we only seek for track entries with zero tracking value */
if (trackTable[i].get_track_value () == 0.f)
{
trackTableEntry = &trackTable[0];
break;
}
}
// We couldn't match any, exit
if (!trackTableEntry) return 0.;
/* TODO bfind() */
unsigned int size_index;
UnsizedArrayOf<Fixed> size_table = base+sizeTable;
for (size_index = 0; size_index < sizes; ++size_index)
for (size_index = 0; size_index < sizes; size_index++)
if (size_table[size_index] >= fixed_size)
break;
// TODO(ebraminio): We don't attempt to extrapolate to larger or
// smaller values for now but we should do, per spec
if (size_index == sizes)
return trackTableEntry->get_value (base, sizes - 1, nSizes);
return trackTableEntry->get_value (base, sizes - 1, sizes);
if (size_index == 0 || size_table[size_index] == fixed_size)
return trackTableEntry->get_value (base, size_index, nSizes);
return trackTableEntry->get_value (base, size_index, sizes);
float s0 = size_table[size_index - 1].to_float ();
float s1 = size_table[size_index].to_float ();
float t = (csspx - s0) / (s1 - s0);
return (float) t * trackTableEntry->get_value (base, size_index, nSizes) +
((float) 1.0 - t) * trackTableEntry->get_value (base, size_index - 1, nSizes);
return (float) t * trackTableEntry->get_value (base, size_index, sizes) +
((float) 1.0 - t) * trackTableEntry->get_value (base, size_index - 1, sizes);
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const