OLD | NEW |
1 // Copyright 2014 Google Inc. All Rights Reserved. | 1 // Copyright 2014 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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 // | 14 // |
15 // Library for converting WOFF2 format font files to their TTF versions. | 15 // Library for converting WOFF2 format font files to their TTF versions. |
16 | 16 |
17 #include "./woff2_dec.h" | 17 #include "./woff2_dec.h" |
18 | 18 |
19 #include <stdlib.h> | 19 #include <stdlib.h> |
20 #include <algorithm> | 20 #include <algorithm> |
| 21 #include <brotli/decode.h> |
21 #include <complex> | 22 #include <complex> |
22 #include <cstring> | 23 #include <cstring> |
23 #include <limits> | 24 #include <limits> |
24 #include <string> | 25 #include <string> |
25 #include <vector> | 26 #include <vector> |
26 #include <map> | 27 #include <map> |
27 #include <memory> | 28 #include <memory> |
28 #include <utility> | 29 #include <utility> |
29 | 30 |
30 #include "./decode.h" | |
31 #include "./buffer.h" | 31 #include "./buffer.h" |
32 #include "./port.h" | 32 #include "./port.h" |
33 #include "./round.h" | 33 #include "./round.h" |
34 #include "./store_bytes.h" | 34 #include "./store_bytes.h" |
35 #include "./table_tags.h" | 35 #include "./table_tags.h" |
36 #include "./variable_length.h" | 36 #include "./variable_length.h" |
37 #include "./woff2_common.h" | 37 #include "./woff2_common.h" |
38 | 38 |
39 namespace woff2 { | 39 namespace woff2 { |
40 | 40 |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 if (PREDICT_FALSE(!out->Write(&hmtx_table[0], hmtx_output_size))) { | 729 if (PREDICT_FALSE(!out->Write(&hmtx_table[0], hmtx_output_size))) { |
730 return FONT_COMPRESSION_FAILURE(); | 730 return FONT_COMPRESSION_FAILURE(); |
731 } | 731 } |
732 | 732 |
733 return true; | 733 return true; |
734 } | 734 } |
735 | 735 |
736 bool Woff2Uncompress(uint8_t* dst_buf, size_t dst_size, | 736 bool Woff2Uncompress(uint8_t* dst_buf, size_t dst_size, |
737 const uint8_t* src_buf, size_t src_size) { | 737 const uint8_t* src_buf, size_t src_size) { |
738 size_t uncompressed_size = dst_size; | 738 size_t uncompressed_size = dst_size; |
739 int ok = BrotliDecompressBuffer(src_size, src_buf, | 739 BrotliDecoderResult result = BrotliDecoderDecompress( |
740 &uncompressed_size, dst_buf); | 740 src_size, src_buf, &uncompressed_size, dst_buf); |
741 if (PREDICT_FALSE(!ok || uncompressed_size != dst_size)) { | 741 if (PREDICT_FALSE(result != BROTLI_DECODER_RESULT_SUCCESS || |
| 742 uncompressed_size != dst_size)) { |
742 return FONT_COMPRESSION_FAILURE(); | 743 return FONT_COMPRESSION_FAILURE(); |
743 } | 744 } |
744 return true; | 745 return true; |
745 } | 746 } |
746 | 747 |
747 bool ReadTableDirectory(Buffer* file, std::vector<Table>* tables, | 748 bool ReadTableDirectory(Buffer* file, std::vector<Table>* tables, |
748 size_t num_tables) { | 749 size_t num_tables) { |
749 uint32_t src_offset = 0; | 750 uint32_t src_offset = 0; |
750 for (size_t i = 0; i < num_tables; ++i) { | 751 for (size_t i = 0; i < num_tables; ++i) { |
751 Table* table = &(*tables)[i]; | 752 Table* table = &(*tables)[i]; |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1300 hdr.uncompressed_size, | 1301 hdr.uncompressed_size, |
1301 &metadata, &hdr, i, out))) { | 1302 &metadata, &hdr, i, out))) { |
1302 return FONT_COMPRESSION_FAILURE(); | 1303 return FONT_COMPRESSION_FAILURE(); |
1303 } | 1304 } |
1304 } | 1305 } |
1305 | 1306 |
1306 return true; | 1307 return true; |
1307 } | 1308 } |
1308 | 1309 |
1309 } // namespace woff2 | 1310 } // namespace woff2 |
OLD | NEW |