1 // Copyright (c) 2011 The Chromium 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 <utility> // std::pair 9 #include <vector> 10 11 #include "ots.h" 12 13 namespace ots { 14 15 struct OpenTypeMetricsHeader { 16 uint32_t version; 17 int16_t ascent; 18 int16_t descent; 19 int16_t linegap; 20 uint16_t adv_width_max; 21 int16_t min_sb1; 22 int16_t min_sb2; 23 int16_t max_extent; 24 int16_t caret_slope_rise; 25 int16_t caret_slope_run; 26 int16_t caret_offset; 27 uint16_t num_metrics; 28 }; 29 30 struct OpenTypeMetricsTable { 31 std::vector<std::pair<uint16_t, int16_t> > entries; 32 std::vector<int16_t> sbs; 33 }; 34 35 bool ParseMetricsHeader(OpenTypeFile *file, Buffer *table, 36 OpenTypeMetricsHeader *header); 37 bool SerialiseMetricsHeader(OTSStream *out, 38 const OpenTypeMetricsHeader *header); 39 40 bool ParseMetricsTable(Buffer *table, 41 const uint16_t num_glyphs, 42 const OpenTypeMetricsHeader *header, 43 OpenTypeMetricsTable *metrics); 44 bool SerialiseMetricsTable(OTSStream *out, 45 const OpenTypeMetricsTable *metrics); 46 47 } // namespace ots 48 49 #endif // OTS_METRICS_H_ 50 51