[trak] Choose closest trak track to 0.0

Seems to be what CT does. Needs more testing to adjust better, but
for now it's better than before.
This commit is contained in:
Behdad Esfahbod 2025-02-06 17:40:10 +00:00
parent 8efd2d85c7
commit 6a37a65276

View file

@ -98,14 +98,17 @@ struct TrackData
*/
const TrackTableEntry *trackTableEntry = nullptr;
unsigned int count = nTracks;
float last_trak = 1e5;
for (unsigned int i = 0; i < count; 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 */
/* Not sure what CoreText does, but it looks to apply a trak=1.0 by default
* if there is no 0.0 trak. So, just pick the one closest to 0.0. */
if (trackTable[i].get_track_value () == 0.f)
float trak = trackTable[i].get_track_value ();
if (fabsf (trak) < fabsf (last_trak))
{
trackTableEntry = &trackTable[i];
break;