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

Unified Diff: test/idempotent.cc

Issue 408020: Upload test scripts which I'm currently using.... (Closed) Base URL: http://ots.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 1 month 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
« no previous file with comments | « test/SConstruct ('k') | test/test_malicious_fonts.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/idempotent.cc
===================================================================
--- test/idempotent.cc (revision 10)
+++ test/idempotent.cc (working copy)
@@ -2,6 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#if !defined(_MSC_VER)
+#ifdef __linux__
+// Linux
+#include <freetype/ftoutln.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#else
+// Mac OS X
+#include <ApplicationServices/ApplicationServices.h> // g++ -framework Cocoa
+#endif // __linux__
+#else
+// Windows
+// TODO(yusukes): Support Windows.
+#endif // _MSC_VER
+
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -90,5 +105,59 @@
}
}
+ // Verify that the transcoded font can be opened by the font renderer for
+ // Linux (FreeType2), Mac OS X, or Windows.
+#if !defined(_MSC_VER)
+#ifdef __linux__
+ // Linux
+ FT_Library library;
+ FT_Error error = ::FT_Init_FreeType(&library);
+ if (error) {
+ std::fprintf(stderr, "Failed to initialize FreeType2!\n");
+ return 1;
+ }
+ FT_Face dummy;
+ error = ::FT_New_Memory_Face(library, result, result_len, 0, &dummy);
+ if (error) {
+ std::fprintf(stderr, "Failed to open the transcoded font\n");
+ return 1;
+ }
+#else
+ // Mac OS X
+ ATSFontContainerRef container_ref = 0;
+ ATSFontActivateFromMemory(result, result_len, 3, kATSFontFormatUnspecified,
+ NULL, kATSOptionFlagsDefault, &container_ref);
+ if (!container_ref) {
+ std::fprintf(stderr, "Failed to open the transcoded font\n");
+ return 1;
+ }
+
+ ItemCount count;
+ ATSFontFindFromContainer(
+ container_ref, kATSOptionFlagsDefault, 0, NULL, &count);
+ if (!count) {
+ std::fprintf(stderr, "Failed to open the transcoded font\n");
+ return 1;
+ }
+
+ ATSFontRef ats_font_ref = 0;
+ ATSFontFindFromContainer(
+ container_ref, kATSOptionFlagsDefault, 1, &ats_font_ref, NULL);
+ if (!ats_font_ref) {
+ std::fprintf(stderr, "Failed to open the transcoded font\n");
+ return 1;
+ }
+
+ CGFontRef cg_font_ref = CGFontCreateWithPlatformFont(&ats_font_ref);
+ if (!CGFontGetNumberOfGlyphs(cg_font_ref)) {
+ std::fprintf(stderr, "Failed to open the transcoded font\n");
+ return 1;
+ }
+#endif // __linux__
+#else
+ // Windows
+ // TODO(yusukes): Support Windows.
+#endif // _MSC_VER
+
return 0;
}
« no previous file with comments | « test/SConstruct ('k') | test/test_malicious_fonts.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698