[trak] Fix calc
We were getting the first track record always. Ie. this line: if (trackTable[i].get_track_value () == 0.f) { - trackTableEntry = &trackTable[0]; + trackTableEntry = &trackTable[i]; break; } The rest is cleanup. Fixes https://github.com/harfbuzz/harfbuzz/issues/1263 for the most part.
This commit is contained in:
parent
3341c7fbfb
commit
9d42d70269
|
@ -93,12 +93,11 @@ struct TrackData
|
||||||
float s0 = size_table[idx].to_float ();
|
float s0 = size_table[idx].to_float ();
|
||||||
float s1 = size_table[idx + 1].to_float ();
|
float s1 = size_table[idx + 1].to_float ();
|
||||||
float t = unlikely (s0 == s1) ? 0.f : (target_size - s0) / (s1 - s0);
|
float t = unlikely (s0 == s1) ? 0.f : (target_size - s0) / (s1 - s0);
|
||||||
return (float) t * trackTableEntry.get_value (base, idx + 1, sizes) +
|
return t * trackTableEntry.get_value (base, idx + 1, sizes) +
|
||||||
((float) 1.0 - t) * trackTableEntry.get_value (base, idx, sizes);
|
(1.f - t) * trackTableEntry.get_value (base, idx, sizes);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float get_tracking (const void *base, float ptem) const
|
inline int get_tracking (const void *base, float ptem) const
|
||||||
{
|
{
|
||||||
/* CoreText points are CSS pixels (96 per inch),
|
/* CoreText points are CSS pixels (96 per inch),
|
||||||
* NOT typographic points (72 per inch).
|
* NOT typographic points (72 per inch).
|
||||||
|
@ -121,7 +120,7 @@ struct TrackData
|
||||||
|
|
||||||
if (trackTable[i].get_track_value () == 0.f)
|
if (trackTable[i].get_track_value () == 0.f)
|
||||||
{
|
{
|
||||||
trackTableEntry = &trackTable[0];
|
trackTableEntry = &trackTable[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,8 +140,8 @@ struct TrackData
|
||||||
if (size_table[size_index].to_float () >= csspx)
|
if (size_table[size_index].to_float () >= csspx)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
return interpolate_at (size_index ? size_index - 1 : 0, csspx,
|
return round (interpolate_at (size_index ? size_index - 1 : 0, csspx,
|
||||||
*trackTableEntry, base);
|
*trackTableEntry, base));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||||
|
@ -193,7 +192,7 @@ struct trak
|
||||||
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
|
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
|
||||||
{
|
{
|
||||||
const TrackData &trackData = this+horizData;
|
const TrackData &trackData = this+horizData;
|
||||||
float tracking = trackData.get_tracking (this, ptem);
|
int tracking = trackData.get_tracking (this, ptem);
|
||||||
hb_position_t offset_to_add = c->font->em_scalef_x (tracking / 2);
|
hb_position_t offset_to_add = c->font->em_scalef_x (tracking / 2);
|
||||||
hb_position_t advance_to_add = c->font->em_scalef_x (tracking);
|
hb_position_t advance_to_add = c->font->em_scalef_x (tracking);
|
||||||
foreach_grapheme (buffer, start, end)
|
foreach_grapheme (buffer, start, end)
|
||||||
|
@ -205,7 +204,7 @@ struct trak
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const TrackData &trackData = this+vertData;
|
const TrackData &trackData = this+vertData;
|
||||||
float tracking = trackData.get_tracking (this, ptem);
|
int tracking = trackData.get_tracking (this, ptem);
|
||||||
hb_position_t offset_to_add = c->font->em_scalef_y (tracking / 2);
|
hb_position_t offset_to_add = c->font->em_scalef_y (tracking / 2);
|
||||||
hb_position_t advance_to_add = c->font->em_scalef_y (tracking);
|
hb_position_t advance_to_add = c->font->em_scalef_y (tracking);
|
||||||
foreach_grapheme (buffer, start, end)
|
foreach_grapheme (buffer, start, end)
|
||||||
|
|
Loading…
Reference in New Issue