OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/mac/bundle_locations.h" |
6 #include "content/shell/webkit_test_platform_support.h" | 7 #include "content/shell/webkit_test_platform_support.h" |
7 | 8 |
8 #include <AppKit/AppKit.h> | 9 #include <AppKit/AppKit.h> |
9 #include <Foundation/Foundation.h> | 10 #include <Foundation/Foundation.h> |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 void SetDefaultsToLayoutTestValues(void) { | 16 void SetDefaultsToLayoutTestValues(void) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 "WebKitWeightWatcher700.ttf", | 53 "WebKitWeightWatcher700.ttf", |
53 "WebKitWeightWatcher800.ttf", | 54 "WebKitWeightWatcher800.ttf", |
54 "WebKitWeightWatcher900.ttf", | 55 "WebKitWeightWatcher900.ttf", |
55 }; | 56 }; |
56 | 57 |
57 // mainBundle is Content Shell Helper.app. Go two levels up to find | 58 // mainBundle is Content Shell Helper.app. Go two levels up to find |
58 // Content Shell.app. Due to DumpRenderTree injecting the font files into | 59 // Content Shell.app. Due to DumpRenderTree injecting the font files into |
59 // its direct dependents, it's not easily possible to put the ttf files into | 60 // its direct dependents, it's not easily possible to put the ttf files into |
60 // the helper's resource directory instead of the outer bundle's resource | 61 // the helper's resource directory instead of the outer bundle's resource |
61 // directory. | 62 // directory. |
62 NSString* bundle = [[NSBundle mainBundle] bundlePath]; | 63 NSString* bundle = [base::mac::FrameworkBundle() bundlePath]; |
63 bundle = [bundle stringByAppendingPathComponent:@"../.."]; | 64 bundle = [bundle stringByAppendingPathComponent:@"../.."]; |
64 NSURL* resources_directory = [[NSBundle bundleWithPath:bundle] resourceURL]; | 65 NSURL* resources_directory = [[NSBundle bundleWithPath:bundle] resourceURL]; |
65 | 66 |
66 NSMutableArray* font_urls = [NSMutableArray array]; | 67 NSMutableArray* font_urls = [NSMutableArray array]; |
67 for (unsigned i = 0; i < arraysize(fontFileNames); ++i) { | 68 for (unsigned i = 0; i < arraysize(fontFileNames); ++i) { |
68 NSURL* font_url = [resources_directory | 69 NSURL* font_url = [resources_directory |
69 URLByAppendingPathComponent:[NSString | 70 URLByAppendingPathComponent:[NSString |
70 stringWithUTF8String:fontFileNames[i]]]; | 71 stringWithUTF8String:fontFileNames[i]]]; |
71 [font_urls addObject:[font_url absoluteURL]]; | 72 [font_urls addObject:[font_url absoluteURL]]; |
72 } | 73 } |
73 | 74 |
74 CFArrayRef errors = 0; | 75 CFArrayRef errors = 0; |
75 if (!CTFontManagerRegisterFontsForURLs((CFArrayRef)font_urls, | 76 if (!CTFontManagerRegisterFontsForURLs((CFArrayRef)font_urls, |
76 kCTFontManagerScopeProcess, | 77 kCTFontManagerScopeProcess, |
77 &errors)) { | 78 &errors)) { |
78 DLOG(FATAL) << "Fail to activate fonts."; | 79 DLOG(FATAL) << "Fail to activate fonts."; |
79 CFRelease(errors); | 80 CFRelease(errors); |
80 } | 81 } |
81 | 82 |
82 return true; | 83 return true; |
83 } | 84 } |
84 | 85 |
85 } // namespace | 86 } // namespace |
OLD | NEW |