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

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

Issue 2804001: Mac: More pluming for OOP font loading (Closed)
Patch Set: Fix review comments Created 10 years, 6 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
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 #ifndef CHROME_COMMON_FONT_LOADER_MAC_H_ 5 #ifndef CHROME_COMMON_FONT_LOADER_MAC_H_
6 #define CHROME_COMMON_FONT_LOADER_MAC_H_ 6 #define CHROME_COMMON_FONT_LOADER_MAC_H_
7 7
8 #include <ApplicationServices/ApplicationServices.h> 8 #include <ApplicationServices/ApplicationServices.h>
9 9
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 12
13 #ifdef __OBJC__
14 @class NSFont;
15 #else
16 class NSFont;
17 #endif
18
13 // Provides functionality to transmit fonts over IPC. 19 // Provides functionality to transmit fonts over IPC.
14 // 20 //
15 // Note about font formats: .dfont (datafork suitcase) fonts are currently not 21 // Note about font formats: .dfont (datafork suitcase) fonts are currently not
16 // supported by this code since ATSFontActivateFromMemory() can't handle them 22 // supported by this code since ATSFontActivateFromMemory() can't handle them
17 // directly. 23 // directly.
18 24
19 class FontLoader { 25 class FontLoader {
20 public: 26 public:
21 // Load a font specified by |font_name| and |font_point_size| into a shared 27 // Load a font specified by |font_to_encode| into a shared memory buffer
22 // memory buffer suitable for sending over IPC. 28 // suitable for sending over IPC.
23 // 29 //
24 // On return: 30 // On return:
25 // returns true on success, false on failure. 31 // returns true on success, false on failure.
26 // |font_data| - shared memory buffer containing the raw data for the font 32 // |font_data| - shared memory buffer containing the raw data for the font
27 // file. 33 // file.
28 // |font_data_size| - size of data contained in |font_data|. 34 // |font_data_size| - size of data contained in |font_data|.
29 static bool LoadFontIntoBuffer(const string16& font_name, 35 static bool LoadFontIntoBuffer(NSFont* font_to_encode,
30 float font_point_size,
31 base::SharedMemory* font_data, 36 base::SharedMemory* font_data,
32 uint32* font_data_size); 37 uint32* font_data_size);
33 38
34 // Given a shared memory buffer containing the raw data for a font file, load 39 // Given a shared memory buffer containing the raw data for a font file, load
35 // the font into a CGFontRef. 40 // the font and return a container ref.
36 // 41 //
37 // |data| - A shared memory handle pointing to the raw data from a font file. 42 // |data| - A shared memory handle pointing to the raw data from a font file.
38 // |data_size| - Size of |data|. 43 // |data_size| - Size of |data|.
39 // 44 //
40 // On return: 45 // On return:
41 // returns true on success, false on failure. 46 // returns true on success, false on failure.
42 // |font| - A CGFontRef containing the designated font, the caller is 47 // |font_container| - A font container corresponding to the designated font.
43 // responsible for releasing this value. 48 // The caller is responsible for releasing this value via ATSFontDeactivate()
44 static bool CreateCGFontFromBuffer(base::SharedMemoryHandle font_data, 49 // when done
45 uint32 font_data_size, 50 static bool ATSFontContainerFromBuffer(base::SharedMemoryHandle font_data,
46 CGFontRef* font); 51 uint32 font_data_size,
52 ATSFontContainerRef* font_container);
47 }; 53 };
48 54
49 #endif // CHROME_COMMON_FONT_LOADER_MAC_H_ 55 #endif // CHROME_COMMON_FONT_LOADER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698