From 2a4d7a193ef7001afe536d56317dab0cf2ff718e Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 2 Nov 2023 11:36:51 +0000 Subject: [PATCH] LibGfx: Define and use OpenType data types for struct definitions A few closely-related changes: - Move our definitions of the OpenType spec's "data types" into their own header file. - Add definitions for the integer types there too, for completeness. (Plus Uint16 matches the spec term, and is less verbose than BigEndian.) - Include Traits for the non-BigEndian types so that we can read them from Streams. (BigEndian already has this.) - Use the integer types in our struct definitions. As a bonus, this fixes a bug in Hmtx, which read the left-side bearings as i16 instead of BigEndian. --- .../LibGfx/Font/OpenType/DataTypes.h | 73 ++++ .../Libraries/LibGfx/Font/OpenType/Tables.cpp | 8 +- .../Libraries/LibGfx/Font/OpenType/Tables.h | 376 +++++++++--------- 3 files changed, 254 insertions(+), 203 deletions(-) create mode 100644 Userland/Libraries/LibGfx/Font/OpenType/DataTypes.h diff --git a/Userland/Libraries/LibGfx/Font/OpenType/DataTypes.h b/Userland/Libraries/LibGfx/Font/OpenType/DataTypes.h new file mode 100644 index 0000000000..d3c687bb31 --- /dev/null +++ b/Userland/Libraries/LibGfx/Font/OpenType/DataTypes.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2020, Srimanta Barua + * Copyright (c) 2022, Jelle Raaijmakers + * Copyright (c) 2023, Lukas Affolter + * Copyright (c) 2023, Sam Atkins + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +// https://learn.microsoft.com/en-us/typography/opentype/spec/otff#data-types +namespace OpenType { + +using Uint8 = u8; +using Int8 = i8; +using Uint16 = BigEndian; +using Int16 = BigEndian; +// FIXME: Uint24 +using Uint32 = BigEndian; +using Int32 = BigEndian; + +struct [[gnu::packed]] Fixed { + BigEndian integer; + BigEndian fraction; +}; +static_assert(AssertSize()); + +using FWord = BigEndian; +using UFWord = BigEndian; + +// FIXME: F2Dot14 + +struct [[gnu::packed]] LongDateTime { + BigEndian value; +}; +static_assert(AssertSize()); + +using Tag = BigEndian; + +using Offset16 = BigEndian; +// FIXME: Offset24 +using Offset32 = BigEndian; + +struct [[gnu::packed]] Version16Dot16 { + BigEndian major; + BigEndian minor; +}; +static_assert(AssertSize()); + +} + +namespace AK { +template<> +struct Traits : public GenericTraits { + static constexpr bool is_trivially_serializable() { return true; } +}; +template<> +struct Traits : public GenericTraits { + static constexpr bool is_trivially_serializable() { return true; } +}; +template<> +struct Traits : public GenericTraits { + static constexpr bool is_trivially_serializable() { return true; } +}; +template<> +struct Traits : public GenericTraits { + static constexpr bool is_trivially_serializable() { return true; } +}; +} diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp b/Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp index 1d1a347e9d..b5273d8b32 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp +++ b/Userland/Libraries/LibGfx/Font/OpenType/Tables.cpp @@ -145,16 +145,16 @@ u16 Maxp::num_glyphs() const ErrorOr Hmtx::from_slice(ReadonlyBytes slice, u32 num_glyphs, u32 number_of_h_metrics) { - if (slice.size() < number_of_h_metrics * sizeof(LongHorMetric) + (num_glyphs - number_of_h_metrics) * sizeof(i16)) + if (slice.size() < number_of_h_metrics * sizeof(LongHorMetric) + (num_glyphs - number_of_h_metrics) * sizeof(Int16)) return Error::from_string_literal("Could not load Hmtx: Not enough data"); - // The Horizontal Metrics table is LongHorMetric[number_of_h_metrics] followed by i16[num_glyphs - number_of_h_metrics]; + // The Horizontal Metrics table is LongHorMetric[number_of_h_metrics] followed by Int16[num_glyphs - number_of_h_metrics]; ReadonlySpan long_hor_metrics { bit_cast(slice.data()), number_of_h_metrics }; - ReadonlySpan left_side_bearings {}; + ReadonlySpan left_side_bearings {}; auto number_of_left_side_bearings = num_glyphs - number_of_h_metrics; if (number_of_left_side_bearings > 0) { left_side_bearings = { - bit_cast(slice.offset(number_of_h_metrics * sizeof(LongHorMetric))), + bit_cast(slice.offset(number_of_h_metrics * sizeof(LongHorMetric))), number_of_left_side_bearings }; } diff --git a/Userland/Libraries/LibGfx/Font/OpenType/Tables.h b/Userland/Libraries/LibGfx/Font/OpenType/Tables.h index 80520a67d0..db2ae9e016 100644 --- a/Userland/Libraries/LibGfx/Font/OpenType/Tables.h +++ b/Userland/Libraries/LibGfx/Font/OpenType/Tables.h @@ -16,6 +16,7 @@ #include #include #include +#include namespace OpenType { @@ -24,46 +25,23 @@ enum class IndexToLocFormat { Offset32, }; -struct [[gnu::packed]] Fixed { - BigEndian integer; - BigEndian fraction; -}; -static_assert(AssertSize()); - -struct [[gnu::packed]] LongDateTime { - BigEndian value; -}; -static_assert(AssertSize()); - -struct [[gnu::packed]] Version16Dot16 { - BigEndian major; - BigEndian minor; -}; -static_assert(AssertSize()); - -using FWord = BigEndian; -using UFWord = BigEndian; -using Tag = BigEndian; -using Offset16 = BigEndian; -using Offset32 = BigEndian; - // https://learn.microsoft.com/en-us/typography/opentype/spec/otff#table-directory // Table Directory (known as the Offset Table in ISO-IEC 14496-22:2019) struct [[gnu::packed]] TableDirectory { - BigEndian sfnt_version; - BigEndian num_tables; // Number of tables. - BigEndian search_range; // (Maximum power of 2 <= numTables) x 16. - BigEndian entry_selector; // Log2(maximum power of 2 <= numTables). - BigEndian range_shift; // NumTables x 16 - searchRange. + Uint32 sfnt_version; + Uint16 num_tables; // Number of tables. + Uint16 search_range; // (Maximum power of 2 <= numTables) x 16. + Uint16 entry_selector; // Log2(maximum power of 2 <= numTables). + Uint16 range_shift; // NumTables x 16 - searchRange. }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/otff#table-directory struct [[gnu::packed]] TableRecord { - Tag table_tag; // Table identifier. - BigEndian checksum; // CheckSum for this table. - Offset32 offset; // Offset from beginning of TrueType font file. - BigEndian length; // Length of this table. + Tag table_tag; // Table identifier. + Uint32 checksum; // CheckSum for this table. + Offset32 offset; // Offset from beginning of TrueType font file. + Uint32 length; // Length of this table. }; static_assert(AssertSize()); @@ -99,24 +77,24 @@ public: private: struct [[gnu::packed]] FontHeaderTable { - BigEndian major_version; - BigEndian minor_version; + Uint16 major_version; + Uint16 minor_version; Fixed font_revision; - BigEndian checksum_adjustment; - BigEndian magic_number; - BigEndian flags; - BigEndian units_per_em; + Uint32 checksum_adjustment; + Uint32 magic_number; + Uint16 flags; + Uint16 units_per_em; LongDateTime created; LongDateTime modified; - BigEndian x_min; - BigEndian y_min; - BigEndian x_max; - BigEndian y_max; - BigEndian mac_style; - BigEndian lowest_rec_ppem; - BigEndian font_direction_hint; - BigEndian index_to_loc_format; - BigEndian glyph_data_format; + Int16 x_min; + Int16 y_min; + Int16 x_max; + Int16 y_max; + Uint16 mac_style; + Uint16 lowest_rec_ppem; + Int16 font_direction_hint; + Int16 index_to_loc_format; + Int16 glyph_data_format; }; static_assert(AssertSize()); @@ -141,8 +119,8 @@ public: private: struct [[gnu::packed]] HorizontalHeaderTable { - BigEndian major_version; - BigEndian minor_version; + Uint16 major_version; + Uint16 minor_version; FWord ascender; FWord descender; FWord line_gap; @@ -150,12 +128,12 @@ private: FWord min_left_side_bearing; FWord min_right_side_bearing; FWord x_max_extent; - BigEndian caret_slope_rise; - BigEndian caret_slope_run; - BigEndian caret_offset; - BigEndian reserved[4]; - BigEndian metric_data_format; - BigEndian number_of_h_metrics; + Int16 caret_slope_rise; + Int16 caret_slope_run; + Int16 caret_offset; + Int16 reserved[4]; + Int16 metric_data_format; + Uint16 number_of_h_metrics; }; static_assert(AssertSize()); @@ -178,24 +156,24 @@ public: private: struct [[gnu::packed]] Version0_5 { Version16Dot16 version; - BigEndian num_glyphs; + Uint16 num_glyphs; }; static_assert(AssertSize()); struct [[gnu::packed]] Version1_0 : Version0_5 { - BigEndian max_points; - BigEndian max_contours; - BigEndian max_composite_points; - BigEndian max_composite_contours; - BigEndian max_zones; - BigEndian max_twilight_points; - BigEndian max_storage; - BigEndian max_function_defs; - BigEndian max_instruction_defs; - BigEndian max_stack_elements; - BigEndian max_size_of_instructions; - BigEndian max_component_elements; - BigEndian max_component_depths; + Uint16 max_points; + Uint16 max_contours; + Uint16 max_composite_points; + Uint16 max_composite_contours; + Uint16 max_zones; + Uint16 max_twilight_points; + Uint16 max_storage; + Uint16 max_function_defs; + Uint16 max_instruction_defs; + Uint16 max_stack_elements; + Uint16 max_size_of_instructions; + Uint16 max_component_elements; + Uint16 max_component_depths; }; static_assert(AssertSize()); @@ -253,19 +231,19 @@ public: private: struct [[gnu::packed]] LongHorMetric { - BigEndian advance_width; - BigEndian lsb; + Uint16 advance_width; + Int16 lsb; }; static_assert(AssertSize()); - Hmtx(ReadonlySpan long_hor_metrics, ReadonlySpan left_side_bearings) + Hmtx(ReadonlySpan long_hor_metrics, ReadonlySpan left_side_bearings) : m_long_hor_metrics(long_hor_metrics) , m_left_side_bearings(left_side_bearings) { } ReadonlySpan m_long_hor_metrics; - ReadonlySpan m_left_side_bearings; + ReadonlySpan m_left_side_bearings; }; // https://learn.microsoft.com/en-us/typography/opentype/spec/os2 @@ -287,51 +265,51 @@ public: private: struct [[gnu::packed]] Version0 { - BigEndian version; - BigEndian avg_char_width; - BigEndian us_weight_class; - BigEndian us_width_class; - BigEndian fs_type; - BigEndian y_subscript_x_size; - BigEndian y_subscript_y_size; - BigEndian y_subscript_x_offset; - BigEndian y_subscript_y_offset; - BigEndian y_superscript_x_size; - BigEndian y_superscript_y_size; - BigEndian y_superscript_x_offset; - BigEndian y_superscript_y_offset; - BigEndian y_strikeout_size; - BigEndian y_strikeout_position; - BigEndian s_family_class; - u8 panose[10]; - BigEndian ul_unicode_range1; - BigEndian ul_unicode_range2; - BigEndian ul_unicode_range3; - BigEndian ul_unicode_range4; + Uint16 version; + Int16 avg_char_width; + Uint16 us_weight_class; + Uint16 us_width_class; + Uint16 fs_type; + Int16 y_subscript_x_size; + Int16 y_subscript_y_size; + Int16 y_subscript_x_offset; + Int16 y_subscript_y_offset; + Int16 y_superscript_x_size; + Int16 y_superscript_y_size; + Int16 y_superscript_x_offset; + Int16 y_superscript_y_offset; + Int16 y_strikeout_size; + Int16 y_strikeout_position; + Int16 s_family_class; + Uint8 panose[10]; + Uint32 ul_unicode_range1; + Uint32 ul_unicode_range2; + Uint32 ul_unicode_range3; + Uint32 ul_unicode_range4; Tag ach_vend_id; - BigEndian fs_selection; - BigEndian fs_first_char_index; - BigEndian us_last_char_index; - BigEndian s_typo_ascender; - BigEndian s_typo_descender; - BigEndian s_typo_line_gap; - BigEndian us_win_ascent; - BigEndian us_win_descent; + Uint16 fs_selection; + Uint16 fs_first_char_index; + Uint16 us_last_char_index; + Int16 s_typo_ascender; + Int16 s_typo_descender; + Int16 s_typo_line_gap; + Uint16 us_win_ascent; + Uint16 us_win_descent; }; static_assert(AssertSize()); struct [[gnu::packed]] Version1 : Version0 { - BigEndian ul_code_page_range1; - BigEndian ul_code_page_range2; + Uint32 ul_code_page_range1; + Uint32 ul_code_page_range2; }; static_assert(AssertSize()); struct [[gnu::packed]] Version2 : Version1 { - BigEndian sx_height; - BigEndian s_cap_height; - BigEndian us_default_char; - BigEndian us_break_char; - BigEndian us_max_context; + Int16 sx_height; + Int16 s_cap_height; + Uint16 us_default_char; + Uint16 us_break_char; + Uint16 us_max_context; }; static_assert(AssertSize()); @@ -368,19 +346,19 @@ public: private: // https://learn.microsoft.com/en-us/typography/opentype/spec/name#name-records struct [[gnu::packed]] NameRecord { - BigEndian platform_id; - BigEndian encoding_id; - BigEndian language_id; - BigEndian name_id; - BigEndian length; + Uint16 platform_id; + Uint16 encoding_id; + Uint16 language_id; + Uint16 name_id; + Uint16 length; Offset16 string_offset; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/name#naming-table-version-0 struct [[gnu::packed]] NamingTableVersion0 { - BigEndian version; - BigEndian count; + Uint16 version; + Uint16 count; Offset16 storage_offset; // NameRecords are stored in a separate span. // NameRecord name_record[0]; @@ -425,30 +403,30 @@ public: i16 get_glyph_kerning(u16 left_glyph_id, u16 right_glyph_id) const; struct [[gnu::packed]] Header { - BigEndian version; - BigEndian n_tables; + Uint16 version; + Uint16 n_tables; }; static_assert(AssertSize()); struct [[gnu::packed]] SubtableHeader { - BigEndian version; - BigEndian length; - BigEndian coverage; + Uint16 version; + Uint16 length; + Uint16 coverage; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/kern#format-0 struct [[gnu::packed]] Format0 { - BigEndian n_pairs; - BigEndian search_range; - BigEndian entry_selector; - BigEndian range_shift; + Uint16 n_pairs; + Uint16 search_range; + Uint16 entry_selector; + Uint16 range_shift; }; static_assert(AssertSize()); struct [[gnu::packed]] Format0Pair { - BigEndian left; - BigEndian right; + Uint16 left; + Uint16 right; FWord value; }; static_assert(AssertSize()); @@ -483,33 +461,33 @@ class EBLC { public: // https://learn.microsoft.com/en-us/typography/opentype/spec/eblc#sbitlinemetrics-record struct [[gnu::packed]] SbitLineMetrics { - i8 ascender {}; - i8 descender {}; - u8 width_max {}; - i8 caret_slope_numerator {}; - i8 caret_slope_denominator {}; - i8 caret_offset {}; - i8 min_origin_sb {}; - i8 min_advance_sb {}; - i8 max_before_bl {}; - i8 min_after_bl {}; - i8 pad1 {}; - i8 pad2 {}; + Int8 ascender {}; + Int8 descender {}; + Uint8 width_max {}; + Int8 caret_slope_numerator {}; + Int8 caret_slope_denominator {}; + Int8 caret_offset {}; + Int8 min_origin_sb {}; + Int8 min_advance_sb {}; + Int8 max_before_bl {}; + Int8 min_after_bl {}; + Int8 pad1 {}; + Int8 pad2 {}; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/eblc#indexsubtablearray struct [[gnu::packed]] IndexSubTableArray { - BigEndian first_glyph_index; - BigEndian last_glyph_index; + Uint16 first_glyph_index; + Uint16 last_glyph_index; Offset32 additional_offset_to_index_subtable; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/eblc#indexsubheader struct [[gnu::packed]] IndexSubHeader { - BigEndian index_format; - BigEndian image_format; + Uint16 index_format; + Uint16 image_format; Offset32 image_data_offset; }; static_assert(AssertSize()); @@ -530,25 +508,25 @@ public: // https://learn.microsoft.com/en-us/typography/opentype/spec/cblc#bitmapsize-record struct [[gnu::packed]] BitmapSize { Offset32 index_subtable_array_offset; - BigEndian index_tables_size; - BigEndian number_of_index_subtables; - BigEndian color_ref; + Uint32 index_tables_size; + Uint32 number_of_index_subtables; + Uint32 color_ref; EBLC::SbitLineMetrics hori; EBLC::SbitLineMetrics vert; - BigEndian start_glyph_index; - BigEndian end_glyph_index; - u8 ppem_x {}; - u8 ppem_y {}; - u8 bit_depth {}; - i8 flags {}; + Uint16 start_glyph_index; + Uint16 end_glyph_index; + Uint8 ppem_x {}; + Uint8 ppem_y {}; + Uint8 bit_depth {}; + Int8 flags {}; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/cblc#cblcheader struct [[gnu::packed]] CblcHeader { - BigEndian major_version; - BigEndian minor_version; - BigEndian num_sizes; + Uint16 major_version; + Uint16 minor_version; + Uint32 num_sizes; // Stored in a separate span: // BitmapSize bitmap_sizes[]; }; @@ -577,11 +555,11 @@ class EBDT { public: // https://learn.microsoft.com/en-us/typography/opentype/spec/ebdt#smallglyphmetrics struct [[gnu::packed]] SmallGlyphMetrics { - u8 height {}; - u8 width {}; - i8 bearing_x {}; - i8 bearing_y {}; - u8 advance {}; + Uint8 height {}; + Uint8 width {}; + Int8 bearing_x {}; + Int8 bearing_y {}; + Uint8 advance {}; }; static_assert(AssertSize()); }; @@ -592,16 +570,16 @@ class CBDT { public: // https://learn.microsoft.com/en-us/typography/opentype/spec/cbdt#table-structure struct [[gnu::packed]] CbdtHeader { - BigEndian major_version; - BigEndian minor_version; + Uint16 major_version; + Uint16 minor_version; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/cbdt#format-17-small-metrics-png-image-data struct [[gnu::packed]] Format17 { EBDT::SmallGlyphMetrics glyph_metrics; - BigEndian data_len; - u8 data[]; + Uint32 data_len; + Uint8 data[]; }; static_assert(AssertSize()); @@ -628,7 +606,7 @@ static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#feature-list-table struct [[gnu::packed]] FeatureList { - BigEndian feature_count; + Uint16 feature_count; FeatureRecord feature_records[]; }; static_assert(AssertSize()); @@ -636,63 +614,63 @@ static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#feature-table struct [[gnu::packed]] Feature { Offset16 feature_params_offset; - BigEndian lookup_index_count; - BigEndian lookup_list_indices[]; + Uint16 lookup_index_count; + Uint16 lookup_list_indices[]; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#lookup-table struct [[gnu::packed]] Lookup { - BigEndian lookup_type; - BigEndian lookup_flag; - BigEndian subtable_count; + Uint16 lookup_type; + Uint16 lookup_flag; + Uint16 subtable_count; Offset16 subtable_offsets[]; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#lookup-list-table struct [[gnu::packed]] LookupList { - BigEndian lookup_count; + Uint16 lookup_count; Offset16 lookup_offsets[]; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#coverage-format-1 struct [[gnu::packed]] CoverageFormat1 { - BigEndian coverage_format; - BigEndian glyph_count; - BigEndian glyph_array[]; + Uint16 coverage_format; + Uint16 glyph_count; + Uint16 glyph_array[]; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#coverage-format-2 struct [[gnu::packed]] RangeRecord { - BigEndian start_glyph_id; - BigEndian end_glyph_id; - BigEndian start_coverage_index; + Uint16 start_glyph_id; + Uint16 end_glyph_id; + Uint16 start_coverage_index; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#coverage-format-2 struct [[gnu::packed]] CoverageFormat2 { - BigEndian coverage_format; - BigEndian range_count; + Uint16 coverage_format; + Uint16 range_count; RangeRecord range_records[]; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#class-definition-table-format-2 struct [[gnu::packed]] ClassRangeRecord { - BigEndian start_glyph_id; - BigEndian end_glyph_id; - BigEndian class_; + Uint16 start_glyph_id; + Uint16 end_glyph_id; + Uint16 class_; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#class-definition-table-format-2 struct [[gnu::packed]] ClassDefFormat2 { - BigEndian class_format; - BigEndian class_range_count; + Uint16 class_format; + Uint16 class_range_count; ClassRangeRecord class_range_records[]; }; static_assert(AssertSize()); @@ -702,8 +680,8 @@ class GPOS { public: // https://learn.microsoft.com/en-us/typography/opentype/spec/gpos#gpos-header struct [[gnu::packed]] Version1_0 { - BigEndian major_version; - BigEndian minor_version; + Uint16 major_version; + Uint16 minor_version; Offset16 script_list_offset; Offset16 feature_list_offset; Offset16 lookup_list_offset; @@ -712,21 +690,21 @@ public: // https://learn.microsoft.com/en-us/typography/opentype/spec/gpos#pair-adjustment-positioning-format-1-adjustments-for-glyph-pairs struct [[gnu::packed]] PairPosFormat1 { - BigEndian pos_format; + Uint16 pos_format; Offset16 coverage_offset; - BigEndian value_format1; - BigEndian value_format2; - BigEndian pair_set_count; + Uint16 value_format1; + Uint16 value_format2; + Uint16 pair_set_count; Offset16 pair_set_offsets[]; }; static_assert(AssertSize()); // https://learn.microsoft.com/en-us/typography/opentype/spec/gpos#value-record struct [[gnu::packed]] ValueRecord { - BigEndian x_placement; - BigEndian y_placement; - BigEndian x_advance; - BigEndian y_advance; + Int16 x_placement; + Int16 y_placement; + Int16 x_advance; + Int16 y_advance; Offset16 x_placement_device_offset; Offset16 y_placement_device_offset; Offset16 x_advance_device_offset; @@ -736,14 +714,14 @@ public: // https://learn.microsoft.com/en-us/typography/opentype/spec/gpos#pair-adjustment-positioning-format-2-class-pair-adjustment struct [[gnu::packed]] PairPosFormat2 { - BigEndian pos_format; + Uint16 pos_format; Offset16 coverage_offset; - BigEndian value_format1; - BigEndian value_format2; + Uint16 value_format1; + Uint16 value_format2; Offset16 class_def1_offset; Offset16 class_def2_offset; - BigEndian class1_count; - BigEndian class2_count; + Uint16 class1_count; + Uint16 class2_count; }; static_assert(AssertSize());