1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_COMMON_MAC_FONT_LOADER_H_
6 #define CONTENT_COMMON_MAC_FONT_LOADER_H_
8 #include <ApplicationServices/ApplicationServices.h>
10 #include "base/shared_memory.h"
11 #include "content/common/content_export.h"
19 struct FontDescriptor
;
21 // Provides functionality to transmit fonts over IPC.
23 // Note about font formats: .dfont (datafork suitcase) fonts are currently not
24 // supported by this code since CGFontCreateWithDataProvider() can't handle them
29 // This structure holds the result of LoadFont(). This structure is passed to
30 // LoadFont(), which should run on the file thread, then it is passed to a
31 // task which sends the result to the originating renderer.
33 uint32 font_data_size
;
34 base::SharedMemory font_data
;
37 // Load a font specified by |font| into a shared memory buffer suitable for
41 // |result->font_data| - shared memory buffer containing the raw data for
42 // the font file. The buffer is only valid when both |result->font_data_size|
43 // and |result->font_id| are not zero.
44 // |result->font_data_size| - size of data contained in |result->font_data|.
45 // This value is zero on failure.
46 // |result->font_id| - unique identifier for the on-disk file we load for
47 // the font. This value is zero on failure.
49 static void LoadFont(const FontDescriptor
& font
, FontLoader::Result
* result
);
51 // Given a shared memory buffer containing the raw data for a font file, load
52 // the font and return a CGFontRef.
54 // |data| - A shared memory handle pointing to the raw data from a font file.
55 // |data_size| - Size of |data|.
58 // returns true on success, false on failure.
59 // |out| - A CGFontRef corresponding to the designated font.
60 // The caller is responsible for releasing this value via CGFontRelease()
63 static bool CGFontRefFromBuffer(base::SharedMemoryHandle font_data
,
64 uint32 font_data_size
,
68 #endif // CONTENT_COMMON_MAC_FONT_LOADER_H_