| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkEndian.h" | 8 #include "SkEndian.h" |
| 9 #include "SkFontStream.h" | 9 #include "SkFontStream.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (offsetToDir) { | 94 if (offsetToDir) { |
| 95 // add the size of the header, so we will point to the DirEntries | 95 // add the size of the header, so we will point to the DirEntries |
| 96 *offsetToDir = offset + sizeof(SkSFNTHeader); | 96 *offsetToDir = offset + sizeof(SkSFNTHeader); |
| 97 } | 97 } |
| 98 return SkEndian_SwapBE16(header->fSingle.fNumTables); | 98 return SkEndian_SwapBE16(header->fSingle.fNumTables); |
| 99 } | 99 } |
| 100 | 100 |
| 101 /////////////////////////////////////////////////////////////////////////////// | 101 /////////////////////////////////////////////////////////////////////////////// |
| 102 | 102 |
| 103 struct SfntHeader { | 103 struct SfntHeader { |
| 104 SfntHeader() : fCount(0), fDir(NULL) {} | 104 SfntHeader() : fCount(0), fDir(nullptr) {} |
| 105 ~SfntHeader() { sk_free(fDir); } | 105 ~SfntHeader() { sk_free(fDir); } |
| 106 | 106 |
| 107 /** If it returns true, then fCount and fDir are properly initialized. | 107 /** If it returns true, then fCount and fDir are properly initialized. |
| 108 Note: fDir will point to the raw array of SkSFNTDirEntry values, | 108 Note: fDir will point to the raw array of SkSFNTDirEntry values, |
| 109 meaning they will still be in the file's native endianness (BE). | 109 meaning they will still be in the file's native endianness (BE). |
| 110 | 110 |
| 111 fDir will be automatically freed when this object is destroyed | 111 fDir will be automatically freed when this object is destroyed |
| 112 */ | 112 */ |
| 113 bool init(SkStream* stream, int ttcIndex) { | 113 bool init(SkStream* stream, int ttcIndex) { |
| 114 stream->rewind(); | 114 stream->rewind(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 if (!read(stream, data, length)) { | 202 if (!read(stream, data, length)) { |
| 203 return 0; | 203 return 0; |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 return length; | 206 return length; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 return 0; | 209 return 0; |
| 210 } | 210 } |
| OLD | NEW |