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

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

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/c/dev/ppb_find_dev.h ('k') | ppapi/c/dev/ppb_fullscreen_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_module.h" 9 #include "ppapi/c/pp_module.h"
9 #include "ppapi/c/pp_resource.h" 10 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/c/pp_stdint.h" 11 #include "ppapi/c/pp_stdint.h"
11 #include "ppapi/c/pp_var.h" 12 #include "ppapi/c/pp_var.h"
12 13
13 #define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.1" 14 #define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.2"
14 15
15 struct PP_Point; 16 struct PP_Point;
16 struct PP_Rect; 17 struct PP_Rect;
17 18
18 typedef enum { 19 typedef enum {
19 // Uses the user's default web page font (normally either the default serif 20 // Uses the user's default web page font (normally either the default serif
20 // or sans serif font). 21 // or sans serif font).
21 PP_FONTFAMILY_DEFAULT = 0, 22 PP_FONTFAMILY_DEFAULT = 0,
22 23
23 // These families will use the default web page font corresponding to the 24 // These families will use the default web page font corresponding to the
(...skipping 24 matching lines...) Expand all
48 49
49 // When face is a Null string, this specifies the generic font family type 50 // When face is a Null string, this specifies the generic font family type
50 // to use. If the face is specified, this will be ignored. 51 // to use. If the face is specified, this will be ignored.
51 PP_FontFamily_Dev family; 52 PP_FontFamily_Dev family;
52 53
53 uint32_t size; 54 uint32_t size;
54 55
55 // Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD. 56 // Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD.
56 PP_FontWeight_Dev weight; 57 PP_FontWeight_Dev weight;
57 58
58 bool italic; 59 PP_Bool italic;
59 bool small_caps; 60 PP_Bool small_caps;
60 61
61 // Adjustment to apply to letter and word spacing, respectively. Initialize 62 // Adjustment to apply to letter and word spacing, respectively. Initialize
62 // to 0 to get normal spacing. Negative values bring letters/words closer 63 // to 0 to get normal spacing. Negative values bring letters/words closer
63 // together, positive values separate them. 64 // together, positive values separate them.
64 int letter_spacing; 65 int letter_spacing;
65 int word_spacing; 66 int word_spacing;
66 }; 67 };
67 68
68 struct PP_FontMetrics_Dev { 69 struct PP_FontMetrics_Dev {
69 int32_t height; 70 int32_t height;
70 int32_t ascent; 71 int32_t ascent;
71 int32_t descent; 72 int32_t descent;
72 int32_t line_spacing; 73 int32_t line_spacing;
73 int32_t x_height; 74 int32_t x_height;
74 }; 75 };
75 76
76 struct PP_TextRun_Dev { 77 struct PP_TextRun_Dev {
77 // This var must either be a string or a null var (which will be treated as 78 // This var must either be a string or a null var (which will be treated as
78 // a 0-length string). 79 // a 0-length string).
79 struct PP_Var text; 80 struct PP_Var text;
80 81
81 // Set to true if the text is right-to-left. 82 // Set to PP_TRUE if the text is right-to-left.
82 bool rtl; 83 PP_Bool rtl;
83 84
84 // Set to true to force the directionality of the text regardless of content 85 // Set to PP_TRUE to force the directionality of the text regardless of
85 bool override_direction; 86 // content
87 PP_Bool override_direction;
86 }; 88 };
87 89
88 struct PPB_Font_Dev { 90 struct PPB_Font_Dev {
89 // Returns a font which best matches the given description. The return value 91 // Returns a font which best matches the given description. The return value
90 // will have a non-zero ID on success, or zero on failure. 92 // will have a non-zero ID on success, or zero on failure.
91 PP_Resource (*Create)(PP_Module module, 93 PP_Resource (*Create)(PP_Module module,
92 const struct PP_FontDescription_Dev* description); 94 const struct PP_FontDescription_Dev* description);
93 95
94 // Returns true if the given resource is a Font. Returns false if the 96 // Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the
95 // resource is invalid or some type other than a Font. 97 // resource is invalid or some type other than a Font.
96 bool (*IsFont)(PP_Resource resource); 98 PP_Bool (*IsFont)(PP_Resource resource);
97 99
98 // Loads the description and metrics of the font into the given structures. 100 // Loads the description and metrics of the font into the given structures.
99 // The description will be different than the description the font was 101 // The description will be different than the description the font was
100 // created with since it will be filled with the real values from the font 102 // created with since it will be filled with the real values from the font
101 // that was actually selected. 103 // that was actually selected.
102 // 104 //
103 // The PP_Var in the description should be of type Void on input. On output, 105 // The PP_Var in the description should be of type Void on input. On output,
104 // this will contain the string and will have a reference count of 1. The 106 // this will contain the string and will have a reference count of 1. The
105 // plugin is responsible for calling Release on this var. 107 // plugin is responsible for calling Release on this var.
106 // 108 //
107 // Returns true on success, false if the font is invalid or if the Var in 109 // Returns PP_TRUE on success, PP_FALSE if the font is invalid or if the Var
108 // the description isn't Null (to prevent leaks). 110 // in the description isn't Null (to prevent leaks).
109 bool (*Describe)(PP_Resource font, 111 PP_Bool (*Describe)(PP_Resource font,
110 struct PP_FontDescription_Dev* description, 112 struct PP_FontDescription_Dev* description,
111 struct PP_FontMetrics_Dev* metrics); 113 struct PP_FontMetrics_Dev* metrics);
112 114
113 // Draws the text to the image buffer. 115 // Draws the text to the image buffer.
114 // 116 //
115 // The given point represents the baseline of the left edge of the font, 117 // The given point represents the baseline of the left edge of the font,
116 // regardless of whether it is left-to-right or right-to-left (in the case of 118 // regardless of whether it is left-to-right or right-to-left (in the case of
117 // RTL text, this will actually represent the logical end of the text). 119 // RTL text, this will actually represent the logical end of the text).
118 // 120 //
119 // The clip is optional and may be NULL. In this case, the text will be 121 // The clip is optional and may be NULL. In this case, the text will be
120 // clipped to the image. 122 // clipped to the image.
121 // 123 //
122 // The image_data_is_opaque flag indicates whether subpixel antialiasing can 124 // The image_data_is_opaque flag indicates whether subpixel antialiasing can
123 // be performend, if it is supported. When the image below the text is 125 // be performend, if it is supported. When the image below the text is
124 // opaque, subpixel antialiasing is supported and you should set this to true 126 // opaque, subpixel antialiasing is supported and you should set this to
125 // to pick up the user's default preferences. If your plugin is partially 127 // PP_TRUE to pick up the user's default preferences. If your plugin is
126 // transparent, then subpixel antialiasing is not possible and grayscale 128 // partially transparent, then subpixel antialiasing is not possible and
127 // antialiasing will be used instead (assuming the user has antialiasing 129 // grayscale antialiasing will be used instead (assuming the user has
128 // enabled at all). 130 // antialiasing enabled at all).
129 bool (*DrawTextAt)(PP_Resource font, 131 PP_Bool (*DrawTextAt)(PP_Resource font,
130 PP_Resource image_data, 132 PP_Resource image_data,
131 const struct PP_TextRun_Dev* text, 133 const struct PP_TextRun_Dev* text,
132 const struct PP_Point* position, 134 const struct PP_Point* position,
133 uint32_t color, 135 uint32_t color,
134 const struct PP_Rect* clip, 136 const struct PP_Rect* clip,
135 bool image_data_is_opaque); 137 PP_Bool image_data_is_opaque);
136 138
137 // Returns the width of the given string. If the font is invalid or the var 139 // Returns the width of the given string. If the font is invalid or the var
138 // isn't a valid string, this will return -1. 140 // isn't a valid string, this will return -1.
139 // 141 //
140 // Note that this function handles complex scripts such as Arabic, combining 142 // Note that this function handles complex scripts such as Arabic, combining
141 // accents, etc. so that adding the width of substrings won't necessarily 143 // accents, etc. so that adding the width of substrings won't necessarily
142 // produce the correct width of the entire string. 144 // produce the correct width of the entire string.
143 int32_t (*MeasureText)(PP_Resource font, 145 int32_t (*MeasureText)(PP_Resource font,
144 const struct PP_TextRun_Dev* text); 146 const struct PP_TextRun_Dev* text);
145 147
146 // Returns the character at the given pixel X position from the beginning of 148 // Returns the character at the given pixel X position from the beginning of
147 // the string. This handles complex scripts such as Arabic, where characters 149 // the string. This handles complex scripts such as Arabic, where characters
148 // may be combined or replaced depending on the context. 150 // may be combined or replaced depending on the context.
149 uint32_t (*CharacterOffsetForPixel)(PP_Resource font, 151 uint32_t (*CharacterOffsetForPixel)(PP_Resource font,
150 const struct PP_TextRun_Dev* text, 152 const struct PP_TextRun_Dev* text,
151 int32_t pixel_position); 153 int32_t pixel_position);
152 154
153 // Returns the horizontal advance to the given character if the string was 155 // Returns the horizontal advance to the given character if the string was
154 // placed at the given position. This handles complex scripts such as Arabic, 156 // placed at the given position. This handles complex scripts such as Arabic,
155 // where characters may be combined or replaced depending on context. 157 // where characters may be combined or replaced depending on context.
156 int32_t (*PixelOffsetForCharacter)(PP_Resource font, 158 int32_t (*PixelOffsetForCharacter)(PP_Resource font,
157 const struct PP_TextRun_Dev* text, 159 const struct PP_TextRun_Dev* text,
158 uint32_t char_offset); 160 uint32_t char_offset);
159 }; 161 };
160 162
161 #endif // PPAPI_C_DEV_PPB_FONT_DEV_H_ 163 #endif // PPAPI_C_DEV_PPB_FONT_DEV_H_
OLDNEW
« no previous file with comments | « ppapi/c/dev/ppb_find_dev.h ('k') | ppapi/c/dev/ppb_fullscreen_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698