diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-23 16:43:44 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-23 16:43:44 +0000 |
commit | 865f37920b4b2b600832017c9f3c1741a38b416a (patch) | |
tree | 7607eb7788c645020bd8553adf4adb89b7ce332a /chrome/common/font_loader_mac.h | |
parent | 7e1b0740be7db1a28e5f3559339f2abbe9668763 (diff) | |
download | chromium_src-865f37920b4b2b600832017c9f3c1741a38b416a.zip chromium_src-865f37920b4b2b600832017c9f3c1741a38b416a.tar.gz chromium_src-865f37920b4b2b600832017c9f3c1741a38b416a.tar.bz2 |
Mac: Infrastructure for serialization of OS fonts over IPC.
BUG=29729
TEST=All unit tests should pass.
Review URL: http://codereview.chromium.org/2131005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48002 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/font_loader_mac.h')
-rw-r--r-- | chrome/common/font_loader_mac.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/chrome/common/font_loader_mac.h b/chrome/common/font_loader_mac.h new file mode 100644 index 0000000..8d2467f --- /dev/null +++ b/chrome/common/font_loader_mac.h @@ -0,0 +1,49 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_FONT_LOADER_MAC_H_ +#define CHROME_COMMON_FONT_LOADER_MAC_H_ + +#include <ApplicationServices/ApplicationServices.h> + +#include "base/shared_memory.h" +#include "base/string16.h" + +// Provides functionality to transmit fonts over IPC. +// +// Note about font formats: .dfont (datafork suitcase) fonts are currently not +// supported by this code since ATSFontActivateFromMemory() can't handle them +// directly. + +class FontLoader { + public: + // Load a font specified by |font_name| and |font_point_size| into a shared + // memory buffer suitable for sending over IPC. + // + // On return: + // returns true on success, false on failure. + // |font_data| - shared memory buffer containing the raw data for the font + // file. + // |font_data_size| - size of data contained in |font_data|. + static bool LoadFontIntoBuffer(const string16& font_name, + float font_point_size, + base::SharedMemory* font_data, + uint32* font_data_size); + + // Given a shared memory buffer containing the raw data for a font file, load + // the font into a CGFontRef. + // + // |data| - A shared memory handle pointing to the raw data from a font file. + // |data_size| - Size of |data|. + // + // On return: + // returns true on success, false on failure. + // |font| - A CGFontRef containing the designated font, the caller is + // responsible for releasing this value. + static bool CreateCGFontFromBuffer(base::SharedMemoryHandle font_data, + uint32 font_data_size, + CGFontRef* font); +}; + +#endif // CHROME_COMMON_FONT_LOADER_MAC_H_ |