blob: 0a2322fc06d6a64d4c10eccc1083386189f9af12 [file] [log] [blame]
reed@google.com6ec97b62013-03-04 15:16:06 +00001/*
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
8#ifndef SkFontStream_DEFINED
9#define SkFontStream_DEFINED
10
11class SkStream;
12
13#include "SkTypeface.h"
14
15class SkFontStream {
16public:
reed@google.com90ee4482013-03-05 20:50:47 +000017 /**
reed@google.comed268bf2013-03-11 20:13:36 +000018 * Return the number of shared directories inside a TTC sfnt, or return 1
19 * if the stream is a normal sfnt (ttf). If there is an error or
20 * no directory is found, return 0.
reed@google.com5bfc8392013-03-05 22:12:11 +000021 *
reed@google.com90ee4482013-03-05 20:50:47 +000022 * Note: the stream is rewound initially, but is returned at an arbitrary
23 * read offset.
24 */
reed@google.com5bfc8392013-03-05 22:12:11 +000025 static int CountTTCEntries(SkStream*);
reed@google.com90ee4482013-03-05 20:50:47 +000026
27 /**
reed@google.com5bfc8392013-03-05 22:12:11 +000028 * @param ttcIndex 0 for normal sfnts, or the index within a TTC sfnt.
29 *
reed@google.com90ee4482013-03-05 20:50:47 +000030 * Note: the stream is rewound initially, but is returned at an arbitrary
31 * read offset.
32 */
reed@google.com5bfc8392013-03-05 22:12:11 +000033 static int GetTableTags(SkStream*, int ttcIndex, SkFontTableTag tags[]);
34
35 /**
36 * @param ttcIndex 0 for normal sfnts, or the index within a TTC sfnt.
37 *
38 * Note: the stream is rewound initially, but is returned at an arbitrary
39 * read offset.
40 */
41 static size_t GetTableData(SkStream*, int ttcIndex, SkFontTableTag tag,
reed@google.com6ec97b62013-03-04 15:16:06 +000042 size_t offset, size_t length, void* data);
reed@google.comed268bf2013-03-11 20:13:36 +000043
44 static size_t GetTableSize(SkStream* stream, int ttcIndex, SkFontTableTag tag) {
halcanary96fcdcc2015-08-27 07:41:13 -070045 return GetTableData(stream, ttcIndex, tag, 0, ~0U, nullptr);
reed@google.comed268bf2013-03-11 20:13:36 +000046 }
reed@google.com6ec97b62013-03-04 15:16:06 +000047};
48
49#endif