From a5be380cae9b49ed85c8620f1921209ef61a72ad Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 11 Oct 2018 10:29:02 -0400 Subject: [PATCH] [trak] More --- src/hb-aat-layout-trak-table.hh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index dbad449..9054922 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 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 -- 2.7.4