| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_C_DEV_PPB_FONT_DEV_H_ | 5 #ifndef PPAPI_C_DEV_PPB_FONT_DEV_H_ |
| 6 #define PPAPI_C_DEV_PPB_FONT_DEV_H_ | 6 #define PPAPI_C_DEV_PPB_FONT_DEV_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_macros.h" |
| 9 #include "ppapi/c/pp_module.h" | 10 #include "ppapi/c/pp_module.h" |
| 10 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
| 11 #include "ppapi/c/pp_stdint.h" | 12 #include "ppapi/c/pp_stdint.h" |
| 12 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
| 13 | 14 |
| 14 #define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.2" | 15 #define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.3" |
| 15 | 16 |
| 16 struct PP_Point; | 17 struct PP_Point; |
| 17 struct PP_Rect; | 18 struct PP_Rect; |
| 18 | 19 |
| 19 typedef enum { | 20 typedef enum { |
| 20 // Uses the user's default web page font (normally either the default serif | 21 // Uses the user's default web page font (normally either the default serif |
| 21 // or sans serif font). | 22 // or sans serif font). |
| 22 PP_FONTFAMILY_DEFAULT = 0, | 23 PP_FONTFAMILY_DEFAULT = 0, |
| 23 | 24 |
| 24 // These families will use the default web page font corresponding to the | 25 // These families will use the default web page font corresponding to the |
| 25 // given family. | 26 // given family. |
| 26 PP_FONTFAMILY_SERIF = 1, | 27 PP_FONTFAMILY_SERIF = 1, |
| 27 PP_FONTFAMILY_SANSSERIF = 2, | 28 PP_FONTFAMILY_SANSSERIF = 2, |
| 28 PP_FONTFAMILY_MONOSPACE = 3 | 29 PP_FONTFAMILY_MONOSPACE = 3 |
| 29 } PP_FontFamily_Dev; | 30 } PP_FontFamily_Dev; |
| 31 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontFamily_Dev, 4); |
| 30 | 32 |
| 31 typedef enum { | 33 typedef enum { |
| 32 PP_FONTWEIGHT_100 = 0, | 34 PP_FONTWEIGHT_100 = 0, |
| 33 PP_FONTWEIGHT_200, | 35 PP_FONTWEIGHT_200, |
| 34 PP_FONTWEIGHT_300, | 36 PP_FONTWEIGHT_300, |
| 35 PP_FONTWEIGHT_400, | 37 PP_FONTWEIGHT_400, |
| 36 PP_FONTWEIGHT_500, | 38 PP_FONTWEIGHT_500, |
| 37 PP_FONTWEIGHT_600, | 39 PP_FONTWEIGHT_600, |
| 38 PP_FONTWEIGHT_700, | 40 PP_FONTWEIGHT_700, |
| 39 PP_FONTWEIGHT_800, | 41 PP_FONTWEIGHT_800, |
| 40 PP_FONTWEIGHT_900, | 42 PP_FONTWEIGHT_900, |
| 41 PP_FONTWEIGHT_NORMAL = PP_FONTWEIGHT_400, | 43 PP_FONTWEIGHT_NORMAL = PP_FONTWEIGHT_400, |
| 42 PP_FONTWEIGHT_BOLD = PP_FONTWEIGHT_700 | 44 PP_FONTWEIGHT_BOLD = PP_FONTWEIGHT_700 |
| 43 } PP_FontWeight_Dev; | 45 } PP_FontWeight_Dev; |
| 46 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontWeight_Dev, 4); |
| 44 | 47 |
| 45 struct PP_FontDescription_Dev { | 48 struct PP_FontDescription_Dev { |
| 46 // Font face name as a string. This can also be a Null var, in which case the | 49 // Font face name as a string. This can also be a Null var, in which case the |
| 47 // generic family will be obeyed. | 50 // generic family will be obeyed. |
| 48 struct PP_Var face; | 51 struct PP_Var face; |
| 49 | 52 |
| 50 // When face is a Null string, this specifies the generic font family type | 53 // When face is a Null string, this specifies the generic font family type |
| 51 // to use. If the face is specified, this will be ignored. | 54 // to use. If the face is specified, this will be ignored. |
| 52 PP_FontFamily_Dev family; | 55 PP_FontFamily_Dev family; |
| 53 | 56 |
| 54 uint32_t size; | 57 uint32_t size; |
| 55 | 58 |
| 56 // Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD. | 59 // Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD. |
| 57 PP_FontWeight_Dev weight; | 60 PP_FontWeight_Dev weight; |
| 58 | 61 |
| 59 PP_Bool italic; | 62 PP_Bool italic; |
| 60 PP_Bool small_caps; | 63 PP_Bool small_caps; |
| 61 | 64 |
| 62 // Adjustment to apply to letter and word spacing, respectively. Initialize | 65 // Adjustment to apply to letter and word spacing, respectively. Initialize |
| 63 // to 0 to get normal spacing. Negative values bring letters/words closer | 66 // to 0 to get normal spacing. Negative values bring letters/words closer |
| 64 // together, positive values separate them. | 67 // together, positive values separate them. |
| 65 int letter_spacing; | 68 int32_t letter_spacing; |
| 66 int word_spacing; | 69 int32_t word_spacing; |
| 70 |
| 71 // Ensure that this struct is 48-bytes wide by padding the end. In some |
| 72 // compilers, PP_Var is 8-byte aligned, so those compilers align this struct |
| 73 // on 8-byte boundaries as well and pad it to 16 bytes even without this |
| 74 // padding attribute. This padding makes its size consistent across |
| 75 // compilers. |
| 76 int32_t padding; |
| 67 }; | 77 }; |
| 78 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontDescription_Dev, 48); |
| 68 | 79 |
| 69 struct PP_FontMetrics_Dev { | 80 struct PP_FontMetrics_Dev { |
| 70 int32_t height; | 81 int32_t height; |
| 71 int32_t ascent; | 82 int32_t ascent; |
| 72 int32_t descent; | 83 int32_t descent; |
| 73 int32_t line_spacing; | 84 int32_t line_spacing; |
| 74 int32_t x_height; | 85 int32_t x_height; |
| 75 }; | 86 }; |
| 87 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontMetrics_Dev, 20); |
| 76 | 88 |
| 77 struct PP_TextRun_Dev { | 89 struct PP_TextRun_Dev { |
| 78 // This var must either be a string or a null var (which will be treated as | 90 // This var must either be a string or a null var (which will be treated as |
| 79 // a 0-length string). | 91 // a 0-length string). |
| 80 struct PP_Var text; | 92 struct PP_Var text; |
| 81 | 93 |
| 82 // Set to PP_TRUE if the text is right-to-left. | 94 // Set to PP_TRUE if the text is right-to-left. |
| 83 PP_Bool rtl; | 95 PP_Bool rtl; |
| 84 | 96 |
| 85 // Set to PP_TRUE to force the directionality of the text regardless of | 97 // Set to PP_TRUE to force the directionality of the text regardless of |
| 86 // content | 98 // content |
| 87 PP_Bool override_direction; | 99 PP_Bool override_direction; |
| 88 }; | 100 }; |
| 101 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TextRun_Dev, 24); |
| 89 | 102 |
| 90 struct PPB_Font_Dev { | 103 struct PPB_Font_Dev { |
| 91 // Returns a font which best matches the given description. The return value | 104 // Returns a font which best matches the given description. The return value |
| 92 // will have a non-zero ID on success, or zero on failure. | 105 // will have a non-zero ID on success, or zero on failure. |
| 93 PP_Resource (*Create)(PP_Module module, | 106 PP_Resource (*Create)(PP_Module module, |
| 94 const struct PP_FontDescription_Dev* description); | 107 const struct PP_FontDescription_Dev* description); |
| 95 | 108 |
| 96 // Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the | 109 // Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the |
| 97 // resource is invalid or some type other than a Font. | 110 // resource is invalid or some type other than a Font. |
| 98 PP_Bool (*IsFont)(PP_Resource resource); | 111 PP_Bool (*IsFont)(PP_Resource resource); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 167 |
| 155 // Returns the horizontal advance to the given character if the string was | 168 // Returns the horizontal advance to the given character if the string was |
| 156 // placed at the given position. This handles complex scripts such as Arabic, | 169 // placed at the given position. This handles complex scripts such as Arabic, |
| 157 // where characters may be combined or replaced depending on context. | 170 // where characters may be combined or replaced depending on context. |
| 158 int32_t (*PixelOffsetForCharacter)(PP_Resource font, | 171 int32_t (*PixelOffsetForCharacter)(PP_Resource font, |
| 159 const struct PP_TextRun_Dev* text, | 172 const struct PP_TextRun_Dev* text, |
| 160 uint32_t char_offset); | 173 uint32_t char_offset); |
| 161 }; | 174 }; |
| 162 | 175 |
| 163 #endif // PPAPI_C_DEV_PPB_FONT_DEV_H_ | 176 #endif // PPAPI_C_DEV_PPB_FONT_DEV_H_ |
| OLD | NEW |