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

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

Issue 7044012: Support getting the font list in Pepper. This currently only works out of (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « content/ppapi_plugin/ppapi_thread.cc ('k') | ppapi/cpp/dev/font_dev.h » ('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) 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_instance.h" 9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/c/pp_macros.h" 10 #include "ppapi/c/pp_macros.h"
11 #include "ppapi/c/pp_resource.h" 11 #include "ppapi/c/pp_resource.h"
12 #include "ppapi/c/pp_stdint.h" 12 #include "ppapi/c/pp_stdint.h"
13 #include "ppapi/c/pp_var.h" 13 #include "ppapi/c/pp_var.h"
14 14
15 #define PPB_FONT_DEV_INTERFACE_0_5 "PPB_Font(Dev);0.5" 15 #define PPB_FONT_DEV_INTERFACE_0_6 "PPB_Font(Dev);0.6"
16 #define PPB_FONT_DEV_INTERFACE PPB_FONT_DEV_INTERFACE_0_5 16 #define PPB_FONT_DEV_INTERFACE PPB_FONT_DEV_INTERFACE_0_6
17 17
18 struct PP_Point; 18 struct PP_Point;
19 struct PP_Rect; 19 struct PP_Rect;
20 20
21 typedef enum { 21 typedef enum {
22 // Uses the user's default web page font (normally either the default serif 22 /**
23 // or sans serif font). 23 * Uses the user's default web page font (normally either the default serif
24 * or sans serif font).
25 */
24 PP_FONTFAMILY_DEFAULT = 0, 26 PP_FONTFAMILY_DEFAULT = 0,
25 27
26 // These families will use the default web page font corresponding to the 28 /**
27 // given family. 29 * These families will use the default web page font corresponding to the
30 * given family.
31 */
28 PP_FONTFAMILY_SERIF = 1, 32 PP_FONTFAMILY_SERIF = 1,
29 PP_FONTFAMILY_SANSSERIF = 2, 33 PP_FONTFAMILY_SANSSERIF = 2,
30 PP_FONTFAMILY_MONOSPACE = 3 34 PP_FONTFAMILY_MONOSPACE = 3
31 } PP_FontFamily_Dev; 35 } PP_FontFamily_Dev;
32 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontFamily_Dev, 4); 36 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontFamily_Dev, 4);
33 37
38 /**
39 * Specifies the font weight. Normally users will only use NORMAL or BOLD.
40 */
34 typedef enum { 41 typedef enum {
35 PP_FONTWEIGHT_100 = 0, 42 PP_FONTWEIGHT_100 = 0,
36 PP_FONTWEIGHT_200, 43 PP_FONTWEIGHT_200,
37 PP_FONTWEIGHT_300, 44 PP_FONTWEIGHT_300,
38 PP_FONTWEIGHT_400, 45 PP_FONTWEIGHT_400,
39 PP_FONTWEIGHT_500, 46 PP_FONTWEIGHT_500,
40 PP_FONTWEIGHT_600, 47 PP_FONTWEIGHT_600,
41 PP_FONTWEIGHT_700, 48 PP_FONTWEIGHT_700,
42 PP_FONTWEIGHT_800, 49 PP_FONTWEIGHT_800,
43 PP_FONTWEIGHT_900, 50 PP_FONTWEIGHT_900,
44 PP_FONTWEIGHT_NORMAL = PP_FONTWEIGHT_400, 51 PP_FONTWEIGHT_NORMAL = PP_FONTWEIGHT_400,
45 PP_FONTWEIGHT_BOLD = PP_FONTWEIGHT_700 52 PP_FONTWEIGHT_BOLD = PP_FONTWEIGHT_700
46 } PP_FontWeight_Dev; 53 } PP_FontWeight_Dev;
47 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontWeight_Dev, 4); 54 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FontWeight_Dev, 4);
48 55
49 struct PP_FontDescription_Dev { 56 struct PP_FontDescription_Dev {
50 // Font face name as a string. This can also be a Null var, in which case the 57 /**
51 // generic family will be obeyed. 58 * Font face name as a string. This can also be an undefined var, in which
59 * case the generic family will be obeyed.
60 */
52 struct PP_Var face; 61 struct PP_Var face;
53 62
54 // When face is a Null string, this specifies the generic font family type 63 /**
55 // to use. If the face is specified, this will be ignored. 64 * When face is an undefined var, this specifies the generic font family type
65 * to use. If the face is specified, this will be ignored.
66 */
56 PP_FontFamily_Dev family; 67 PP_FontFamily_Dev family;
57 68
69 /**
70 * Size in pixels.
71 */
58 uint32_t size; 72 uint32_t size;
59 73
60 // Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD. 74 /**
75 * Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD.
76 */
61 PP_FontWeight_Dev weight; 77 PP_FontWeight_Dev weight;
62 78
63 PP_Bool italic; 79 PP_Bool italic;
64 PP_Bool small_caps; 80 PP_Bool small_caps;
65 81
66 // Adjustment to apply to letter and word spacing, respectively. Initialize 82 /**
67 // to 0 to get normal spacing. Negative values bring letters/words closer 83 * Adjustment to apply to letter and word spacing, respectively. Initialize
68 // together, positive values separate them. 84 * to 0 to get normal spacing. Negative values bring letters/words closer
85 * together, positive values separate them.
86 */
69 int32_t letter_spacing; 87 int32_t letter_spacing;
70 int32_t word_spacing; 88 int32_t word_spacing;
71 89
72 // Ensure that this struct is 48-bytes wide by padding the end. In some 90 /**
73 // compilers, PP_Var is 8-byte aligned, so those compilers align this struct 91 * Ensure that this struct is 48-bytes wide by padding the end. In some
74 // on 8-byte boundaries as well and pad it to 16 bytes even without this 92 * compilers, PP_Var is 8-byte aligned, so those compilers align this struct
75 // padding attribute. This padding makes its size consistent across 93 * on 8-byte boundaries as well and pad it to 16 bytes even without this
76 // compilers. 94 * padding attribute. This padding makes its size consistent across
95 * compilers.
96 */
77 int32_t padding; 97 int32_t padding;
78 }; 98 };
79 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontDescription_Dev, 48); 99 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontDescription_Dev, 48);
80 100
81 struct PP_FontMetrics_Dev { 101 struct PP_FontMetrics_Dev {
82 int32_t height; 102 int32_t height;
83 int32_t ascent; 103 int32_t ascent;
84 int32_t descent; 104 int32_t descent;
85 int32_t line_spacing; 105 int32_t line_spacing;
86 int32_t x_height; 106 int32_t x_height;
87 }; 107 };
88 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontMetrics_Dev, 20); 108 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FontMetrics_Dev, 20);
89 109
90 struct PP_TextRun_Dev { 110 struct PP_TextRun_Dev {
91 // This var must either be a string or a null var (which will be treated as 111 /**
92 // a 0-length string). 112 * This var must either be a string or a null/undefined var (which will be
113 * treated as a 0-length string).
114 */
93 struct PP_Var text; 115 struct PP_Var text;
94 116
95 // Set to PP_TRUE if the text is right-to-left. 117 /**
118 * Set to PP_TRUE if the text is right-to-left.
119 */
96 PP_Bool rtl; 120 PP_Bool rtl;
97 121
98 // Set to PP_TRUE to force the directionality of the text regardless of 122 /**
99 // content 123 * Set to PP_TRUE to force the directionality of the text regardless of
124 * content
125 */
100 PP_Bool override_direction; 126 PP_Bool override_direction;
101 }; 127 };
102 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TextRun_Dev, 24); 128 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TextRun_Dev, 24);
103 129
104 struct PPB_Font_Dev { 130 struct PPB_Font_Dev {
105 // Returns a font which best matches the given description. The return value 131 /**
106 // will have a non-zero ID on success, or zero on failure. 132 * Returns a list of all available font families on the system. You can use
133 * this list to decide whether to Create() a font.
134 *
135 * The return value will be a single string with null characters delimiting
136 * the end of each font name. For example: "Arial\0Courier\0Times\0".
137 *
138 * Returns an undefined var on failure (this typically means you passed an
139 * invalid instance).
140 */
141 struct PP_Var (*GetFontFamilies)(PP_Instance instance);
142
143 /**
144 * Returns a font which best matches the given description. The return value
145 * will have a non-zero ID on success, or zero on failure.
146 */
107 PP_Resource (*Create)(PP_Instance instance, 147 PP_Resource (*Create)(PP_Instance instance,
108 const struct PP_FontDescription_Dev* description); 148 const struct PP_FontDescription_Dev* description);
109 149
110 // Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the 150 /**
111 // resource is invalid or some type other than a Font. 151 * Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the
152 * resource is invalid or some type other than a Font.
153 */
112 PP_Bool (*IsFont)(PP_Resource resource); 154 PP_Bool (*IsFont)(PP_Resource resource);
113 155
114 // Loads the description and metrics of the font into the given structures. 156 /**
115 // The description will be different than the description the font was 157 * Loads the description and metrics of the font into the given structures.
116 // created with since it will be filled with the real values from the font 158 * The description will be different than the description the font was
117 // that was actually selected. 159 * created with since it will be filled with the real values from the font
118 // 160 * that was actually selected.
119 // The PP_Var in the description should be of type Void on input. On output, 161 *
120 // this will contain the string and will have a reference count of 1. The 162 * The PP_Var in the description should be of type Void on input. On output,
121 // plugin is responsible for calling Release on this var. 163 * this will contain the string and will have a reference count of 1. The
122 // 164 * plugin is responsible for calling Release on this var.
123 // Returns PP_TRUE on success, PP_FALSE if the font is invalid or if the Var 165 *
124 // in the description isn't Null (to prevent leaks). 166 * Returns PP_TRUE on success, PP_FALSE if the font is invalid or if the Var
167 * in the description isn't Null (to prevent leaks).
168 */
125 PP_Bool (*Describe)(PP_Resource font, 169 PP_Bool (*Describe)(PP_Resource font,
126 struct PP_FontDescription_Dev* description, 170 struct PP_FontDescription_Dev* description,
127 struct PP_FontMetrics_Dev* metrics); 171 struct PP_FontMetrics_Dev* metrics);
128 172
129 // Draws the text to the image buffer. 173 /**
130 // 174 * Draws the text to the image buffer.
131 // The given point represents the baseline of the left edge of the font, 175 *
132 // regardless of whether it is left-to-right or right-to-left (in the case of 176 * The given point represents the baseline of the left edge of the font,
133 // RTL text, this will actually represent the logical end of the text). 177 * regardless of whether it is left-to-right or right-to-left (in the case of
134 // 178 * RTL text, this will actually represent the logical end of the text).
135 // The clip is optional and may be NULL. In this case, the text will be 179 *
136 // clipped to the image. 180 * The clip is optional and may be NULL. In this case, the text will be
137 // 181 * clipped to the image.
138 // The image_data_is_opaque flag indicates whether subpixel antialiasing can 182 *
139 // be performend, if it is supported. When the image below the text is 183 * The image_data_is_opaque flag indicates whether subpixel antialiasing can
140 // opaque, subpixel antialiasing is supported and you should set this to 184 * be performend, if it is supported. When the image below the text is
141 // PP_TRUE to pick up the user's default preferences. If your plugin is 185 * opaque, subpixel antialiasing is supported and you should set this to
142 // partially transparent, then subpixel antialiasing is not possible and 186 * PP_TRUE to pick up the user's default preferences. If your plugin is
143 // grayscale antialiasing will be used instead (assuming the user has 187 * partially transparent, then subpixel antialiasing is not possible and
144 // antialiasing enabled at all). 188 * grayscale antialiasing will be used instead (assuming the user has
189 * antialiasing enabled at all).
190 */
145 PP_Bool (*DrawTextAt)(PP_Resource font, 191 PP_Bool (*DrawTextAt)(PP_Resource font,
146 PP_Resource image_data, 192 PP_Resource image_data,
147 const struct PP_TextRun_Dev* text, 193 const struct PP_TextRun_Dev* text,
148 const struct PP_Point* position, 194 const struct PP_Point* position,
149 uint32_t color, 195 uint32_t color,
150 const struct PP_Rect* clip, 196 const struct PP_Rect* clip,
151 PP_Bool image_data_is_opaque); 197 PP_Bool image_data_is_opaque);
152 198
153 // Returns the width of the given string. If the font is invalid or the var 199 /**
154 // isn't a valid string, this will return -1. 200 * Returns the width of the given string. If the font is invalid or the var
155 // 201 * isn't a valid string, this will return -1.
156 // Note that this function handles complex scripts such as Arabic, combining 202 *
157 // accents, etc. so that adding the width of substrings won't necessarily 203 * Note that this function handles complex scripts such as Arabic, combining
158 // produce the correct width of the entire string. 204 * accents, etc. so that adding the width of substrings won't necessarily
159 // 205 * produce the correct width of the entire string.
160 // Returns -1 on failure. 206 *
207 * Returns -1 on failure.
208 */
161 int32_t (*MeasureText)(PP_Resource font, 209 int32_t (*MeasureText)(PP_Resource font,
162 const struct PP_TextRun_Dev* text); 210 const struct PP_TextRun_Dev* text);
163 211
164 // Returns the character at the given pixel X position from the beginning of 212 /**
165 // the string. This handles complex scripts such as Arabic, where characters 213 * Returns the character at the given pixel X position from the beginning of
166 // may be combined or replaced depending on the context. Returns (uint32)-1 214 * the string. This handles complex scripts such as Arabic, where characters
167 // on failure. 215 * may be combined or replaced depending on the context. Returns (uint32)-1
216 * on failure.
217 */
168 uint32_t (*CharacterOffsetForPixel)(PP_Resource font, 218 uint32_t (*CharacterOffsetForPixel)(PP_Resource font,
169 const struct PP_TextRun_Dev* text, 219 const struct PP_TextRun_Dev* text,
170 int32_t pixel_position); 220 int32_t pixel_position);
171 221
172 // Returns the horizontal advance to the given character if the string was 222 /**
173 // placed at the given position. This handles complex scripts such as Arabic, 223 * Returns the horizontal advance to the given character if the string was
174 // where characters may be combined or replaced depending on context. Returns 224 * placed at the given position. This handles complex scripts such as Arabic,
175 // -1 on error. 225 * where characters may be combined or replaced depending on context. Returns
226 * -1 on error.
227 */
176 int32_t (*PixelOffsetForCharacter)(PP_Resource font, 228 int32_t (*PixelOffsetForCharacter)(PP_Resource font,
177 const struct PP_TextRun_Dev* text, 229 const struct PP_TextRun_Dev* text,
178 uint32_t char_offset); 230 uint32_t char_offset);
231
232
179 }; 233 };
180 234
181 #endif /* PPAPI_C_DEV_PPB_FONT_DEV_H_ */ 235 #endif /* PPAPI_C_DEV_PPB_FONT_DEV_H_ */
182 236
OLDNEW
« no previous file with comments | « content/ppapi_plugin/ppapi_thread.cc ('k') | ppapi/cpp/dev/font_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698