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