OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_FONT_LOADER_MAC_H_ |
| 6 #define CHROME_COMMON_FONT_LOADER_MAC_H_ |
| 7 |
| 8 #include <ApplicationServices/ApplicationServices.h> |
| 9 |
| 10 #include "base/shared_memory.h" |
| 11 #include "base/string16.h" |
| 12 |
| 13 // Provides functionality to transmit fonts over IPC. |
| 14 // |
| 15 // Note about font formats: .dfont (datafork suitcase) fonts are currently not |
| 16 // supported by this code since ATSFontActivateFromMemory() can't handle them |
| 17 // directly. |
| 18 |
| 19 class FontLoader { |
| 20 public: |
| 21 // Load a font specified by |font_name| and |font_point_size| into a shared |
| 22 // memory buffer suitable for sending over IPC. |
| 23 // |
| 24 // On return: |
| 25 // returns true on success, false on failure. |
| 26 // |font_data| - shared memory buffer containing the raw data for the font |
| 27 // file. |
| 28 // |font_data_size| - size of data contained in |font_data|. |
| 29 static bool LoadFontIntoBuffer(const string16& font_name, |
| 30 float font_point_size, |
| 31 base::SharedMemory* font_data, |
| 32 uint32* font_data_size); |
| 33 |
| 34 // Given a shared memory buffer containing the raw data for a font file, load |
| 35 // the font into a CGFontRef. |
| 36 // |
| 37 // |data| - A shared memory handle pointing to the raw data from a font file. |
| 38 // |data_size| - Size of |data|. |
| 39 // |
| 40 // On return: |
| 41 // returns true on success, false on failure. |
| 42 // |font| - A CGFontRef containing the designated font, the caller is |
| 43 // responsible for releasing this value. |
| 44 static bool CreateCGFontFromBuffer(base::SharedMemoryHandle font_data, |
| 45 uint32 font_data_size, |
| 46 CGFontRef* font); |
| 47 }; |
| 48 |
| 49 #endif // CHROME_COMMON_FONT_LOADER_MAC_H_ |
OLD | NEW |