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

Side by Side Diff: third_party/woff2/src/woff2_decompress.cc

Issue 954163002: Add woff2 to src/third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase as third_party/ots/src/woff2.cc has changed Created 5 years, 9 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
« no previous file with comments | « third_party/woff2/src/woff2_dec.cc ('k') | third_party/woff2/src/woff2_enc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // A very simple commandline tool for decompressing woff2 format files to true
16 // type font files.
17
18 #include <string>
19
20
21 #include "file.h"
22 #include "./woff2_dec.h"
23
24 int main(int argc, char **argv) {
25 using std::string;
26
27 if (argc != 2) {
28 fprintf(stderr, "One argument, the input filename, must be provided.\n");
29 return 1;
30 }
31
32 string filename(argv[1]);
33 string outfilename = filename.substr(0, filename.find_last_of(".")) + ".ttf";
34 fprintf(stdout, "Processing %s => %s\n",
35 filename.c_str(), outfilename.c_str());
36 string input = woff2::GetFileContent(filename);
37
38 size_t decompressed_size = woff2::ComputeWOFF2FinalSize(
39 reinterpret_cast<const uint8_t*>(input.data()), input.size());
40 string output(decompressed_size, 0);
41 const bool ok = woff2::ConvertWOFF2ToTTF(
42 reinterpret_cast<uint8_t*>(&output[0]), decompressed_size,
43 reinterpret_cast<const uint8_t*>(input.data()), input.size());
44
45 if (!ok) {
46 fprintf(stderr, "Decompression failed\n");
47 return 1;
48 }
49
50 woff2::SetFileContents(outfilename, output);
51
52 return 0;
53 }
54
OLDNEW
« no previous file with comments | « third_party/woff2/src/woff2_dec.cc ('k') | third_party/woff2/src/woff2_enc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698