Home | History | Annotate | Download | only in dev
      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 Tue Oct 15 05:52:52 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    */
     45   PP_TRUETYPEFONTFAMILY_SERIF = 0,
     46   PP_TRUETYPEFONTFAMILY_SANSSERIF = 1,
     47   PP_TRUETYPEFONTFAMILY_CURSIVE = 2,
     48   PP_TRUETYPEFONTFAMILY_FANTASY = 3,
     49   PP_TRUETYPEFONTFAMILY_MONOSPACE = 4
     50 } PP_TrueTypeFontFamily_Dev;
     51 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontFamily_Dev, 4);
     52 
     53 /**
     54  * The PP_TrueTypeFontStyle_Dev enum defines font styles.
     55  */
     56 typedef enum {
     57   PP_TRUETYPEFONTSTYLE_NORMAL = 0,
     58   PP_TRUETYPEFONTSTYLE_ITALIC = 1
     59 } PP_TrueTypeFontStyle_Dev;
     60 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontStyle_Dev, 4);
     61 
     62 /**
     63  * The PP_TrueTypeFontWeight_Dev enum defines font weights.
     64  */
     65 typedef enum {
     66   PP_TRUETYPEFONTWEIGHT_THIN = 100,
     67   PP_TRUETYPEFONTWEIGHT_ULTRALIGHT = 200,
     68   PP_TRUETYPEFONTWEIGHT_LIGHT = 300,
     69   PP_TRUETYPEFONTWEIGHT_NORMAL = 400,
     70   PP_TRUETYPEFONTWEIGHT_MEDIUM = 500,
     71   PP_TRUETYPEFONTWEIGHT_SEMIBOLD = 600,
     72   PP_TRUETYPEFONTWEIGHT_BOLD = 700,
     73   PP_TRUETYPEFONTWEIGHT_ULTRABOLD = 800,
     74   PP_TRUETYPEFONTWEIGHT_HEAVY = 900
     75 } PP_TrueTypeFontWeight_Dev;
     76 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontWeight_Dev, 4);
     77 
     78 /**
     79  * The PP_TrueTypeFontWidth_Dev enum defines font widths.
     80  */
     81 typedef enum {
     82   PP_TRUETYPEFONTWIDTH_ULTRACONDENSED = 0,
     83   PP_TRUETYPEFONTWIDTH_EXTRACONDENSED = 1,
     84   PP_TRUETYPEFONTWIDTH_CONDENSED = 2,
     85   PP_TRUETYPEFONTWIDTH_SEMICONDENSED = 3,
     86   PP_TRUETYPEFONTWIDTH_NORMAL = 4,
     87   PP_TRUETYPEFONTWIDTH_SEMIEXPANDED = 5,
     88   PP_TRUETYPEFONTWIDTH_EXPANDED = 6,
     89   PP_TRUETYPEFONTWIDTH_EXTRAEXPANDED = 7,
     90   PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED = 8
     91 } PP_TrueTypeFontWidth_Dev;
     92 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontWidth_Dev, 4);
     93 
     94 /**
     95  * The PP_TrueTypeFontCharset enum defines font character sets.
     96  */
     97 typedef enum {
     98   PP_TRUETYPEFONTCHARSET_ANSI = 0,
     99   PP_TRUETYPEFONTCHARSET_DEFAULT = 1,
    100   PP_TRUETYPEFONTCHARSET_SYMBOL = 2,
    101   PP_TRUETYPEFONTCHARSET_MAC = 77,
    102   PP_TRUETYPEFONTCHARSET_SHIFTJIS = 128,
    103   PP_TRUETYPEFONTCHARSET_HANGUL = 129,
    104   PP_TRUETYPEFONTCHARSET_JOHAB = 130,
    105   PP_TRUETYPEFONTCHARSET_GB2312 = 134,
    106   PP_TRUETYPEFONTCHARSET_CHINESEBIG5 = 136,
    107   PP_TRUETYPEFONTCHARSET_GREEK = 161,
    108   PP_TRUETYPEFONTCHARSET_TURKISH = 162,
    109   PP_TRUETYPEFONTCHARSET_VIETNAMESE = 163,
    110   PP_TRUETYPEFONTCHARSET_HEBREW = 177,
    111   PP_TRUETYPEFONTCHARSET_ARABIC = 178,
    112   PP_TRUETYPEFONTCHARSET_BALTIC = 186,
    113   PP_TRUETYPEFONTCHARSET_RUSSIAN = 204,
    114   PP_TRUETYPEFONTCHARSET_THAI = 222,
    115   PP_TRUETYPEFONTCHARSET_EASTEUROPE = 238,
    116   PP_TRUETYPEFONTCHARSET_OEM = 255
    117 } PP_TrueTypeFontCharset_Dev;
    118 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TrueTypeFontCharset_Dev, 4);
    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  */
    131 struct PP_TrueTypeFontDesc_Dev {
    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. */
    141   PP_TrueTypeFontFamily_Dev generic_family;
    142   /** This value specifies the font style. */
    143   PP_TrueTypeFontStyle_Dev style;
    144   /** This value specifies the font weight. */
    145   PP_TrueTypeFontWeight_Dev weight;
    146   /** This value specifies the font width, for condensed or expanded fonts */
    147   PP_TrueTypeFontWidth_Dev width;
    148   /** This value specifies a character set. */
    149   PP_TrueTypeFontCharset_Dev charset;
    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 };
    159 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TrueTypeFontDesc_Dev, 40);
    160 /**
    161  * @}
    162  */
    163 
    164 /**
    165  * @addtogroup Interfaces
    166  * @{
    167  */
    168 struct PPB_TrueTypeFont_Dev_0_1 {
    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    */
    215   PP_Resource (*Create)(PP_Instance instance,
    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    */
    225   PP_Bool (*IsTrueTypeFont)(PP_Resource resource);
    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. Passing an offset
    270    * greater than or equal to the table size will succeed with 0 bytes copied.
    271    * @param[in] max_data_length The maximum number of bytes to transfer from
    272    * <code>offset</code>.
    273    * @param[in] output A <code>PP_ArrayOutput</code> to hold the font data.
    274    * The output is an array of bytes.
    275    * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
    276    * completion of GetTable.
    277    *
    278    * @return If >= 0, the table size in bytes, otherwise an error code from
    279    * <code>pp_errors.h</code>.
    280    */
    281   int32_t (*GetTable)(PP_Resource font,
    282                       uint32_t table,
    283                       int32_t offset,
    284                       int32_t max_data_length,
    285                       struct PP_ArrayOutput output,
    286                       struct PP_CompletionCallback callback);
    287 };
    288 
    289 typedef struct PPB_TrueTypeFont_Dev_0_1 PPB_TrueTypeFont_Dev;
    290 /**
    291  * @}
    292  */
    293 
    294 #endif  /* PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ */
    295 
    296