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

Unified Diff: test/ot-sanitise.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 side-by-side diff with in-line comments
Download patch
« .gitmodules ('K') | « test/idempotent.cc ('k') | test/perf.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/ot-sanitise.cc
diff --git a/test/ot-sanitise.cc b/test/ot-sanitise.cc
old mode 100644
new mode 100755
index ad3054e7c9e1df8918c70bd4be26e3c9fdcb91fe..3411cac2c0c8db5df30558ff8097f53f137306f3
--- a/test/ot-sanitise.cc
+++ b/test/ot-sanitise.cc
@@ -13,6 +13,7 @@
#include <unistd.h>
#endif // defined(_WIN32)
+#include <cstdarg>
#include <cstdio>
#include <cstdlib>
@@ -28,15 +29,45 @@
namespace {
int Usage(const char *argv0) {
- std::fprintf(stderr, "Usage: %s ttf_file > dest_ttf_file\n", argv0);
+ std::fprintf(stderr, "Usage: %s ttf_file [dest_ttf_file]\n", argv0);
return 1;
}
+class Context: public ots::OTSContext {
+ public:
+ virtual void Message(int level, const char *format, ...) {
+ va_list va;
+
+ if (level == 0)
+ std::fprintf(stderr, "ERROR: ");
+ else
+ std::fprintf(stderr, "WARNING: ");
+ va_start(va, format);
+ std::vfprintf(stderr, format, va);
+ std::fprintf(stderr, "\n");
+ va_end(va);
+ }
+
+ virtual ots::TableAction GetTableAction(uint32_t tag) {
+#define TAG(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
+ switch (tag) {
+ case TAG('S','i','l','f'):
+ case TAG('S','i','l','l'):
+ case TAG('G','l','o','c'):
+ case TAG('G','l','a','t'):
+ case TAG('F','e','a','t'):
+ return ots::TABLE_ACTION_PASSTHRU;
+ default:
+ return ots::TABLE_ACTION_DEFAULT;
+ }
+#undef TAG
+ }
+};
+
} // namespace
int main(int argc, char **argv) {
- if (argc != 2) return Usage(argv[0]);
- if (::isatty(1)) return Usage(argv[0]);
+ if (argc < 2 || argc > 3) return Usage(argv[0]);
ots::EnableWOFF2();
@@ -56,11 +87,14 @@ int main(int argc, char **argv) {
}
::close(fd);
- ots::FILEStream output(stdout);
-#if defined(_WIN32)
- ::setmode(fileno(stdout), O_BINARY);
-#endif
- const bool result = ots::Process(&output, data, st.st_size);
+ Context context;
+
+ FILE* out = NULL;
+ if (argc == 3)
+ out = fopen(argv[2], "wb");
+
+ ots::FILEStream output(out);
+ const bool result = context.Process(&output, data, st.st_size);
if (!result) {
std::fprintf(stderr, "Failed to sanitise file!\n");
« .gitmodules ('K') | « test/idempotent.cc ('k') | test/perf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698