SkFontStream.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2013 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef SkFontStream_DEFINED
  8. #define SkFontStream_DEFINED
  9. class SkStream;
  10. #include "include/core/SkTypeface.h"
  11. class SkFontStream {
  12. public:
  13. /**
  14. * Return the number of shared directories inside a TTC sfnt, or return 1
  15. * if the stream is a normal sfnt (ttf). If there is an error or
  16. * no directory is found, return 0.
  17. *
  18. * Note: the stream is rewound initially, but is returned at an arbitrary
  19. * read offset.
  20. */
  21. static int CountTTCEntries(SkStream*);
  22. /**
  23. * @param ttcIndex 0 for normal sfnts, or the index within a TTC sfnt.
  24. *
  25. * Note: the stream is rewound initially, but is returned at an arbitrary
  26. * read offset.
  27. */
  28. static int GetTableTags(SkStream*, int ttcIndex, SkFontTableTag tags[]);
  29. /**
  30. * @param ttcIndex 0 for normal sfnts, or the index within a TTC sfnt.
  31. *
  32. * Note: the stream is rewound initially, but is returned at an arbitrary
  33. * read offset.
  34. */
  35. static size_t GetTableData(SkStream*, int ttcIndex, SkFontTableTag tag,
  36. size_t offset, size_t length, void* data);
  37. static size_t GetTableSize(SkStream* stream, int ttcIndex, SkFontTableTag tag) {
  38. return GetTableData(stream, ttcIndex, tag, 0, ~0U, nullptr);
  39. }
  40. };
  41. #endif