diff --git a/src/hb-aat-var-hvgl-table.hh b/src/hb-aat-var-hvgl-table.hh new file mode 100644 index 000000000..c71f704f5 --- /dev/null +++ b/src/hb-aat-var-hvgl-table.hh @@ -0,0 +1,74 @@ +#ifndef HB_AAT_VAR_HVGL_TABLE_HH +#define HB_AAT_VAR_HVGL_TABLE_HH + +#include "hb-ot-var-common.hh" + +/* + * `hvgl` table + */ +#define HB_AAT_TAG_hvgl HB_TAG('h','v','g','l') + + +namespace AAT { + +using namespace OT; + +namespace hvgl { + +struct coordinates_t +{ + public: + + unsigned get_size (unsigned axis_count, unsigned segment_count) const + { return (coords[0].static_size * 4) * segment_count; } + + hb_array_t + get_coords(unsigned segment_count) const + { return hb_array (coords, segment_count * 4); } + + bool sanitize (hb_sanitize_context_t *c, + unsigned segment_count) const + { + TRACE_SANITIZE (this); + return_trace (c->check_range (coords, coords[0].static_size * 4, segment_count)); + } + + protected: + HBFLOAT64LE coords[HB_VAR_ARRAY]; // length: SegmentCount * 4 +}; + +struct deltas_t +{ + public: + + unsigned get_size (unsigned axis_count, unsigned segment_count) const + { return (matrix[0].static_size * 2 * 4) * axis_count * segment_count; } + + hb_array_t + get_column(unsigned column_index, unsigned axis_count, unsigned segment_count) const + { + const unsigned rows = 4 * segment_count; + const unsigned start = column_index * rows; + return hb_array (matrix + start, rows); + } + + hb_array_t + get_matrix(unsigned axis_count, unsigned segment_count) const + { return hb_array (matrix, (2 * 4) * axis_count * segment_count); } + + bool sanitize (hb_sanitize_context_t *c, + unsigned axis_count, + unsigned segment_count) const + { + TRACE_SANITIZE (this); + return_trace (c->check_range (matrix, matrix[0].static_size * 2 * 4, axis_count, segment_count)); + } + + protected: + HBFLOAT64LE matrix[HB_VAR_ARRAY]; // column-major: AxisCount * 2 columns, DeltaSegmentCount * 4 rows +}; + +} // namespace hvgl +} // namespace AAT + +#endif /* HB_AAT_VAR_HVGL_TABLE_HH */ diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 005248741..85900bd90 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -39,6 +39,7 @@ #ifndef HB_NO_AAT #include "hb-aat-layout-trak-table.hh" #endif +#include "hb-aat-var-hvgl-table.hh" #include "hb-ot-cmap-table.hh" #include "hb-ot-glyf-table.hh" #include "hb-ot-cff2-table.hh" diff --git a/src/meson.build b/src/meson.build index 8e40e0498..3bea8b99f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -23,6 +23,7 @@ hb_base_sources = files( 'hb-aat-ltag-table.hh', 'hb-aat-map.cc', 'hb-aat-map.hh', + 'hb-aat-var-hvgl-table.hh', 'hb-algs.hh', 'hb-array.hh', 'hb-atomic.hh',