Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: ppapi/c/dev/ppb_font_dev.h

Issue 1416303007: Partial revert of r357449 to keep Flash 19.x working. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: with idl file Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ppapi/api/dev/ppb_font_dev.idl ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 5
6 /* From trusted/ppb_browser_font_trusted.idl, 6 /* From dev/ppb_font_dev.idl modified Thu Mar 28 10:56:39 2013. */
7 * modified Thu Mar 28 10:14:27 2013.
8 */
9 7
10 #ifndef PPAPI_C_TRUSTED_PPB_BROWSER_FONT_TRUSTED_H_ 8 #ifndef PPAPI_C_DEV_PPB_FONT_DEV_H_
11 #define PPAPI_C_TRUSTED_PPB_BROWSER_FONT_TRUSTED_H_ 9 #define PPAPI_C_DEV_PPB_FONT_DEV_H_
12 10
13 #include "ppapi/c/pp_bool.h" 11 #include "ppapi/c/pp_bool.h"
14 #include "ppapi/c/pp_instance.h" 12 #include "ppapi/c/pp_instance.h"
15 #include "ppapi/c/pp_macros.h" 13 #include "ppapi/c/pp_macros.h"
16 #include "ppapi/c/pp_point.h" 14 #include "ppapi/c/pp_point.h"
17 #include "ppapi/c/pp_rect.h" 15 #include "ppapi/c/pp_rect.h"
18 #include "ppapi/c/pp_resource.h" 16 #include "ppapi/c/pp_resource.h"
19 #include "ppapi/c/pp_size.h" 17 #include "ppapi/c/pp_size.h"
20 #include "ppapi/c/pp_stdint.h" 18 #include "ppapi/c/pp_stdint.h"
21 #include "ppapi/c/pp_var.h" 19 #include "ppapi/c/pp_var.h"
22 20
23 #define PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0 "PPB_BrowserFont_Trusted;1.0" 21 #define PPB_FONT_DEV_INTERFACE_0_6 "PPB_Font(Dev);0.6"
24 #define PPB_BROWSERFONT_TRUSTED_INTERFACE PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0 22 #define PPB_FONT_DEV_INTERFACE PPB_FONT_DEV_INTERFACE_0_6
25 23
26 /** 24 /**
27 * @file 25 * @file
28 * This file defines the <code>PPB_BrowserFont_Trusted</code> interface. 26 * This file defines the <code>PPB_Font_Dev</code> interface.
29 */ 27 */
30 28
31 29
32 /** 30 /**
33 * @addtogroup Enums 31 * @addtogroup Enums
34 * @{ 32 * @{
35 */ 33 */
36 typedef enum { 34 typedef enum {
37 /** 35 /**
38 * Uses the user's default web page font (normally either the default serif 36 * Uses the user's default web page font (normally either the default serif
39 * or sans serif font). 37 * or sans serif font).
40 */ 38 */
41 PP_BROWSERFONT_TRUSTED_FAMILY_DEFAULT = 0, 39 PP_FONTFAMILY_DEFAULT = 0,
42 /** 40 /**
43 * These families will use the default web page font corresponding to the 41 * These families will use the default web page font corresponding to the
44 * given family. 42 * given family.
45 */ 43 */
46 PP_BROWSERFONT_TRUSTED_FAMILY_SERIF = 1, 44 PP_FONTFAMILY_SERIF = 1,
47 PP_BROWSERFONT_TRUSTED_FAMILY_SANSSERIF = 2, 45 PP_FONTFAMILY_SANSSERIF = 2,
48 PP_BROWSERFONT_TRUSTED_FAMILY_MONOSPACE = 3 46 PP_FONTFAMILY_MONOSPACE = 3
49 } PP_BrowserFont_Trusted_Family; 47 } PP_FontFamily_Dev;
50 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_Family, 4); 48 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontFamily_Dev, 4);
51 49
52 /** 50 /**
53 * Specifies the font weight. Normally users will only use NORMAL or BOLD. 51 * Specifies the font weight. Normally users will only use NORMAL or BOLD.
54 */ 52 */
55 typedef enum { 53 typedef enum {
56 PP_BROWSERFONT_TRUSTED_WEIGHT_100 = 0, 54 PP_FONTWEIGHT_100 = 0,
57 PP_BROWSERFONT_TRUSTED_WEIGHT_200 = 1, 55 PP_FONTWEIGHT_200 = 1,
58 PP_BROWSERFONT_TRUSTED_WEIGHT_300 = 2, 56 PP_FONTWEIGHT_300 = 2,
59 PP_BROWSERFONT_TRUSTED_WEIGHT_400 = 3, 57 PP_FONTWEIGHT_400 = 3,
60 PP_BROWSERFONT_TRUSTED_WEIGHT_500 = 4, 58 PP_FONTWEIGHT_500 = 4,
61 PP_BROWSERFONT_TRUSTED_WEIGHT_600 = 5, 59 PP_FONTWEIGHT_600 = 5,
62 PP_BROWSERFONT_TRUSTED_WEIGHT_700 = 6, 60 PP_FONTWEIGHT_700 = 6,
63 PP_BROWSERFONT_TRUSTED_WEIGHT_800 = 7, 61 PP_FONTWEIGHT_800 = 7,
64 PP_BROWSERFONT_TRUSTED_WEIGHT_900 = 8, 62 PP_FONTWEIGHT_900 = 8,
65 PP_BROWSERFONT_TRUSTED_WEIGHT_NORMAL = PP_BROWSERFONT_TRUSTED_WEIGHT_400, 63 PP_FONTWEIGHT_NORMAL = PP_FONTWEIGHT_400,
66 PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD = PP_BROWSERFONT_TRUSTED_WEIGHT_700 64 PP_FONTWEIGHT_BOLD = PP_FONTWEIGHT_700
67 } PP_BrowserFont_Trusted_Weight; 65 } PP_FontWeight_Dev;
68 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_Weight, 4); 66 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontWeight_Dev, 4);
69 /** 67 /**
70 * @} 68 * @}
71 */ 69 */
72 70
73 /** 71 /**
74 * @addtogroup Structs 72 * @addtogroup Structs
75 * @{ 73 * @{
76 */ 74 */
77 struct PP_BrowserFont_Trusted_Description { 75 struct PP_FontDescription_Dev {
78 /** 76 /**
79 * Font face name as a string. This can also be an undefined var, in which 77 * Font face name as a string. This can also be an undefined var, in which
80 * case the generic family will be obeyed. If the face is not available on 78 * case the generic family will be obeyed. If the face is not available on
81 * the system, the browser will attempt to do font fallback or pick a default 79 * the system, the browser will attempt to do font fallback or pick a default
82 * font. 80 * font.
83 */ 81 */
84 struct PP_Var face; 82 struct PP_Var face;
85 /** 83 /**
86 * When Create()ing a font and the face is an undefined var, the family 84 * When Create()ing a font and the face is an undefined var, the family
87 * specifies the generic font family type to use. If the face is specified, 85 * specifies the generic font family type to use. If the face is specified,
88 * this will be ignored. 86 * this will be ignored.
89 * 87 *
90 * When Describe()ing a font, the family will be the value you passed in when 88 * When Describe()ing a font, the family will be the value you passed in when
91 * the font was created. In other words, if you specify a face name, the 89 * the font was created. In other words, if you specify a face name, the
92 * family will not be updated to reflect whether the font name you requested 90 * family will not be updated to reflect whether the font name you requested
93 * is serif or sans serif. 91 * is serif or sans serif.
94 */ 92 */
95 PP_BrowserFont_Trusted_Family family; 93 PP_FontFamily_Dev family;
96 /** 94 /**
97 * Size in pixels. 95 * Size in pixels.
98 * 96 *
99 * You can specify 0 to get the default font size. The default font size 97 * You can specify 0 to get the default font size. The default font size
100 * may vary depending on the requested font. The typical example is that 98 * may vary depending on the requested font. The typical example is that
101 * the user may have a different font size for the default monospace font to 99 * the user may have a different font size for the default monospace font to
102 * give it a similar optical size to the proportionally spaced fonts. 100 * give it a similar optical size to the proportionally spaced fonts.
103 */ 101 */
104 uint32_t size; 102 uint32_t size;
105 /** 103 /**
106 * Normally you will use either normal or bold. 104 * Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD.
107 */ 105 */
108 PP_BrowserFont_Trusted_Weight weight; 106 PP_FontWeight_Dev weight;
109 PP_Bool italic; 107 PP_Bool italic;
110 PP_Bool small_caps; 108 PP_Bool small_caps;
111 /** 109 /**
112 * Adjustment to apply to letter and word spacing, respectively. Initialize 110 * Adjustment to apply to letter and word spacing, respectively. Initialize
113 * to 0 to get normal spacing. Negative values bring letters/words closer 111 * to 0 to get normal spacing. Negative values bring letters/words closer
114 * together, positive values separate them. 112 * together, positive values separate them.
115 */ 113 */
116 int32_t letter_spacing; 114 int32_t letter_spacing;
117 int32_t word_spacing; 115 int32_t word_spacing;
118 /** 116 /**
119 * Ensure that this struct is 48-bytes wide by padding the end. In some 117 * Ensure that this struct is 48-bytes wide by padding the end. In some
120 * compilers, PP_Var is 8-byte aligned, so those compilers align this struct 118 * compilers, PP_Var is 8-byte aligned, so those compilers align this struct
121 * on 8-byte boundaries as well and pad it to 16 bytes even without this 119 * on 8-byte boundaries as well and pad it to 16 bytes even without this
122 * padding attribute. This padding makes its size consistent across 120 * padding attribute. This padding makes its size consistent across
123 * compilers. 121 * compilers.
124 */ 122 */
125 int32_t padding; 123 int32_t padding;
126 }; 124 };
127 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_Description, 48); 125 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontDescription_Dev, 48);
128 126
129 struct PP_BrowserFont_Trusted_Metrics { 127 struct PP_FontMetrics_Dev {
130 int32_t height; 128 int32_t height;
131 int32_t ascent; 129 int32_t ascent;
132 int32_t descent; 130 int32_t descent;
133 int32_t line_spacing; 131 int32_t line_spacing;
134 int32_t x_height; 132 int32_t x_height;
135 }; 133 };
136 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_Metrics, 20); 134 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontMetrics_Dev, 20);
137 135
138 struct PP_BrowserFont_Trusted_TextRun { 136 struct PP_TextRun_Dev {
139 /** 137 /**
140 * This var must either be a string or a null/undefined var (which will be 138 * This var must either be a string or a null/undefined var (which will be
141 * treated as a 0-length string). 139 * treated as a 0-length string).
142 */ 140 */
143 struct PP_Var text; 141 struct PP_Var text;
144 /** 142 /**
145 * Set to PP_TRUE if the text is right-to-left. 143 * Set to PP_TRUE if the text is right-to-left.
144 *
145 * When <code>override_direction</code> is false, the browser will perform
146 * the Unicode Bidirectional Algorithm (http://unicode.org/reports/tr9/) on
147 * the text. The value of the <code>rtl</code> flag specifies the
148 * directionality of the surrounding environment. This means that Hebrew
149 * word will always display right to left, even if <code>rtl</code> is false.
150 *
151 * When <code>override_direction</code> is true, no autodetection will be done
152 * and <code>rtl</code> specifies the direction of the text.
153 *
154 * TODO(brettw) note that autodetection with rtl = true is currently
155 * unimplemented.
146 */ 156 */
147 PP_Bool rtl; 157 PP_Bool rtl;
148 /** 158 /**
149 * Set to PP_TRUE to force the directionality of the text regardless of 159 * Set to PP_TRUE to force the directionality of the text regardless of
150 * content 160 * content.
161 *
162 * If this flag is set, the browser will skip autodetection of the content
163 * and will display all text in the direction specified by the
164 * <code>rtl</code> flag.
151 */ 165 */
152 PP_Bool override_direction; 166 PP_Bool override_direction;
153 }; 167 };
154 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_BrowserFont_Trusted_TextRun, 24); 168 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TextRun_Dev, 24);
155 /** 169 /**
156 * @} 170 * @}
157 */ 171 */
158 172
159 /** 173 /**
160 * @addtogroup Interfaces 174 * @addtogroup Interfaces
161 * @{ 175 * @{
162 */ 176 */
163 /** 177 struct PPB_Font_Dev_0_6 {
164 * Provides an interface for native browser text rendering.
165 *
166 * This API is "trusted" not for security reasons, but because it can not be
167 * implemented efficiently when running out-of-process in Browser Client. In
168 * this case, WebKit is in another process and every text call would require a
169 * synchronous IPC to the renderer. It is, however, available to native
170 * (non-NaCl) out-of-process PPAPI plugins since WebKit is available in the
171 * plugin process.
172 */
173 struct PPB_BrowserFont_Trusted_1_0 {
174 /** 178 /**
175 * Returns a list of all available font families on the system. You can use 179 * Returns a list of all available font families on the system. You can use
176 * this list to decide whether to Create() a font. 180 * this list to decide whether to Create() a font.
177 * 181 *
178 * The return value will be a single string with null characters delimiting 182 * The return value will be a single string with null characters delimiting
179 * the end of each font name. For example: "Arial\0Courier\0Times\0". 183 * the end of each font name. For example: "Arial\0Courier\0Times\0".
180 * 184 *
181 * Returns an undefined var on failure (this typically means you passed an 185 * Returns an undefined var on failure (this typically means you passed an
182 * invalid instance). 186 * invalid instance).
183 */ 187 */
184 struct PP_Var (*GetFontFamilies)(PP_Instance instance); 188 struct PP_Var (*GetFontFamilies)(PP_Instance instance);
185 /** 189 /**
186 * Returns a font which best matches the given description. The return value 190 * Returns a font which best matches the given description. The return value
187 * will have a non-zero ID on success, or zero on failure. 191 * will have a non-zero ID on success, or zero on failure.
188 */ 192 */
189 PP_Resource (*Create)( 193 PP_Resource (*Create)(PP_Instance instance,
190 PP_Instance instance, 194 const struct PP_FontDescription_Dev* description);
191 const struct PP_BrowserFont_Trusted_Description* description);
192 /** 195 /**
193 * Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the 196 * Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the
194 * resource is invalid or some type other than a Font. 197 * resource is invalid or some type other than a Font.
195 */ 198 */
196 PP_Bool (*IsFont)(PP_Resource resource); 199 PP_Bool (*IsFont)(PP_Resource resource);
197 /** 200 /**
198 * Loads the description and metrics of the font into the given structures. 201 * Loads the description and metrics of the font into the given structures.
199 * The description will be different than the description the font was 202 * The description will be different than the description the font was
200 * created with since it will be filled with the real values from the font 203 * created with since it will be filled with the real values from the font
201 * that was actually selected. 204 * that was actually selected.
202 * 205 *
203 * The PP_Var in the description should be of type Void on input. On output, 206 * The PP_Var in the description should be of type Void on input. On output,
204 * this will contain the string and will have a reference count of 1. The 207 * this will contain the string and will have a reference count of 1. The
205 * plugin is responsible for calling Release on this var. 208 * plugin is responsible for calling Release on this var.
206 * 209 *
207 * Returns PP_TRUE on success, PP_FALSE if the font is invalid or if the Var 210 * Returns PP_TRUE on success, PP_FALSE if the font is invalid or if the Var
208 * in the description isn't Null (to prevent leaks). 211 * in the description isn't Null (to prevent leaks).
209 */ 212 */
210 PP_Bool (*Describe)(PP_Resource font, 213 PP_Bool (*Describe)(PP_Resource font,
211 struct PP_BrowserFont_Trusted_Description* description, 214 struct PP_FontDescription_Dev* description,
212 struct PP_BrowserFont_Trusted_Metrics* metrics); 215 struct PP_FontMetrics_Dev* metrics);
213 /** 216 /**
214 * Draws the text to the image buffer. 217 * Draws the text to the image buffer.
215 * 218 *
216 * The given point represents the baseline of the left edge of the font, 219 * The given point represents the baseline of the left edge of the font,
217 * regardless of whether it is left-to-right or right-to-left (in the case of 220 * regardless of whether it is left-to-right or right-to-left (in the case of
218 * RTL text, this will actually represent the logical end of the text). 221 * RTL text, this will actually represent the logical end of the text).
219 * 222 *
220 * The clip is optional and may be NULL. In this case, the text will be 223 * The clip is optional and may be NULL. In this case, the text will be
221 * clipped to the image. 224 * clipped to the image.
222 * 225 *
223 * The image_data_is_opaque flag indicates whether subpixel antialiasing can 226 * The image_data_is_opaque flag indicates whether subpixel antialiasing can
224 * be performed, if it is supported. When the image below the text is 227 * be performed, if it is supported. When the image below the text is
225 * opaque, subpixel antialiasing is supported and you should set this to 228 * opaque, subpixel antialiasing is supported and you should set this to
226 * PP_TRUE to pick up the user's default preferences. If your plugin is 229 * PP_TRUE to pick up the user's default preferences. If your plugin is
227 * partially transparent, then subpixel antialiasing is not possible and 230 * partially transparent, then subpixel antialiasing is not possible and
228 * grayscale antialiasing will be used instead (assuming the user has 231 * grayscale antialiasing will be used instead (assuming the user has
229 * antialiasing enabled at all). 232 * antialiasing enabled at all).
230 */ 233 */
231 PP_Bool (*DrawTextAt)(PP_Resource font, 234 PP_Bool (*DrawTextAt)(PP_Resource font,
232 PP_Resource image_data, 235 PP_Resource image_data,
233 const struct PP_BrowserFont_Trusted_TextRun* text, 236 const struct PP_TextRun_Dev* text,
234 const struct PP_Point* position, 237 const struct PP_Point* position,
235 uint32_t color, 238 uint32_t color,
236 const struct PP_Rect* clip, 239 const struct PP_Rect* clip,
237 PP_Bool image_data_is_opaque); 240 PP_Bool image_data_is_opaque);
238 /** 241 /**
239 * Returns the width of the given string. If the font is invalid or the var 242 * Returns the width of the given string. If the font is invalid or the var
240 * isn't a valid string, this will return -1. 243 * isn't a valid string, this will return -1.
241 * 244 *
242 * Note that this function handles complex scripts such as Arabic, combining 245 * Note that this function handles complex scripts such as Arabic, combining
243 * accents, etc. so that adding the width of substrings won't necessarily 246 * accents, etc. so that adding the width of substrings won't necessarily
244 * produce the correct width of the entire string. 247 * produce the correct width of the entire string.
245 * 248 *
246 * Returns -1 on failure. 249 * Returns -1 on failure.
247 */ 250 */
248 int32_t (*MeasureText)(PP_Resource font, 251 int32_t (*MeasureText)(PP_Resource font, const struct PP_TextRun_Dev* text);
249 const struct PP_BrowserFont_Trusted_TextRun* text);
250 /** 252 /**
251 * Returns the character at the given pixel X position from the beginning of 253 * Returns the character at the given pixel X position from the beginning of
252 * the string. This handles complex scripts such as Arabic, where characters 254 * the string. This handles complex scripts such as Arabic, where characters
253 * may be combined or replaced depending on the context. Returns (uint32)-1 255 * may be combined or replaced depending on the context. Returns (uint32)-1
254 * on failure. 256 * on failure.
255 *
256 * TODO(brettw) this function may be broken. See the CharPosRTL test. It
257 * seems to tell you "insertion point" rather than painting position. This
258 * is useful but maybe not what we intended here.
259 */ 257 */
260 uint32_t (*CharacterOffsetForPixel)( 258 uint32_t (*CharacterOffsetForPixel)(PP_Resource font,
261 PP_Resource font, 259 const struct PP_TextRun_Dev* text,
262 const struct PP_BrowserFont_Trusted_TextRun* text, 260 int32_t pixel_position);
263 int32_t pixel_position);
264 /** 261 /**
265 * Returns the horizontal advance to the given character if the string was 262 * Returns the horizontal advance to the given character if the string was
266 * placed at the given position. This handles complex scripts such as Arabic, 263 * placed at the given position. This handles complex scripts such as Arabic,
267 * where characters may be combined or replaced depending on context. Returns 264 * where characters may be combined or replaced depending on context. Returns
268 * -1 on error. 265 * -1 on error.
269 */ 266 */
270 int32_t (*PixelOffsetForCharacter)( 267 int32_t (*PixelOffsetForCharacter)(PP_Resource font,
271 PP_Resource font, 268 const struct PP_TextRun_Dev* text,
272 const struct PP_BrowserFont_Trusted_TextRun* text, 269 uint32_t char_offset);
273 uint32_t char_offset);
274 }; 270 };
275 271
276 typedef struct PPB_BrowserFont_Trusted_1_0 PPB_BrowserFont_Trusted; 272 typedef struct PPB_Font_Dev_0_6 PPB_Font_Dev;
277 /** 273 /**
278 * @} 274 * @}
279 */ 275 */
280 276
281 #endif /* PPAPI_C_TRUSTED_PPB_BROWSER_FONT_TRUSTED_H_ */ 277 #endif /* PPAPI_C_DEV_PPB_FONT_DEV_H_ */
282 278
OLDNEW
« no previous file with comments | « ppapi/api/dev/ppb_font_dev.idl ('k') | ppapi/ppapi_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698