| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #if !defined(_MSC_VER) | 5 #if !defined(_MSC_VER) |
| 6 #ifdef __linux__ | 6 #ifdef __linux__ |
| 7 // Linux | 7 // Linux |
| 8 #include <freetype/ftoutln.h> | |
| 9 #include <ft2build.h> | 8 #include <ft2build.h> |
| 10 #include FT_FREETYPE_H | 9 #include FT_FREETYPE_H |
| 10 #include FT_OUTLINE_H |
| 11 #else | 11 #else |
| 12 // Mac OS X | 12 // Mac OS X |
| 13 #include <ApplicationServices/ApplicationServices.h> // g++ -framework Cocoa | 13 #include <ApplicationServices/ApplicationServices.h> // g++ -framework Cocoa |
| 14 #endif // __linux__ | 14 #endif // __linux__ |
| 15 #else | 15 #else |
| 16 // Windows | 16 // Windows |
| 17 // TODO(yusukes): Support Windows. | 17 // TODO(yusukes): Support Windows. |
| 18 #endif // _MSC_VER | 18 #endif // _MSC_VER |
| 19 | 19 |
| 20 #include <fcntl.h> | 20 #include <fcntl.h> |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 if (::read(fd, orig_font, orig_len) != orig_len) { | 154 if (::read(fd, orig_font, orig_len) != orig_len) { |
| 155 std::fprintf(stderr, "Failed to read file!\n"); | 155 std::fprintf(stderr, "Failed to read file!\n"); |
| 156 return 1; | 156 return 1; |
| 157 } | 157 } |
| 158 ::close(fd); | 158 ::close(fd); |
| 159 | 159 |
| 160 // transcode the malicious font. | 160 // transcode the malicious font. |
| 161 static const size_t kBigPadLen = 1024 * 1024; // 1MB | 161 static const size_t kBigPadLen = 1024 * 1024; // 1MB |
| 162 uint8_t *trans_font = new uint8_t[orig_len + kBigPadLen]; | 162 uint8_t *trans_font = new uint8_t[orig_len + kBigPadLen]; |
| 163 ots::MemoryStream output(trans_font, orig_len + kBigPadLen); | 163 ots::MemoryStream output(trans_font, orig_len + kBigPadLen); |
| 164 ots::OTSContext context; |
| 164 | 165 |
| 165 bool result = ots::Process(&output, orig_font, orig_len); | 166 bool result = context.Process(&output, orig_font, orig_len); |
| 166 if (!result) { | 167 if (!result) { |
| 167 std::fprintf(stderr, "OK: the malicious font was filtered: %s\n", argv[1]); | 168 std::fprintf(stderr, "OK: the malicious font was filtered: %s\n", argv[1]); |
| 168 return 0; | 169 return 0; |
| 169 } | 170 } |
| 170 const size_t trans_len = output.Tell(); | 171 const size_t trans_len = output.Tell(); |
| 171 | 172 |
| 172 return OpenAndLoadChars(argv[1], trans_font, trans_len); | 173 return OpenAndLoadChars(argv[1], trans_font, trans_len); |
| 173 } | 174 } |
| OLD | NEW |