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_LAYOUT_H_ 6 #define OTS_LAYOUT_H_ 7 8 #include "ots.h" 9 10 // Utility functions for OpenType layout common table formats. 11 // http://www.microsoft.com/typography/otspec/chapter2.htm 12 13 namespace ots { 14 15 // The maximum number of class value. 16 const uint16_t kMaxClassDefValue = 0xFFFF; 17 18 struct LookupSubtableParser { 19 struct TypeParser { 20 uint16_t type; 21 bool (*parse)(const Font *font, const uint8_t *data, 22 const size_t length); 23 }; 24 size_t num_types; 25 uint16_t extension_type; 26 const TypeParser *parsers; 27 28 bool Parse(const Font *font, const uint8_t *data, 29 const size_t length, const uint16_t lookup_type) const; 30 }; 31 32 bool ParseScriptListTable(const ots::Font *font, 33 const uint8_t *data, const size_t length, 34 const uint16_t num_features); 35 36 bool ParseFeatureListTable(const ots::Font *font, 37 const uint8_t *data, const size_t length, 38 const uint16_t num_lookups, 39 uint16_t *num_features); 40 41 bool ParseLookupListTable(Font *font, const uint8_t *data, 42 const size_t length, 43 const LookupSubtableParser* parser, 44 uint16_t* num_lookups); 45 46 bool ParseClassDefTable(const ots::Font *font, 47 const uint8_t *data, size_t length, 48 const uint16_t num_glyphs, 49 const uint16_t num_classes); 50 51 bool ParseCoverageTable(const ots::Font *font, 52 const uint8_t *data, size_t length, 53 const uint16_t num_glyphs, 54 const uint16_t expected_num_glyphs = 0); 55 56 bool ParseDeviceTable(const ots::Font *font, 57 const uint8_t *data, size_t length); 58 59 // Parser for 'Contextual' subtable shared by GSUB/GPOS tables. 60 bool ParseContextSubtable(const ots::Font *font, 61 const uint8_t *data, const size_t length, 62 const uint16_t num_glyphs, 63 const uint16_t num_lookups); 64 65 // Parser for 'Chaining Contextual' subtable shared by GSUB/GPOS tables. 66 bool ParseChainingContextSubtable(const ots::Font *font, 67 const uint8_t *data, const size_t length, 68 const uint16_t num_glyphs, 69 const uint16_t num_lookups); 70 71 bool ParseExtensionSubtable(const Font *font, 72 const uint8_t *data, const size_t length, 73 const LookupSubtableParser* parser); 74 75 // For feature variations table (in GSUB/GPOS v1.1) 76 bool ParseConditionTable(const Font *font, 77 const uint8_t *data, const size_t length, 78 const uint16_t axis_count); 79 80 bool ParseConditionSetTable(const Font *font, 81 const uint8_t *data, const size_t length, 82 const uint16_t axis_count); 83 84 bool ParseFeatureTableSubstitutionTable(const Font *font, 85 const uint8_t *data, const size_t length, 86 const uint16_t num_lookups); 87 88 bool ParseFeatureVariationsTable(const Font *font, 89 const uint8_t *data, const size_t length, 90 const uint16_t num_lookups); 91 92 } // namespace ots 93 94 #endif // OTS_LAYOUT_H_ 95 96