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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 SfntHeader() : fCount(0), fDir(NULL) {} | 82 SfntHeader() : fCount(0), fDir(NULL) {} |
83 ~SfntHeader() { sk_free(fDir); } | 83 ~SfntHeader() { sk_free(fDir); } |
84 | 84 |
85 /** If it returns true, then fCount and fDir are properly initialized. | 85 /** If it returns true, then fCount and fDir are properly initialized. |
86 Note: fDir will point to the raw array of SkSFNTDirEntry values, | 86 Note: fDir will point to the raw array of SkSFNTDirEntry values, |
87 meaning they will still be in the file's native endianness (BE). | 87 meaning they will still be in the file's native endianness (BE). |
88 | 88 |
89 fDir will be automatically freed when this object is destroyed | 89 fDir will be automatically freed when this object is destroyed |
90 */ | 90 */ |
91 bool init(SkStream* stream) { | 91 bool init(SkStream* stream) { |
| 92 stream->rewind(); |
| 93 |
92 size_t offsetToDir; | 94 size_t offsetToDir; |
93 fCount = count_tables(stream, &offsetToDir); | 95 fCount = count_tables(stream, &offsetToDir); |
94 if (0 == fCount) { | 96 if (0 == fCount) { |
95 return false; | 97 return false; |
96 } | 98 } |
97 | 99 |
98 stream->rewind(); | 100 stream->rewind(); |
99 if (stream->skip(offsetToDir) != offsetToDir) { | 101 if (stream->skip(offsetToDir) != offsetToDir) { |
100 return false; | 102 return false; |
101 } | 103 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 160 } |
159 if (stream->read(data, length) != length) { | 161 if (stream->read(data, length) != length) { |
160 return 0; | 162 return 0; |
161 } | 163 } |
162 } | 164 } |
163 return length; | 165 return length; |
164 } | 166 } |
165 } | 167 } |
166 return 0; | 168 return 0; |
167 } | 169 } |
OLD | NEW |