1 // Copyright 2013 Google Inc. All Rights Reserved.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 // A very simple commandline tool for decompressing woff2 format files to true
22 #include "./woff2_dec.h"
24 int main(int argc
, char **argv
) {
28 fprintf(stderr
, "One argument, the input filename, must be provided.\n");
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
);
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());
46 fprintf(stderr
, "Decompression failed\n");
50 woff2::SetFileContents(outfilename
, output
);