aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkFontStream.h
blob: 0f7a052e6a48bc8bd5e4d040a5eeaf9f6c35288c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkFontStream_DEFINED
#define SkFontStream_DEFINED

class SkStream;

#include "SkTypeface.h"

class SkFontStream {
public:
    /**
     *  Return the number of shared directories inside a TTC sfnt, or return 1
     *  if the stream is a normal sfnt (ttf). If there is an error or
     *  no directory is found, return 0.
     *
     *  Note: the stream is rewound initially, but is returned at an arbitrary
     *  read offset.
     */
    static int CountTTCEntries(SkStream*);

    /**
     *  @param ttcIndex 0 for normal sfnts, or the index within a TTC sfnt.
     *
     *  Note: the stream is rewound initially, but is returned at an arbitrary
     *  read offset.
     */
    static int GetTableTags(SkStream*, int ttcIndex, SkFontTableTag tags[]);

    /**
     *  @param ttcIndex 0 for normal sfnts, or the index within a TTC sfnt.
     *
     *  Note: the stream is rewound initially, but is returned at an arbitrary
     *  read offset.
     */
    static size_t GetTableData(SkStream*, int ttcIndex, SkFontTableTag tag,
                               size_t offset, size_t length, void* data);

    static size_t GetTableSize(SkStream* stream, int ttcIndex, SkFontTableTag tag) {
        return GetTableData(stream, ttcIndex, tag, 0, ~0U, NULL);
    }
};

#endif