layout.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef OTS_LAYOUT_H_
  5. #define OTS_LAYOUT_H_
  6. #include "ots.h"
  7. // Utility functions for OpenType layout common table formats.
  8. // http://www.microsoft.com/typography/otspec/chapter2.htm
  9. namespace ots {
  10. struct LookupSubtableParser {
  11. struct TypeParser {
  12. uint16_t type;
  13. bool (*parse)(const Font *font, const uint8_t *data,
  14. const size_t length);
  15. };
  16. size_t num_types;
  17. uint16_t extension_type;
  18. const TypeParser *parsers;
  19. bool Parse(const Font *font, const uint8_t *data,
  20. const size_t length, const uint16_t lookup_type) const;
  21. };
  22. bool ParseScriptListTable(const ots::Font *font,
  23. const uint8_t *data, const size_t length,
  24. const uint16_t num_features);
  25. bool ParseFeatureListTable(const ots::Font *font,
  26. const uint8_t *data, const size_t length,
  27. const uint16_t num_lookups,
  28. uint16_t *num_features);
  29. bool ParseLookupListTable(Font *font, const uint8_t *data,
  30. const size_t length,
  31. const LookupSubtableParser* parser,
  32. uint16_t* num_lookups);
  33. bool ParseClassDefTable(const ots::Font *font,
  34. const uint8_t *data, size_t length,
  35. const uint16_t num_glyphs,
  36. const uint16_t num_classes);
  37. bool ParseCoverageTable(const ots::Font *font,
  38. const uint8_t *data, size_t length,
  39. const uint16_t num_glyphs,
  40. const uint16_t expected_num_glyphs = 0);
  41. bool ParseDeviceTable(const ots::Font *font,
  42. const uint8_t *data, size_t length);
  43. // Parser for 'Contextual' subtable shared by GSUB/GPOS tables.
  44. bool ParseContextSubtable(const ots::Font *font,
  45. const uint8_t *data, const size_t length,
  46. const uint16_t num_glyphs,
  47. const uint16_t num_lookups);
  48. // Parser for 'Chaining Contextual' subtable shared by GSUB/GPOS tables.
  49. bool ParseChainingContextSubtable(const ots::Font *font,
  50. const uint8_t *data, const size_t length,
  51. const uint16_t num_glyphs,
  52. const uint16_t num_lookups);
  53. bool ParseExtensionSubtable(const Font *font,
  54. const uint8_t *data, const size_t length,
  55. const LookupSubtableParser* parser);
  56. } // namespace ots
  57. #endif // OTS_LAYOUT_H_