| OLD | NEW |
| 1 // Copyright 2013 Google Inc. All Rights Reserved. | 1 // Copyright 2013 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph) { | 73 bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph) { |
| 74 Buffer buffer(data, len); | 74 Buffer buffer(data, len); |
| 75 | 75 |
| 76 int16_t num_contours; | 76 int16_t num_contours; |
| 77 if (!buffer.ReadS16(&num_contours)) { | 77 if (!buffer.ReadS16(&num_contours)) { |
| 78 return FONT_COMPRESSION_FAILURE(); | 78 return FONT_COMPRESSION_FAILURE(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 if (num_contours == 0) { | |
| 82 // Empty glyph. | |
| 83 return true; | |
| 84 } | |
| 85 | |
| 86 // Read the bounding box. | 81 // Read the bounding box. |
| 87 if (!buffer.ReadS16(&glyph->x_min) || | 82 if (!buffer.ReadS16(&glyph->x_min) || |
| 88 !buffer.ReadS16(&glyph->y_min) || | 83 !buffer.ReadS16(&glyph->y_min) || |
| 89 !buffer.ReadS16(&glyph->x_max) || | 84 !buffer.ReadS16(&glyph->x_max) || |
| 90 !buffer.ReadS16(&glyph->y_max)) { | 85 !buffer.ReadS16(&glyph->y_max)) { |
| 91 return FONT_COMPRESSION_FAILURE(); | 86 return FONT_COMPRESSION_FAILURE(); |
| 92 } | 87 } |
| 93 | 88 |
| 89 if (num_contours == 0) { |
| 90 // Empty glyph. |
| 91 return true; |
| 92 } |
| 93 |
| 94 if (num_contours > 0) { | 94 if (num_contours > 0) { |
| 95 // Simple glyph. | 95 // Simple glyph. |
| 96 glyph->contours.resize(num_contours); | 96 glyph->contours.resize(num_contours); |
| 97 | 97 |
| 98 // Read the number of points per contour. | 98 // Read the number of points per contour. |
| 99 uint16_t last_point_index = 0; | 99 uint16_t last_point_index = 0; |
| 100 for (int i = 0; i < num_contours; ++i) { | 100 for (int i = 0; i < num_contours; ++i) { |
| 101 uint16_t point_index; | 101 uint16_t point_index; |
| 102 if (!buffer.ReadU16(&point_index)) { | 102 if (!buffer.ReadU16(&point_index)) { |
| 103 return FONT_COMPRESSION_FAILURE(); | 103 return FONT_COMPRESSION_FAILURE(); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 StoreInstructions(glyph, &offset, dst); | 371 StoreInstructions(glyph, &offset, dst); |
| 372 if (!StorePoints(glyph, &offset, dst, *dst_size)) { | 372 if (!StorePoints(glyph, &offset, dst, *dst_size)) { |
| 373 return FONT_COMPRESSION_FAILURE(); | 373 return FONT_COMPRESSION_FAILURE(); |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 *dst_size = offset; | 376 *dst_size = offset; |
| 377 return true; | 377 return true; |
| 378 } | 378 } |
| 379 | 379 |
| 380 } // namespace woff2 | 380 } // namespace woff2 |
| OLD | NEW |