[beyond-64k] Add SinglePos formats 3/4

This commit is contained in:
Behdad Esfahbod committed 2026-06-05 12:34:51 +02:00
1 parent 8647a429ce
commit 155c19c216
3 files changed
+42 -10

No files matched your search

+31 -2
View File
@@ -13,8 +13,12 @@ struct SinglePos
protected:
union {
struct { HBUINT16 v; } format; /* Format identifier */
SinglePosFormat1 format1;
SinglePosFormat2 format2;
SinglePosFormat1_3<SmallTypes> format1;
SinglePosFormat2_4<SmallTypes> format2;
#ifndef HB_NO_BEYOND_64K
SinglePosFormat1_3<MediumTypes> format3;
SinglePosFormat2_4<MediumTypes> format4;
#endif
} u;
public:
@@ -49,6 +53,13 @@ struct SinglePos
if (glyph_val_iter_pairs)
format = get_format (glyph_val_iter_pairs);
#ifndef HB_NO_BEYOND_64K
if (+ glyph_val_iter_pairs
| hb_map_retains_sorting (hb_first)
| hb_filter ([] (hb_codepoint_t gid) { return gid > 0xFFFFu; }))
format += 2;
#endif
u.format.v = format;
switch (u.format.v) {
case 1: u.format1.serialize (c,
@@ -63,6 +74,20 @@ struct SinglePos
new_format,
layout_variation_idx_delta_map);
return;
#ifndef HB_NO_BEYOND_64K
case 3: u.format3.serialize (c,
src,
glyph_val_iter_pairs,
new_format,
layout_variation_idx_delta_map);
return;
case 4: u.format4.serialize (c,
src,
glyph_val_iter_pairs,
new_format,
layout_variation_idx_delta_map);
return;
#endif
default:return;
}
}
@@ -75,6 +100,10 @@ struct SinglePos
switch (u.format.v) {
case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...));
case 2: return_trace (c->dispatch (u.format2, std::forward<Ts> (ds)...));
#ifndef HB_NO_BEYOND_64K
case 3: return_trace (c->dispatch (u.format3, std::forward<Ts> (ds)...));
case 4: return_trace (c->dispatch (u.format4, std::forward<Ts> (ds)...));
#endif
default:return_trace (c->default_return_value ());
}
}
+4 -3
View File
@@ -8,11 +8,12 @@ namespace OT {
namespace Layout {
namespace GPOS_impl {
struct SinglePosFormat1 : ValueBase
template <typename Types>
struct SinglePosFormat1_3 : ValueBase
{
protected:
HBUINT16 format; /* Format identifier--format = 1 */
Offset16To<Coverage>
typename Types::template OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of subtable */
ValueFormat valueFormat; /* Defines the types of data in the
@@ -21,7 +22,7 @@ struct SinglePosFormat1 : ValueBase
* value(s)--applied to all glyphs in
* the Coverage table */
public:
DEFINE_SIZE_ARRAY (6, values);
DEFINE_SIZE_ARRAY (4 + Types::size, values);
bool sanitize (hb_sanitize_context_t *c) const
{
+7 -5
View File
@@ -7,20 +7,22 @@ namespace OT {
namespace Layout {
namespace GPOS_impl {
struct SinglePosFormat2 : ValueBase
template <typename Types>
struct SinglePosFormat2_4 : ValueBase
{
protected:
HBUINT16 format; /* Format identifier--format = 2 */
Offset16To<Coverage>
typename Types::template OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of subtable */
ValueFormat valueFormat; /* Defines the types of data in the
* ValueRecord */
HBUINT16 valueCount; /* Number of ValueRecords */
typename Types::HBUINT
valueCount; /* Number of ValueRecords */
ValueRecord values; /* Array of ValueRecords--positioning
* values applied to glyphs */
public:
DEFINE_SIZE_ARRAY (8, values);
DEFINE_SIZE_ARRAY (4 + 2 * Types::size, values);
bool sanitize (hb_sanitize_context_t *c) const
{
@@ -181,7 +183,7 @@ struct SinglePosFormat2 : ValueBase
const hb_map_t &glyph_map = *c->plan->glyph_map;
unsigned sub_length = valueFormat.get_len ();
auto values_array = values.as_array (valueCount * sub_length);
auto values_array = values.as_array ((unsigned) valueCount * sub_length);
auto it =
+ hb_zip (this+coverage, hb_range ((unsigned) valueCount))