bashi@google.com | 00b790a | 2011-01-27 06:35:42 +0000 | [diff] [blame] | 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_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 | |
bashi@chromium.org | ced7112 | 2011-02-17 10:23:47 +0000 | [diff] [blame] | 15 | |
| 16 | struct LookupSubtableParser { |
| 17 | struct TypeParser { |
| 18 | uint16_t type; |
| 19 | bool (*parse)(const OpenTypeFile *file, const uint8_t *data, |
| 20 | const size_t length); |
| 21 | }; |
| 22 | size_t num_types; |
| 23 | uint16_t extension_type; |
| 24 | const TypeParser *parsers; |
| 25 | |
| 26 | bool Parse(const OpenTypeFile *file, const uint8_t *data, |
| 27 | const size_t length, const uint16_t lookup_type) const; |
bashi@google.com | 78a8baa | 2011-02-07 06:21:25 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | bool ParseScriptListTable(const uint8_t *data, const size_t length, |
| 31 | const uint16_t num_features); |
| 32 | |
| 33 | bool ParseFeatureListTable(const uint8_t *data, const size_t length, |
| 34 | const uint16_t num_lookups, |
bashi@chromium.org | a574866 | 2011-03-18 17:48:29 +0000 | [diff] [blame] | 35 | uint16_t *num_features); |
bashi@google.com | 78a8baa | 2011-02-07 06:21:25 +0000 | [diff] [blame] | 36 | |
| 37 | bool ParseLookupListTable(OpenTypeFile *file, const uint8_t *data, |
bashi@chromium.org | ced7112 | 2011-02-17 10:23:47 +0000 | [diff] [blame] | 38 | const size_t length, |
| 39 | const LookupSubtableParser* parser, |
| 40 | uint16_t* num_lookups); |
bashi@google.com | 78a8baa | 2011-02-07 06:21:25 +0000 | [diff] [blame] | 41 | |
bashi@google.com | 00b790a | 2011-01-27 06:35:42 +0000 | [diff] [blame] | 42 | bool ParseClassDefTable(const uint8_t *data, size_t length, |
| 43 | const uint16_t num_glyphs, |
| 44 | const uint16_t num_classes); |
| 45 | |
| 46 | bool ParseCoverageTable(const uint8_t *data, size_t length, |
ksakamoto@chromium.org | eea4836 | 2014-01-20 02:15:37 +0000 | [diff] [blame] | 47 | const uint16_t num_glyphs, |
| 48 | const uint16_t expected_num_glyphs = 0); |
bashi@google.com | 00b790a | 2011-01-27 06:35:42 +0000 | [diff] [blame] | 49 | |
bashi@google.com | 78a8baa | 2011-02-07 06:21:25 +0000 | [diff] [blame] | 50 | bool ParseDeviceTable(const uint8_t *data, size_t length); |
| 51 | |
bashi@chromium.org | ced7112 | 2011-02-17 10:23:47 +0000 | [diff] [blame] | 52 | // Parser for 'Contextual' subtable shared by GSUB/GPOS tables. |
| 53 | bool ParseContextSubtable(const uint8_t *data, const size_t length, |
| 54 | const uint16_t num_glyphs, |
| 55 | const uint16_t num_lookups); |
| 56 | |
| 57 | // Parser for 'Chaining Contextual' subtable shared by GSUB/GPOS tables. |
| 58 | bool ParseChainingContextSubtable(const uint8_t *data, const size_t length, |
| 59 | const uint16_t num_glyphs, |
| 60 | const uint16_t num_lookups); |
| 61 | |
| 62 | bool ParseExtensionSubtable(const OpenTypeFile *file, |
| 63 | const uint8_t *data, const size_t length, |
| 64 | const LookupSubtableParser* parser); |
| 65 | |
bashi@google.com | 00b790a | 2011-01-27 06:35:42 +0000 | [diff] [blame] | 66 | } // namespace ots |
| 67 | |
| 68 | #endif // OTS_LAYOUT_H_ |
| 69 | |