aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_tables.cpp
blob: 9ddf6c0db6144bc0e29ed3c39c2c2c11f9baa470 (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
50
51
52
53
54
55
56
/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkEndian.h"
#include "SkFontHost.h"
#include "SkFontStream.h"
#include "SkStream.h"

int SkFontHost::CountTables(SkFontID fontID) {
    SkStream* stream = SkFontHost::OpenStream(fontID);
    if (NULL == stream) {
        return 0;
    }

    SkAutoUnref au(stream);
    int ttcIndex = 0;
    return SkFontStream::GetTableTags(stream, ttcIndex, NULL);
}

int SkFontHost::GetTableTags(SkFontID fontID, SkFontTableTag tags[]) {
    SkStream* stream = SkFontHost::OpenStream(fontID);
    if (NULL == stream) {
        return 0;
    }

    SkAutoUnref au(stream);
    int ttcIndex = 0;
    return SkFontStream::GetTableTags(stream, ttcIndex, tags);
}

size_t SkFontHost::GetTableSize(SkFontID fontID, SkFontTableTag tag) {
    SkStream* stream = SkFontHost::OpenStream(fontID);
    if (NULL == stream) {
        return 0;
    }

    SkAutoUnref au(stream);
    int ttcIndex = 0;
    return SkFontStream::GetTableData(stream, ttcIndex, tag, 0, ~0U, NULL);
}

size_t SkFontHost::GetTableData(SkFontID fontID, SkFontTableTag tag,
                                size_t offset, size_t length, void* data) {
    SkStream* stream = SkFontHost::OpenStream(fontID);
    if (NULL == stream) {
        return 0;
    }

    SkAutoUnref au(stream);
    int ttcIndex = 0;
    return SkFontStream::GetTableData(stream, ttcIndex, tag, offset, length, data);
}