Chromium Code Reviews| 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..c2bda4b765f5c560c74a37afaa8dc3548f57f897 100644 |
| --- a/content/common/font_loader_mac.mm |
| +++ b/content/common/font_loader_mac.mm |
| @@ -16,9 +16,11 @@ |
| // 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 && font_data_size && font_id); |
|
Nico
2011/05/30 13:19:37
I'd make this 3 separate CHECK statements, that gi
|
| *font_data_size = 0; |
| + *font_id = 0; |
| // Used only for logging. |
| std::string font_name([[font_to_encode fontName] UTF8String]); |
| @@ -37,6 +39,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 +92,7 @@ bool FontLoader::LoadFontIntoBuffer(NSFont* font_to_encode, |
| } |
| *font_data_size = font_file_size_32; |
| + *font_id = fontContainer; |
| return true; |
| } |