mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 14:01:10 +01:00
[trak] Handle "out-of-range" values better
If requested size < min-size, use the value for min-size. If requested size > max-size, use the value for max-size. This is the only way that makes sense. Extrapolating as we were doing, is just wrong... This also seems to match what CoreText does. Adjacent to fixing https://github.com/harfbuzz/harfbuzz/issues/5054
This commit is contained in:
1 parent
691cc93976
commit
b1677e76aa
2 files changed
+17
-9
No files matched your search
@@ -119,17 +119,26 @@ struct TrackData
|
||||
/*
|
||||
* Choose size.
|
||||
*/
|
||||
unsigned int sizes = nSizes;
|
||||
if (!sizes) return 0;
|
||||
if (sizes == 1) return trackTableEntry->get_value (base, 0, sizes);
|
||||
count = nSizes;
|
||||
if (!count) return 0;
|
||||
if (count == 1) return trackTableEntry->get_value (base, 0, count);
|
||||
|
||||
hb_array_t<const F16DOT16> size_table ((base+sizeTable).arrayZ, sizes);
|
||||
// At least two entries.
|
||||
|
||||
hb_array_t<const F16DOT16> size_table ((base+sizeTable).arrayZ, count);
|
||||
unsigned int size_index;
|
||||
for (size_index = 0; size_index < sizes - 1; size_index++)
|
||||
for (size_index = 0; size_index < count; size_index++)
|
||||
if (size_table[size_index].to_float () >= ptem)
|
||||
break;
|
||||
|
||||
return roundf (interpolate_at (size_index ? size_index - 1 : 0, ptem,
|
||||
if (size_index == 0)
|
||||
return trackTableEntry->get_value (base, 0, count);
|
||||
if (size_index == count)
|
||||
return trackTableEntry->get_value (base, count - 1, count);
|
||||
|
||||
// Interpolate.
|
||||
|
||||
return roundf (interpolate_at (size_index - 1, ptem,
|
||||
*trackTableEntry, base));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
../fonts/TRAK.ttf;--font-ptem=9;U+0041,U+0042,U+0043;[A.alt=0@30,0+1060|B=1@30,0+1060|C.alt=2@30,0+1060]
|
||||
../fonts/TRAK.ttf;--font-ptem=24;U+0041,U+0042,U+0043;[A.alt=0@-7,0+986|B=1@-7,0+986|C.alt=2@-7,0+986]
|
||||
../fonts/TRAK.ttf;--font-ptem=72;U+0041,U+0042,U+0043;[A.alt=0@-35,0+929|B=1@-35,0+929|C.alt=2@-35,0+929]
|
||||
../fonts/TRAK.ttf;--font-ptem=144;U+0041,U+0042,U+0043;[A.alt=0@-78,0+843|B=1@-78,0+843|C.alt=2@-78,0+843]
|
||||
../fonts/TRAK.ttf;--font-ptem=144;U+0041,U+0042,U+0043;[A.alt=0@-78,0+843|B=1@-78,0+843|C.alt=2@-78,0+843]
|
||||
../fonts/TRAK.ttf;--font-ptem=144;U+0041,U+0042,U+0043;[A.alt=0@-50,0+900|B=1@-50,0+900|C.alt=2@-50,0+900]
|
||||
../fonts/TRAK.ttf;--font-ptem=144 --features=-trak;U+0041,U+0042,U+0043;[A.alt=0+1000|B=1+1000|C.alt=2+1000]
|
||||
../fonts/TRAK.ttf;--font-ptem=144 --features=-trak[1:3];U+0041,U+0042,U+0043,U+0041,U+0042,U+0043;[A.alt=0@-78,0+843|B=1+1000|C.alt=2+1000|A.alt=3@-78,0+843|B=4@-78,0+843|C.alt=5@-78,0+843]
|
||||
../fonts/TRAK.ttf;--font-ptem=144 --features=-trak[1:3];U+0041,U+0042,U+0043,U+0041,U+0042,U+0043;[A.alt=0@-50,0+900|B=1+1000|C.alt=2+1000|A.alt=3@-50,0+900|B=4@-50,0+900|C.alt=5@-50,0+900]
|
||||
Reference in new issue
Block a user