Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: src/woff2.cc

Issue 658573004: Updating to new OTS repo from https://github.com/khaledhosny/ots.git (Closed) Base URL: https://chromium.googlesource.com/external/ots@master
Patch Set: Adding Colored Emoji changes from external/git repo Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« .gitmodules ('K') | « src/vorg.cc ('k') | test/README » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is the implementation of decompression of the proposed WOFF Ultra 5 // This is the implementation of decompression of the proposed WOFF Ultra
6 // Condensed file format. 6 // Condensed file format.
7 7
8 #include <cassert> 8 #include <cassert>
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <vector> 10 #include <vector>
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 &points, &triplet_bytes_consumed)) { 627 &points, &triplet_bytes_consumed)) {
628 return OTS_FAILURE(); 628 return OTS_FAILURE();
629 } 629 }
630 const uint32_t header_and_endpts_contours_size = 630 const uint32_t header_and_endpts_contours_size =
631 kEndPtsOfContoursOffset + 2 * n_contours; 631 kEndPtsOfContoursOffset + 2 * n_contours;
632 if (glyf_dst_size < header_and_endpts_contours_size) { 632 if (glyf_dst_size < header_and_endpts_contours_size) {
633 return OTS_FAILURE(); 633 return OTS_FAILURE();
634 } 634 }
635 StoreU16(glyf_dst, 0, n_contours); 635 StoreU16(glyf_dst, 0, n_contours);
636 ComputeBbox(points, glyf_dst); 636 ComputeBbox(points, glyf_dst);
637 size_t offset = kEndPtsOfContoursOffset; 637 size_t endpts_offset = kEndPtsOfContoursOffset;
638 int end_point = -1; 638 int end_point = -1;
639 for (unsigned int contour_ix = 0; contour_ix < n_contours; ++contour_ix) { 639 for (unsigned int contour_ix = 0; contour_ix < n_contours; ++contour_ix) {
640 end_point += n_points_vec.at(contour_ix); 640 end_point += n_points_vec.at(contour_ix);
641 if (end_point >= 65536) { 641 if (end_point >= 65536) {
642 return OTS_FAILURE(); 642 return OTS_FAILURE();
643 } 643 }
644 offset = StoreU16(glyf_dst, offset, static_cast<uint16_t>(end_point)); 644 endpts_offset = StoreU16(glyf_dst, endpts_offset, static_cast<uint16_t>( end_point));
645 } 645 }
646 if (!flag_stream.Skip(flag_size)) { 646 if (!flag_stream.Skip(flag_size)) {
647 return OTS_FAILURE(); 647 return OTS_FAILURE();
648 } 648 }
649 if (!glyph_stream.Skip(triplet_bytes_consumed)) { 649 if (!glyph_stream.Skip(triplet_bytes_consumed)) {
650 return OTS_FAILURE(); 650 return OTS_FAILURE();
651 } 651 }
652 uint16_t instruction_size; 652 uint16_t instruction_size;
653 if (!Read255UShort(&glyph_stream, &instruction_size)) { 653 if (!Read255UShort(&glyph_stream, &instruction_size)) {
654 return OTS_FAILURE(); 654 return OTS_FAILURE();
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 } 863 }
864 return total_length; 864 return total_length;
865 } 865 }
866 866
867 bool ConvertWOFF2ToTTF(uint8_t* result, size_t result_length, 867 bool ConvertWOFF2ToTTF(uint8_t* result, size_t result_length,
868 const uint8_t* data, size_t length) { 868 const uint8_t* data, size_t length) {
869 static const uint32_t kWoff2Signature = 0x774f4632; // "wOF2" 869 static const uint32_t kWoff2Signature = 0x774f4632; // "wOF2"
870 ots::Buffer file(data, length); 870 ots::Buffer file(data, length);
871 871
872 uint32_t signature; 872 uint32_t signature;
873 uint32_t flavor; 873 uint32_t flavor = 0;
874 if (!file.ReadU32(&signature) || signature != kWoff2Signature || 874 if (!file.ReadU32(&signature) || signature != kWoff2Signature ||
875 !file.ReadU32(&flavor)) { 875 !file.ReadU32(&flavor)) {
876 return OTS_FAILURE(); 876 return OTS_FAILURE();
877 } 877 }
878 878
879 if (!IsValidVersionTag(ntohl(flavor))) { 879 if (!IsValidVersionTag(ntohl(flavor))) {
880 return OTS_FAILURE(); 880 return OTS_FAILURE();
881 } 881 }
882 882
883 uint32_t reported_length; 883 uint32_t reported_length;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 if (transform_buf > &uncompressed_buf[0] + uncompressed_buf.size()) { 1034 if (transform_buf > &uncompressed_buf[0] + uncompressed_buf.size()) {
1035 return OTS_FAILURE(); 1035 return OTS_FAILURE();
1036 } 1036 }
1037 } 1037 }
1038 } 1038 }
1039 1039
1040 return FixChecksums(tables, result); 1040 return FixChecksums(tables, result);
1041 } 1041 }
1042 1042
1043 } // namespace ots 1043 } // namespace ots
OLDNEW
« .gitmodules ('K') | « src/vorg.cc ('k') | test/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698