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 8 #ifndef SkFontStream_DEFINED 9 #define SkFontStream_DEFINED 10 11 #include "include/core/SkTypeface.h" 12 13 #include <cstddef> 14 15 class SkStream; 16 17 class SkFontStream { 18 public: 19 /** 20 * Return the number of shared directories inside a TTC sfnt, or return 1 21 * if the stream is a normal sfnt (ttf). If there is an error or 22 * no directory is found, return 0. 23 * 24 * Note: the stream is rewound initially, but is returned at an arbitrary 25 * read offset. 26 */ 27 static int CountTTCEntries(SkStream*); 28 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 int GetTableTags(SkStream*, int ttcIndex, SkFontTableTag tags[]); 36 37 /** 38 * @param ttcIndex 0 for normal sfnts, or the index within a TTC sfnt. 39 * 40 * Note: the stream is rewound initially, but is returned at an arbitrary 41 * read offset. 42 */ 43 static size_t GetTableData(SkStream*, int ttcIndex, SkFontTableTag tag, 44 size_t offset, size_t length, void* data); 45 GetTableSize(SkStream * stream,int ttcIndex,SkFontTableTag tag)46 static size_t GetTableSize(SkStream* stream, int ttcIndex, SkFontTableTag tag) { 47 return GetTableData(stream, ttcIndex, tag, 0, ~0U, nullptr); 48 } 49 }; 50 51 #endif 52