diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2018-10-11 10:29:02 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2018-10-11 10:29:02 -0400 |
commit | a5be380cae9b49ed85c8620f1921209ef61a72ad (patch) | |
tree | ab908cdb9f4bc014bc477d83bd066f6817a4c36c | |
parent | d06c4a867f0d383d8c27f2957e646d9e3fe6853b (diff) |
[trak] More
-rw-r--r-- | src/hb-aat-layout-trak-table.hh | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index dbad449b..9054922b 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -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 + 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]; + { + 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 |