Pepper_31_C_interfaces
ppb_truetype_font_dev.h
Go to the documentation of this file.
1 /* Copyright (c) 2013 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 
6 /* From dev/ppb_truetype_font_dev.idl modified Wed Apr 17 15:38:46 2013. */
7 
8 #ifndef PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_
9 #define PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_
10 
11 #include "ppapi/c/pp_array_output.h"
12 #include "ppapi/c/pp_bool.h"
13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_macros.h"
16 #include "ppapi/c/pp_resource.h"
17 #include "ppapi/c/pp_stdint.h"
18 #include "ppapi/c/pp_var.h"
19 
20 #define PPB_TRUETYPEFONT_DEV_INTERFACE_0_1 "PPB_TrueTypeFont(Dev);0.1"
21 #define PPB_TRUETYPEFONT_DEV_INTERFACE PPB_TRUETYPEFONT_DEV_INTERFACE_0_1
22 
23 /**
24  * @file
25  * This file defines the <code>PPB_TrueTypeFont_Dev</code> interface. This
26  * interface exposes font table data for 'sfnt' fonts on the host system. These
27  * include TrueType and OpenType fonts.
28  */
29 
30 
31 /**
32  * @addtogroup Enums
33  * @{
34  */
35 /**
36  * The PP_TrueTypeFontFamily_Dev defines generic font families. These can be
37  * used to create generic fonts consistent with the user's browser settings.
38  */
39 typedef enum {
40  /**
41  * For a description of these default families, see the
42  * <a href="http://www.w3.org/TR/css3-fonts/#generic-font-families">
43  * 3.1.1 Generic font families</a> documentation.
44  */
52 
53 /**
54  * The PP_TrueTypeFontStyle_Dev enum defines font styles.
55  */
56 typedef enum {
61 
62 /**
63  * The PP_TrueTypeFontWeight_Dev enum defines font weights.
64  */
65 typedef enum {
77 
78 /**
79  * The PP_TrueTypeFontWidth_Dev enum defines font widths.
80  */
81 typedef enum {
93 
94 /**
95  * The PP_TrueTypeFontCharset enum defines font character sets.
96  */
97 typedef enum {
119 /**
120  * @}
121  */
122 
123 /**
124  * @addtogroup Structs
125  * @{
126  */
127 /**
128  * The <code>PP_TrueTypeFontDesc</code> struct describes a TrueType font. It is
129  * passed to Create(), and returned by Describe().
130  */
132  /**
133  * Font family name as a string. This can also be an undefined var, in which
134  * case the generic family will be obeyed. If the face is not available on
135  * the system, the browser will attempt to do font fallback or pick a default
136  * font.
137  */
138  struct PP_Var family;
139  /** This value specifies a generic font family. If a family name string is
140  * provided when creating a font, this is ignored. */
142  /** This value specifies the font style. */
144  /** This value specifies the font weight. */
146  /** This value specifies the font width, for condensed or expanded fonts */
148  /** This value specifies a character set. */
150  /**
151  * Ensure that this struct is 40-bytes wide by padding the end. In some
152  * compilers, PP_Var is 8-byte aligned, so those compilers align this struct
153  * on 8-byte boundaries as well and pad it to 16 bytes even without this
154  * padding attribute. This padding makes its size consistent across
155  * compilers.
156  */
157  int32_t padding;
158 };
160 /**
161  * @}
162  */
163 
164 /**
165  * @addtogroup Interfaces
166  * @{
167  */
169  /**
170  * Gets an array of TrueType font family names available on the host.
171  * These names can be used to create a font from a specific family.
172  *
173  * @param[in] instance A <code>PP_Instance</code> requesting the family names.
174  * @param[in] output A <code>PP_ArrayOutput</code> to hold the names.
175  * The output is an array of PP_Vars, each holding a family name.
176  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
177  * completion of GetFontFamilies.
178  *
179  * @return If >= 0, the number of family names returned, otherwise an error
180  * code from <code>pp_errors.h</code>.
181  */
182  int32_t (*GetFontFamilies)(PP_Instance instance,
183  struct PP_ArrayOutput output,
184  struct PP_CompletionCallback callback);
185  /**
186  * Gets an array of TrueType font descriptors for a given font family. These
187  * descriptors can be used to create a font in that family and matching the
188  * descriptor attributes.
189  *
190  * @param[in] instance A <code>PP_Instance</code> requesting the font
191  * descriptors.
192  * @param[in] family A <code>PP_Var</code> holding a string specifying the
193  * font family.
194  * @param[in] output A <code>PP_ArrayOutput</code> to hold the descriptors.
195  * The output is an array of <code>PP_TrueTypeFontDesc</code> structs. Each
196  * desc contains a PP_Var for the family name which must be released.
197  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
198  * completion of GetFontsInFamily.
199  *
200  * @return If >= 0, the number of font descriptors returned, otherwise an
201  * error code from <code>pp_errors.h</code>.
202  */
203  int32_t (*GetFontsInFamily)(PP_Instance instance,
204  struct PP_Var family,
205  struct PP_ArrayOutput output,
206  struct PP_CompletionCallback callback);
207  /**
208  * Creates a font resource matching the given font characteristics. The
209  * resource id will be non-zero on success, or zero on failure.
210  *
211  * @param[in] instance A <code>PP_Instance</code> to own the font.
212  * @param[in] desc A pointer to a <code>PP_TrueTypeFontDesc</code> describing
213  * the font.
214  */
216  const struct PP_TrueTypeFontDesc_Dev* desc);
217  /**
218  * Determines if the given resource is a TrueType font.
219  *
220  * @param[in] resource A <code>PP_Resource</code> corresponding to a resource.
221  *
222  * @return <code>PP_TRUE</code> if the resource is a
223  * <code>PPB_TrueTypeFont_Dev</code>, <code>PP_FALSE</code> otherwise.
224  */
226  /**
227  * Returns a description of the given font resource. This description may
228  * differ from the description passed to Create, reflecting the host's font
229  * matching and fallback algorithm.
230  *
231  * @param[in] font A <code>PP_Resource</code> corresponding to a font.
232  * @param[out] desc A pointer to a <code>PP_TrueTypeFontDesc</code> to hold
233  * the description. The internal 'family' PP_Var should be set to undefined,
234  * since this function overwrites the <code>PP_TrueTypeFontDesc</code>. After
235  * successful completion, the family will be set to a PP_Var with a single
236  * reference, which the caller must release after use.
237  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
238  * completion of Describe.
239  *
240  * @return A return code from <code>pp_errors.h</code>. If an error code is
241  * returned, the <code>PP_TrueTypeFontDesc</code> will be unchanged.
242  */
243  int32_t (*Describe)(PP_Resource font,
244  struct PP_TrueTypeFontDesc_Dev* desc,
245  struct PP_CompletionCallback callback);
246  /**
247  * Gets an array of identifying tags for each table in the font. These tags
248  * can be used to request specific tables using GetTable.
249  *
250  * @param[in] font A <code>PP_Resource</code> corresponding to a font.
251  * @param[in] output A <code>PP_ArrayOutput</code> to hold the tags.
252  * The output is an array of 4 byte integers, each representing a table tag.
253  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
254  * completion of GetTableTags.
255  *
256  * @return If >= 0, the number of table tags returned, otherwise an error
257  * code from <code>pp_errors.h</code>.
258  */
259  int32_t (*GetTableTags)(PP_Resource font,
260  struct PP_ArrayOutput output,
261  struct PP_CompletionCallback callback);
262  /**
263  * Copies the given font table into client memory.
264  *
265  * @param[in] font A <code>PP_Resource</code> corresponding to a font.
266  * @param[in] table A 4 byte value indicating which table to copy.
267  * For example, 'glyf' will cause the outline table to be copied into the
268  * output array. A zero tag value will cause the entire font to be copied.
269  * @param[in] offset The offset into the font table.
270  * @param[in] max_data_length The maximum number of bytes to transfer from
271  * <code>offset</code>.
272  * @param[in] output A <code>PP_ArrayOutput</code> to hold the font data.
273  * The output is an array of bytes.
274  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
275  * completion of GetTable.
276  *
277  * @return If >= 0, the table size in bytes, otherwise an error code from
278  * <code>pp_errors.h</code>.
279  */
280  int32_t (*GetTable)(PP_Resource font,
281  uint32_t table,
282  int32_t offset,
283  int32_t max_data_length,
284  struct PP_ArrayOutput output,
285  struct PP_CompletionCallback callback);
286 };
287 
289 /**
290  * @}
291  */
292 
293 #endif /* PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ */
294 
int32_t(* Describe)(PP_Resource font, struct PP_TrueTypeFontDesc_Dev *desc, struct PP_CompletionCallback callback)
PP_TrueTypeFontFamily_Dev generic_family
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontFamily_Dev, 4)
PP_Resource(* Create)(PP_Instance instance, const struct PP_TrueTypeFontDesc_Dev *desc)
PP_TrueTypeFontStyle_Dev style
int32_t(* GetFontFamilies)(PP_Instance instance, struct PP_ArrayOutput output, struct PP_CompletionCallback callback)
int32_t(* GetTableTags)(PP_Resource font, struct PP_ArrayOutput output, struct PP_CompletionCallback callback)
int32_t(* GetFontsInFamily)(PP_Instance instance, struct PP_Var family, struct PP_ArrayOutput output, struct PP_CompletionCallback callback)
PP_TrueTypeFontFamily_Dev
int32_t PP_Resource
Definition: pp_resource.h:40
PP_TrueTypeFontWeight_Dev
PP_Bool(* IsTrueTypeFont)(PP_Resource resource)
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TrueTypeFontDesc_Dev, 40)
PP_TrueTypeFontWeight_Dev weight
PP_TrueTypeFontCharset_Dev
Definition: pp_var.h:155
PP_TrueTypeFontWidth_Dev width
int32_t PP_Instance
Definition: pp_instance.h:34
int32_t(* GetTable)(PP_Resource font, uint32_t table, int32_t offset, int32_t max_data_length, struct PP_ArrayOutput output, struct PP_CompletionCallback callback)
PP_Bool
Definition: pp_bool.h:30
PP_TrueTypeFontStyle_Dev
PP_TrueTypeFontWidth_Dev
PP_TrueTypeFontCharset_Dev charset