| 1 |
|
| 2 |
@c %start of fragment |
| 3 |
|
| 4 |
@deffn Function cairo-scaled-font-create (@var{font-face}@tie{}@code{<cairo-font-face-t>}) (@var{font-matrix}@tie{}@code{<cairo-matrix-t>}) (@var{ctm}@tie{}@code{<cairo-matrix-t>}) (@var{options}@tie{}@code{<cairo-font-options-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-scaled-font-t >}) |
| 5 |
Creates a @code{<cairo-scaled-font-t>} object from a font face and |
| 6 |
matrices that describe the size of the font and the environment in which |
| 7 |
it will be used. |
| 8 |
|
| 9 |
@table @var |
| 10 |
@item font-face |
| 11 |
a @code{<cairo-font-face-t>} |
| 12 |
|
| 13 |
@item font-matrix |
| 14 |
font space to user space transformation matrix for the font. In the |
| 15 |
simplest case of a N point font, this matrix is just a scale by N, but |
| 16 |
it can also be used to shear the font or stretch it unequally along the |
| 17 |
two axes. See @code{cairo-set-font-matrix}. |
| 18 |
|
| 19 |
@item ctm |
| 20 |
user to device transformation matrix with which the font will be used. |
| 21 |
|
| 22 |
@item options |
| 23 |
options to use when getting metrics for the font and rendering with it. |
| 24 |
|
| 25 |
@item ret |
| 26 |
a newly created @code{<cairo-scaled-font-t>}. Destroy with |
| 27 |
@code{cairo-scaled-font-destroy} |
| 28 |
|
| 29 |
@end table |
| 30 |
|
| 31 |
@end deffn |
| 32 |
|
| 33 |
@deffn Function cairo-scaled-font-extents (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) (@var{extents}@tie{}@code{<cairo-font-extents-t>}) |
| 34 |
Gets the metrics for a @code{<cairo-scaled-font-t>}. |
| 35 |
|
| 36 |
@table @var |
| 37 |
@item scaled-font |
| 38 |
a @code{<cairo-scaled-font-t>} |
| 39 |
|
| 40 |
@item extents |
| 41 |
a @code{<cairo-font-extents-t>} which to store the retrieved extents. |
| 42 |
|
| 43 |
@end table |
| 44 |
|
| 45 |
@end deffn |
| 46 |
|
| 47 |
@deffn Function cairo-scaled-font-text-extents (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) (@var{utf8}@tie{}@code{<char>}) (@var{extents}@tie{}@code{<cairo-text-extents-t>}) |
| 48 |
Gets the extents for a string of text. The extents describe a user-space |
| 49 |
rectangle that encloses the "inked" portion of the text drawn at the |
| 50 |
origin (0,0) (as it would be drawn by @code{cairo-show-text} if the |
| 51 |
cairo graphics state were set to the same font_face, font_matrix, ctm, |
| 52 |
and font_options as @var{scaled-font}). Additionally, the x_advance and |
| 53 |
y_advance values indicate the amount by which the current point would be |
| 54 |
advanced by @code{cairo-show-text}. |
| 55 |
|
| 56 |
Note that whitespace characters do not directly contribute to the size |
| 57 |
of the rectangle (extents.width and extents.height). They do contribute |
| 58 |
indirectly by changing the position of non-whitespace characters. In |
| 59 |
particular, trailing whitespace characters are likely to not affect the |
| 60 |
size of the rectangle, though they will affect the x_advance and |
| 61 |
y_advance values. |
| 62 |
|
| 63 |
@table @var |
| 64 |
@item scaled-font |
| 65 |
a @code{<cairo-scaled-font-t>} |
| 66 |
|
| 67 |
@item utf8 |
| 68 |
a NUL-terminated string of text, encoded in UTF-8 |
| 69 |
|
| 70 |
@item extents |
| 71 |
a @code{<cairo-text-extents-t>} which to store the retrieved extents. |
| 72 |
|
| 73 |
@end table |
| 74 |
|
| 75 |
Since 1.2 |
| 76 |
|
| 77 |
@end deffn |
| 78 |
|
| 79 |
@deffn Function cairo-scaled-font-glyph-extents (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) (@var{glyphs}@tie{}@code{<cairo-glyph-t>}) (@var{num-glyphs}@tie{}@code{<int>}) (@var{extents}@tie{}@code{<cairo-text-extents-t>}) |
| 80 |
Gets the extents for an array of glyphs. The extents describe a |
| 81 |
user-space rectangle that encloses the "inked" portion of the glyphs, |
| 82 |
(as they would be drawn by @code{cairo-show-glyphs} if the cairo |
| 83 |
graphics state were set to the same font_face, font_matrix, ctm, and |
| 84 |
font_options as @var{scaled-font}). Additionally, the x_advance and |
| 85 |
y_advance values indicate the amount by which the current point would be |
| 86 |
advanced by @code{cairo-show-glyphs}. |
| 87 |
|
| 88 |
Note that whitespace glyphs do not contribute to the size of the |
| 89 |
rectangle (extents.width and extents.height). |
| 90 |
|
| 91 |
@table @var |
| 92 |
@item scaled-font |
| 93 |
a @code{<cairo-scaled-font-t>} |
| 94 |
|
| 95 |
@item glyphs |
| 96 |
an array of glyph IDs with X and Y offsets. |
| 97 |
|
| 98 |
@item num-glyphs |
| 99 |
the number of glyphs in the @var{glyphs} array |
| 100 |
|
| 101 |
@item extents |
| 102 |
a @code{<cairo-text-extents-t>} which to store the retrieved extents. |
| 103 |
|
| 104 |
@end table |
| 105 |
|
| 106 |
@end deffn |
| 107 |
|
| 108 |
@deffn Function cairo-scaled-font-text-to-glyphs (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) (@var{x}@tie{}@code{<double>}) (@var{y}@tie{}@code{<double>}) (@var{utf8}@tie{}@code{<char>}) (@var{utf8-len}@tie{}@code{<int>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-status-t>}) (@var{glyphs}@tie{}@code{<cairo-glyph-t*>}) (@var{num-glyphs}@tie{}@code{<int>}) (@var{clusters}@tie{}@code{<cairo-text-cluster-t*>}) (@var{num-clusters}@tie{}@code{<int>}) (@var{cluster-flags}@tie{}@code{<cairo-text-cluster-flags-t>}) |
| 109 |
Converts UTF-8 text to an array of glyphs, optionally with cluster |
| 110 |
mapping, that can be used to render later using @var{scaled-font}. |
| 111 |
|
| 112 |
If @var{glyphs} initially points to a non-@samp{@code{#f}} value, that |
| 113 |
array is used as a glyph buffer, and @var{num-glyphs} should point to |
| 114 |
the number of glyph entries available there. If the provided glyph array |
| 115 |
is too short for the conversion, a new glyph array is allocated using |
| 116 |
@code{cairo-glyph-allocate} and placed in @var{glyphs}. Upon return, |
| 117 |
@var{num-glyphs} always contains the number of generated glyphs. If the |
| 118 |
value @var{glyphs} points to has changed after the call, the user is |
| 119 |
responsible for freeing the allocated glyph array using |
| 120 |
@code{cairo-glyph-free}. This may happen even if the provided array was |
| 121 |
large enough. |
| 122 |
|
| 123 |
If @var{clusters} is not @samp{@code{#f}}, @var{num-clusters} and |
| 124 |
@var{cluster-flags} should not be @samp{@code{#f}}, and cluster mapping |
| 125 |
will be computed. The semantics of how cluster array allocation works is |
| 126 |
similar to the glyph array. That is, if @var{clusters} initially points |
| 127 |
to a non-@samp{@code{#f}} value, that array is used as a cluster buffer, |
| 128 |
and @var{num-clusters} should point to the number of cluster entries |
| 129 |
available there. If the provided cluster array is too short for the |
| 130 |
conversion, a new cluster array is allocated using |
| 131 |
@code{cairo-text-cluster-allocate} and placed in @var{clusters}. Upon |
| 132 |
return, @var{num-clusters} always contains the number of generated |
| 133 |
clusters. If the value @var{clusters} points at has changed after the |
| 134 |
call, the user is responsible for freeing the allocated cluster array |
| 135 |
using @code{cairo-text-cluster-free}. This may happen even if the |
| 136 |
provided array was large enough. |
| 137 |
|
| 138 |
In the simplest case, @var{glyphs} and @var{clusters} can point to |
| 139 |
@samp{@code{#f}} initially and a suitable array will be allocated. In |
| 140 |
code: |
| 141 |
|
| 142 |
@example |
| 143 |
|
| 144 |
cairo_status_t status; |
| 145 |
|
| 146 |
cairo_glyph_t *glyphs = NULL; |
| 147 |
int num_glyphs; |
| 148 |
cairo_text_cluster_t *clusters = NULL; |
| 149 |
int num_clusters; |
| 150 |
cairo_text_cluster_flags_t cluster_flags; |
| 151 |
|
| 152 |
status = cairo_scaled_font_text_to_glyphs (scaled_font, |
| 153 |
x, y, |
| 154 |
utf8, utf8_len, |
| 155 |
&glyphs, &num_glyphs, |
| 156 |
&clusters, &num_clusters, &cluster_flags); |
| 157 |
|
| 158 |
if (status == CAIRO_STATUS_SUCCESS) @{ |
| 159 |
cairo_show_text_glyphs (cr, |
| 160 |
utf8, utf8_len, |
| 161 |
glyphs, num_glyphs, |
| 162 |
clusters, num_clusters, cluster_flags); |
| 163 |
|
| 164 |
cairo_glyph_free (glyphs); |
| 165 |
cairo_text_cluster_free (clusters); |
| 166 |
@} |
| 167 |
@end example |
| 168 |
|
| 169 |
If no cluster mapping is needed: |
| 170 |
|
| 171 |
@example |
| 172 |
|
| 173 |
cairo_status_t status; |
| 174 |
|
| 175 |
cairo_glyph_t *glyphs = NULL; |
| 176 |
int num_glyphs; |
| 177 |
|
| 178 |
status = cairo_scaled_font_text_to_glyphs (scaled_font, |
| 179 |
x, y, |
| 180 |
utf8, utf8_len, |
| 181 |
&glyphs, &num_glyphs, |
| 182 |
NULL, NULL, |
| 183 |
NULL); |
| 184 |
|
| 185 |
if (status == CAIRO_STATUS_SUCCESS) @{ |
| 186 |
cairo_show_glyphs (cr, glyphs, num_glyphs); |
| 187 |
cairo_glyph_free (glyphs); |
| 188 |
@} |
| 189 |
@end example |
| 190 |
|
| 191 |
If stack-based glyph and cluster arrays are to be used for small arrays: |
| 192 |
|
| 193 |
@example |
| 194 |
|
| 195 |
cairo_status_t status; |
| 196 |
|
| 197 |
cairo_glyph_t stack_glyphs[40]; |
| 198 |
cairo_glyph_t *glyphs = stack_glyphs; |
| 199 |
int num_glyphs = sizeof (stack_glyphs) / sizeof (stack_glyphs[0]); |
| 200 |
cairo_text_cluster_t stack_clusters[40]; |
| 201 |
cairo_text_cluster_t *clusters = stack_clusters; |
| 202 |
int num_clusters = sizeof (stack_clusters) / sizeof (stack_clusters[0]); |
| 203 |
cairo_text_cluster_flags_t cluster_flags; |
| 204 |
|
| 205 |
status = cairo_scaled_font_text_to_glyphs (scaled_font, |
| 206 |
x, y, |
| 207 |
utf8, utf8_len, |
| 208 |
&glyphs, &num_glyphs, |
| 209 |
&clusters, &num_clusters, &cluster_flags); |
| 210 |
|
| 211 |
if (status == CAIRO_STATUS_SUCCESS) @{ |
| 212 |
cairo_show_text_glyphs (cr, |
| 213 |
utf8, utf8_len, |
| 214 |
glyphs, num_glyphs, |
| 215 |
clusters, num_clusters, cluster_flags); |
| 216 |
|
| 217 |
if (glyphs != stack_glyphs) |
| 218 |
cairo_glyph_free (glyphs); |
| 219 |
if (clusters != stack_clusters) |
| 220 |
cairo_text_cluster_free (clusters); |
| 221 |
@} |
| 222 |
@end example |
| 223 |
|
| 224 |
For details of how @var{clusters}, @var{num-clusters}, and |
| 225 |
@var{cluster-flags} map input UTF-8 text to the output glyphs see |
| 226 |
@code{cairo-show-text-glyphs}. |
| 227 |
|
| 228 |
The output values can be readily passed to |
| 229 |
@code{cairo-show-text-glyphs}@code{cairo-show-glyphs}, or related |
| 230 |
functions, assuming that the exact same @var{scaled-font} is used for |
| 231 |
the operation. |
| 232 |
|
| 233 |
@table @var |
| 234 |
@item scaled-font |
| 235 |
a @code{<cairo-scaled-font-t>} |
| 236 |
|
| 237 |
@item x |
| 238 |
X position to place first glyph |
| 239 |
|
| 240 |
@item y |
| 241 |
Y position to place first glyph |
| 242 |
|
| 243 |
@item utf8 |
| 244 |
a string of text encoded in UTF-8 |
| 245 |
|
| 246 |
@item utf8-len |
| 247 |
length of @var{utf8} in bytes, or -1 if it is NUL-terminated |
| 248 |
|
| 249 |
@item glyphs |
| 250 |
pointer to array of glyphs to fill |
| 251 |
|
| 252 |
@item num-glyphs |
| 253 |
pointer to number of glyphs |
| 254 |
|
| 255 |
@item clusters |
| 256 |
pointer to array of cluster mapping information to fill, or |
| 257 |
@samp{@code{#f}} |
| 258 |
|
| 259 |
@item num-clusters |
| 260 |
pointer to number of clusters, or @samp{@code{#f}} |
| 261 |
|
| 262 |
@item cluster-flags |
| 263 |
pointer to location to store cluster flags corresponding to the output |
| 264 |
@var{clusters}, or @samp{@code{#f}} |
| 265 |
|
| 266 |
@item ret |
| 267 |
@samp{CAIRO_STATUS_SUCCESS} upon success, or an error status if the |
| 268 |
input values are wrong or if conversion failed. If the input values are |
| 269 |
correct but the conversion failed, the error status is also set on |
| 270 |
@var{scaled-font}. |
| 271 |
|
| 272 |
@end table |
| 273 |
|
| 274 |
Since 1.8 |
| 275 |
|
| 276 |
@end deffn |
| 277 |
|
| 278 |
@deffn Function cairo-scaled-font-get-font-face (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-font-face-t >}) |
| 279 |
Gets the font face that this scaled font uses. This is the font face |
| 280 |
passed to @code{cairo-scaled-font-create}. |
| 281 |
|
| 282 |
@table @var |
| 283 |
@item scaled-font |
| 284 |
a @code{<cairo-scaled-font-t>} |
| 285 |
|
| 286 |
@item ret |
| 287 |
The @code{<cairo-font-face-t>} with which @var{scaled-font} was created. |
| 288 |
|
| 289 |
@end table |
| 290 |
|
| 291 |
Since 1.2 |
| 292 |
|
| 293 |
@end deffn |
| 294 |
|
| 295 |
@deffn Function cairo-scaled-font-get-font-options (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) (@var{options}@tie{}@code{<cairo-font-options-t>}) |
| 296 |
Stores the font options with which @var{scaled-font} was created into |
| 297 |
@var{options}. |
| 298 |
|
| 299 |
@table @var |
| 300 |
@item scaled-font |
| 301 |
a @code{<cairo-scaled-font-t>} |
| 302 |
|
| 303 |
@item options |
| 304 |
return value for the font options |
| 305 |
|
| 306 |
@end table |
| 307 |
|
| 308 |
Since 1.2 |
| 309 |
|
| 310 |
@end deffn |
| 311 |
|
| 312 |
@deffn Function cairo-scaled-font-get-font-matrix (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) (@var{font-matrix}@tie{}@code{<cairo-matrix-t>}) |
| 313 |
Stores the font matrix with which @var{scaled-font} was created into |
| 314 |
@var{matrix}. |
| 315 |
|
| 316 |
@table @var |
| 317 |
@item scaled-font |
| 318 |
a @code{<cairo-scaled-font-t>} |
| 319 |
|
| 320 |
@item font-matrix |
| 321 |
return value for the matrix |
| 322 |
|
| 323 |
@end table |
| 324 |
|
| 325 |
Since 1.2 |
| 326 |
|
| 327 |
@end deffn |
| 328 |
|
| 329 |
@deffn Function cairo-scaled-font-get-ctm (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) (@var{ctm}@tie{}@code{<cairo-matrix-t>}) |
| 330 |
Stores the CTM with which @var{scaled-font} was created into @var{ctm}. |
| 331 |
Note that the translation offsets (x0, y0) of the CTM are ignored by |
| 332 |
@code{cairo-scaled-font-create}. So, the matrix this function returns |
| 333 |
always has 0,0 as x0,y0. |
| 334 |
|
| 335 |
@table @var |
| 336 |
@item scaled-font |
| 337 |
a @code{<cairo-scaled-font-t>} |
| 338 |
|
| 339 |
@item ctm |
| 340 |
return value for the CTM |
| 341 |
|
| 342 |
@end table |
| 343 |
|
| 344 |
Since 1.2 |
| 345 |
|
| 346 |
@end deffn |
| 347 |
|
| 348 |
@deffn Function cairo-scaled-font-get-type (@var{scaled-font}@tie{}@code{<cairo-scaled-font-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-font-type-t>}) |
| 349 |
This function returns the type of the backend used to create a scaled |
| 350 |
font. See @code{<cairo-font-type-t>} for available types. However, this |
| 351 |
function never returns @samp{CAIRO_FONT_TYPE_TOY}. |
| 352 |
|
| 353 |
@table @var |
| 354 |
@item scaled-font |
| 355 |
a @code{<cairo-scaled-font-t>} |
| 356 |
|
| 357 |
@item ret |
| 358 |
The type of @var{scaled-font}. |
| 359 |
|
| 360 |
@end table |
| 361 |
|
| 362 |
Since 1.2 |
| 363 |
|
| 364 |
@end deffn |
| 365 |
|
| 366 |
|
| 367 |
@c %end of fragment |