kern.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2009-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_KERN_H_
  5. #define OTS_KERN_H_
  6. #include <vector>
  7. #include "ots.h"
  8. namespace ots {
  9. struct OpenTypeKERNFormat0Pair {
  10. uint16_t left;
  11. uint16_t right;
  12. int16_t value;
  13. };
  14. struct OpenTypeKERNFormat0 {
  15. uint16_t version;
  16. uint16_t coverage;
  17. uint16_t search_range;
  18. uint16_t entry_selector;
  19. uint16_t range_shift;
  20. std::vector<OpenTypeKERNFormat0Pair> pairs;
  21. };
  22. // Format 2 is not supported. Since the format is not supported by Windows,
  23. // WebFonts unlikely use it. I've checked thousands of proprietary fonts and
  24. // free fonts, and found no font uses the format.
  25. class OpenTypeKERN : public Table {
  26. public:
  27. explicit OpenTypeKERN(Font *font, uint32_t tag)
  28. : Table(font, tag, tag) { }
  29. bool Parse(const uint8_t *data, size_t length);
  30. bool Serialize(OTSStream *out);
  31. bool ShouldSerialize();
  32. private:
  33. uint16_t version;
  34. std::vector<OpenTypeKERNFormat0> subtables;
  35. };
  36. } // namespace ots
  37. #endif // OTS_KERN_H_