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

Side by Side Diff: chrome/common/font_loader_mac.mm

Issue 6046009: Move base/mac_util.h to base/mac and use the base::mac namespace.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/chrome_paths_mac.mm ('k') | chrome/common/sandbox_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/common/font_loader_mac.h" 5 #include "chrome/common/font_loader_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
15 15
16 // static 16 // static
17 bool FontLoader::LoadFontIntoBuffer(NSFont* font_to_encode, 17 bool FontLoader::LoadFontIntoBuffer(NSFont* font_to_encode,
18 base::SharedMemory* font_data, 18 base::SharedMemory* font_data,
19 uint32* font_data_size) { 19 uint32* font_data_size) {
20 CHECK(font_data && font_data_size); 20 CHECK(font_data && font_data_size);
21 *font_data_size = 0; 21 *font_data_size = 0;
22 22
23 // Used only for logging. 23 // Used only for logging.
(...skipping 19 matching lines...) Expand all
43 // CreateCGFontFromBuffer() is called in the same process as this function 43 // CreateCGFontFromBuffer() is called in the same process as this function
44 // e.g. when writing a unit test that exercises these two functions together. 44 // e.g. when writing a unit test that exercises these two functions together.
45 // If said unit test were to load a system font and activate it from memory 45 // If said unit test were to load a system font and activate it from memory
46 // it becomes impossible for the system to the find the original file ref 46 // it becomes impossible for the system to the find the original file ref
47 // since the font now lives in memory as far as it's concerned. 47 // since the font now lives in memory as far as it's concerned.
48 FSRef font_fsref; 48 FSRef font_fsref;
49 if (ATSFontGetFileReference(ats_font, &font_fsref) != noErr) { 49 if (ATSFontGetFileReference(ats_font, &font_fsref) != noErr) {
50 LOG(ERROR) << "Failed to find font file for " << font_name; 50 LOG(ERROR) << "Failed to find font file for " << font_name;
51 return false; 51 return false;
52 } 52 }
53 FilePath font_path = FilePath(mac_util::PathFromFSRef(font_fsref)); 53 FilePath font_path = FilePath(base::mac::PathFromFSRef(font_fsref));
54 54
55 // Load file into shared memory buffer. 55 // Load file into shared memory buffer.
56 int64 font_file_size_64 = -1; 56 int64 font_file_size_64 = -1;
57 if (!file_util::GetFileSize(font_path, &font_file_size_64)) { 57 if (!file_util::GetFileSize(font_path, &font_file_size_64)) {
58 LOG(ERROR) << "Couldn't get font file size for " << font_path.value(); 58 LOG(ERROR) << "Couldn't get font file size for " << font_path.value();
59 return false; 59 return false;
60 } 60 }
61 61
62 if (font_file_size_64 <= 0 || font_file_size_64 >= kint32max) { 62 if (font_file_size_64 <= 0 || font_file_size_64 >= kint32max) {
63 LOG(ERROR) << "Bad size for font file " << font_path.value(); 63 LOG(ERROR) << "Bad size for font file " << font_path.value();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // This is the value used by WebKit when activating remote fonts. 101 // This is the value used by WebKit when activating remote fonts.
102 const ATSFontContext kFontContextPrivate = 3; 102 const ATSFontContext kFontContextPrivate = 3;
103 OSStatus err = ATSFontActivateFromMemory(shm.memory(), font_data_size, 103 OSStatus err = ATSFontActivateFromMemory(shm.memory(), font_data_size,
104 kFontContextPrivate, kATSFontFormatUnspecified, NULL, 104 kFontContextPrivate, kATSFontFormatUnspecified, NULL,
105 kATSOptionFlagsDefault, font_container); 105 kATSOptionFlagsDefault, font_container);
106 if (err != noErr || !font_container) 106 if (err != noErr || !font_container)
107 return false; 107 return false;
108 108
109 return true; 109 return true;
110 } 110 }
OLDNEW
« no previous file with comments | « chrome/common/chrome_paths_mac.mm ('k') | chrome/common/sandbox_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698