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

Unified Diff: content/common/font_loader_mac.mm

Issue 7080024: Mac: Part 1 of a fix to get OOP font loading working in the renderer on 10.6.6 . (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comments Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/font_loader_mac.h ('k') | content/common/sandbox_mac_fontloading_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/font_loader_mac.mm
diff --git a/content/common/font_loader_mac.mm b/content/common/font_loader_mac.mm
index 124708b2c42ddb0b042a31b46d0b19c7b5d23999..595322f783b525e0358592bc07f89811ea60ea73 100644
--- a/content/common/font_loader_mac.mm
+++ b/content/common/font_loader_mac.mm
@@ -16,9 +16,13 @@
// static
bool FontLoader::LoadFontIntoBuffer(NSFont* font_to_encode,
base::SharedMemory* font_data,
- uint32* font_data_size) {
- CHECK(font_data && font_data_size);
+ uint32* font_data_size,
+ uint32* font_id) {
+ CHECK(font_data);
+ CHECK(font_data_size);
+ CHECK(font_id);
*font_data_size = 0;
+ *font_id = 0;
// Used only for logging.
std::string font_name([[font_to_encode fontName] UTF8String]);
@@ -37,6 +41,17 @@ bool FontLoader::LoadFontIntoBuffer(NSFont* font_to_encode,
return false;
}
+ // Retrieve the ATSFontContainerRef corresponding to the font file we want to
+ // load. This is a unique identifier that allows the caller determine if the
+ // font file in question is already loaded.
+ COMPILE_ASSERT(sizeof(ATSFontContainerRef) == sizeof(font_id),
+ uint32_cant_hold_fontcontainer_ref);
+ ATSFontContainerRef fontContainer = kATSFontContainerRefUnspecified;
+ if (ATSFontGetContainer(ats_font, 0, &fontContainer) != noErr) {
+ LOG(ERROR) << "Failed to get font container ref for " << font_name;
+ return false;
+ }
+
// ATSFontRef -> File path.
// Warning: Calling this function on a font activated from memory will result
// in failure with a -50 - paramErr. This may occur if
@@ -79,6 +94,7 @@ bool FontLoader::LoadFontIntoBuffer(NSFont* font_to_encode,
}
*font_data_size = font_file_size_32;
+ *font_id = fontContainer;
return true;
}
« no previous file with comments | « content/common/font_loader_mac.h ('k') | content/common/sandbox_mac_fontloading_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698