1 // Copyright (c) 2011-2017 The OTS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef OTS_METRICS_H_ 6 #define OTS_METRICS_H_ 7 8 #include <new> 9 #include <utility> 10 #include <vector> 11 12 #include "ots.h" 13 14 namespace ots { 15 16 class OpenTypeMetricsHeader : public Table { 17 public: OpenTypeMetricsHeader(Font * font,uint32_t tag,uint32_t type)18 explicit OpenTypeMetricsHeader(Font *font, uint32_t tag, uint32_t type) 19 : Table(font, tag, type) { } 20 21 bool Parse(const uint8_t *data, size_t length); 22 bool Serialize(OTSStream *out); 23 24 uint32_t version; 25 int16_t ascent; 26 int16_t descent; 27 int16_t linegap; 28 uint16_t adv_width_max; 29 int16_t min_sb1; 30 int16_t min_sb2; 31 int16_t max_extent; 32 int16_t caret_slope_rise; 33 int16_t caret_slope_run; 34 int16_t caret_offset; 35 uint16_t num_metrics; 36 }; 37 38 struct OpenTypeMetricsTable : public Table { 39 public: OpenTypeMetricsTableOpenTypeMetricsTable40 explicit OpenTypeMetricsTable(Font *font, uint32_t tag, uint32_t type, 41 uint32_t header_tag) 42 : Table(font, tag, type), m_header_tag(header_tag) { } 43 44 bool Parse(const uint8_t *data, size_t length); 45 bool Serialize(OTSStream *out); 46 47 private: 48 uint32_t m_header_tag; 49 50 std::vector<std::pair<uint16_t, int16_t> > entries; 51 std::vector<int16_t> sbs; 52 }; 53 54 } // namespace ots 55 56 #endif // OTS_METRICS_H_ 57