Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / shell / app / webkit_test_platform_support_win.cc
index 938bd19..f0dde64 100644 (file)
@@ -9,11 +9,13 @@
 #include <list>
 #include <string>
 
+#include "base/command_line.h"
 #include "base/file_util.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
 #include "base/path_service.h"
 #include "base/strings/utf_string_conversions.h"
+#include "content/shell/common/shell_switches.h"
 
 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \
     offsetof(struct_name, member) + \
@@ -34,6 +36,12 @@ bool SetupFonts() {
   base::FilePath font_path =
       base_path.Append(FILE_PATH_LITERAL("/AHEM____.TTF"));
 
+  // We do two registrations:
+  // 1. For GDI font rendering via ::AddFontMemResourceEx.
+  // 2. For DirectWrite rendering by appending a command line flag that tells
+  //    the sandbox policy/warmup to grant access to the given path.
+
+  // GDI registration.
   std::string font_buffer;
   if (!base::ReadFileToString(font_path, &font_buffer)) {
     std::cerr << "Failed to load font " << base::WideToUTF8(font_path.value())
@@ -51,6 +59,12 @@ bool SetupFonts() {
     std::cerr << "Failed to register Ahem font\n";
     return false;
   }
+
+  // DirectWrite sandbox registration.
+  CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
+  command_line.AppendSwitchASCII(switches::kRegisterFontFiles,
+                                 base::WideToUTF8(font_path.value()));
+
   return true;
 }
 
@@ -64,22 +78,13 @@ bool CheckLayoutSystemDeps() {
   if (::GetSystemMetrics(SM_CXVSCROLL) != 17)
     errors.push_back("Must use normal size fonts (96 dpi).");
 
-  // ClearType must be disabled, because the rendering is unpredictable.
-  BOOL font_smoothing_enabled;
-  ::SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &font_smoothing_enabled, 0);
-  int font_smoothing_type;
-  ::SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &font_smoothing_type, 0);
-  if (font_smoothing_enabled &&
-      (font_smoothing_type == FE_FONTSMOOTHINGCLEARTYPE))
-    errors.push_back("ClearType must be disabled.");
-
   // Check that we're using the default system fonts.
   OSVERSIONINFO version_info = {0};
   version_info.dwOSVersionInfoSize = sizeof(version_info);
   ::GetVersionEx(&version_info);
   bool is_vista_or_later = (version_info.dwMajorVersion >= 6);
   NONCLIENTMETRICS metrics = {0};
-  metrics.cbSize = is_vista_or_later ? (sizeof NONCLIENTMETRICS)
+  metrics.cbSize = is_vista_or_later ? sizeof(NONCLIENTMETRICS)
                                      : NONCLIENTMETRICS_SIZE_PRE_VISTA;
   bool success = !!::SystemParametersInfo(
       SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);