Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/woff2_compress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,37 @@

/* A commandline tool for compressing ttf format files to woff2. */

#include <string>

#include "file.h"
#include <woff2/encode.h>

#include "woff2_compress.h"

int main(int argc, char **argv) {
using std::string;

if (argc != 2) {
fprintf(stderr, "One argument, the input filename, must be provided.\n");
fprintf(stderr, "Please include an argument with your command.\n");
fprintf(stderr, "%s\n", USAGESTRING.c_str());
return 1;
}

string argument = argv[1];
if (argument == "--help" || argument == "-h") {
fprintf(stdout, "%s\n", APPLICATION.c_str());
fprintf(stdout, "%s\n", AUTHOR.c_str());
fprintf(stdout, "%s\n", LICENSE.c_str());
fprintf(stdout, "\n%s\n", HELPSTRING.c_str());
fprintf(stdout, "\n%s\n", USAGESTRING.c_str());
return 0;
}

if (argument == "--usage") {
fprintf(stdout, "%s\n", USAGESTRING.c_str());
return 0;
}

if (argument == "--version" || argument == "-v") {
fprintf(stdout, "%s %s\n", APPLICATION.c_str(), VERSION.c_str());
return 0;
}

string filename(argv[1]);
string outfilename = filename.substr(0, filename.find_last_of(".")) + ".woff2";
fprintf(stdout, "Processing %s => %s\n",
Expand Down
23 changes: 23 additions & 0 deletions src/woff2_compress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Copyright 2018 Google Inc. All Rights Reserved.

Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

#ifndef WOFF2_WOFF2_COMPRESS_H_
#define WOFF2_WOFF2_COMPRESS_H_

#include <string>

#include "file.h"
#include <woff2/encode.h>

#define VERSION string("v1.0.3")

#define APPLICATION string("woff2_compress")
#define AUTHOR string("Copyright 2013 Google Inc.")
#define LICENSE string("MIT License")
#define HELPSTRING string("Include a single *.ttf or *.otf font file path argument to compile to a *.woff2 font file.")
#define USAGESTRING string("Usage: woff2_compress [font file path]")

#endif // WOFF2_WOFF2_COMPRESS_H_
31 changes: 24 additions & 7 deletions src/woff2_decompress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,35 @@
/* A very simple commandline tool for decompressing woff2 format files to true
type font files. */

#include <string>

#include "./file.h"
#include <woff2/decode.h>

#include "woff2_decompress.h"

int main(int argc, char **argv) {
using std::string;

if (argc != 2) {
fprintf(stderr, "One argument, the input filename, must be provided.\n");
return 1;
fprintf(stderr, "Please include an argument with your command.\n");
fprintf(stderr, "%s\n", USAGESTRING.c_str());
return 1;
}

string argument = argv[1];
if (argument == "--help" || argument == "-h") {
fprintf(stdout, "%s\n", APPLICATION.c_str());
fprintf(stdout, "%s\n", AUTHOR.c_str());
fprintf(stdout, "%s\n", LICENSE.c_str());
fprintf(stdout, "\n%s\n", HELPSTRING.c_str());
fprintf(stdout, "\n%s\n", USAGESTRING.c_str());
return 0;
}

if (argument == "--usage") {
fprintf(stdout, "%s\n", USAGESTRING.c_str());
return 0;
}

if (argument == "--version" || argument == "-v") {
fprintf(stdout, "%s %s\n", APPLICATION.c_str(), VERSION.c_str());
return 0;
}

string filename(argv[1]);
Expand Down
23 changes: 23 additions & 0 deletions src/woff2_decompress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Copyright 2018 Google Inc. All Rights Reserved.

Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/

#ifndef WOFF2_WOFF2_DECOMPRESS_H_
#define WOFF2_WOFF2_DECOMPRESS_H_

#include <string>

#include "file.h"
#include <woff2/decode.h>

#define VERSION string("v1.0.3")

#define APPLICATION string("woff2_decompress")
#define AUTHOR string("Copyright 2013 Google Inc.")
#define LICENSE string("MIT License")
#define HELPSTRING string("Include a single *.woff2 font file path argument to decode to a *.ttf font.")
#define USAGESTRING string("Usage: woff2_decompress [font file path]")

#endif // WOFF2_WOFF2_DECOMPRESS_H_