Rev 1892 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1892 | Rev 3959 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | * |
45 | * |
46 | * The font options specify how fonts should be rendered. Most of the |
46 | * The font options specify how fonts should be rendered. Most of the |
47 | * time the font options implied by a surface are just right and do not |
47 | * time the font options implied by a surface are just right and do not |
48 | * need any changes, but for pixel-based targets tweaking font options |
48 | * need any changes, but for pixel-based targets tweaking font options |
49 | * may result in superior output on a particular display. |
49 | * may result in superior output on a particular display. |
50 | */ |
50 | **/ |
Line 51... | Line 51... | ||
51 | 51 | ||
52 | static const cairo_font_options_t _cairo_font_options_nil = { |
52 | static const cairo_font_options_t _cairo_font_options_nil = { |
53 | CAIRO_ANTIALIAS_DEFAULT, |
53 | CAIRO_ANTIALIAS_DEFAULT, |
54 | CAIRO_SUBPIXEL_ORDER_DEFAULT, |
54 | CAIRO_SUBPIXEL_ORDER_DEFAULT, |
55 | CAIRO_LCD_FILTER_DEFAULT, |
55 | CAIRO_LCD_FILTER_DEFAULT, |
56 | CAIRO_HINT_STYLE_DEFAULT, |
56 | CAIRO_HINT_STYLE_DEFAULT, |
- | 57 | CAIRO_HINT_METRICS_DEFAULT, |
|
57 | CAIRO_HINT_METRICS_DEFAULT |
58 | CAIRO_ROUND_GLYPH_POS_DEFAULT |
Line 58... | Line 59... | ||
58 | }; |
59 | }; |
59 | 60 | ||
60 | /** |
61 | /** |
Line 69... | Line 70... | ||
69 | options->antialias = CAIRO_ANTIALIAS_DEFAULT; |
70 | options->antialias = CAIRO_ANTIALIAS_DEFAULT; |
70 | options->subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT; |
71 | options->subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT; |
71 | options->lcd_filter = CAIRO_LCD_FILTER_DEFAULT; |
72 | options->lcd_filter = CAIRO_LCD_FILTER_DEFAULT; |
72 | options->hint_style = CAIRO_HINT_STYLE_DEFAULT; |
73 | options->hint_style = CAIRO_HINT_STYLE_DEFAULT; |
73 | options->hint_metrics = CAIRO_HINT_METRICS_DEFAULT; |
74 | options->hint_metrics = CAIRO_HINT_METRICS_DEFAULT; |
- | 75 | options->round_glyph_positions = CAIRO_ROUND_GLYPH_POS_DEFAULT; |
|
74 | } |
76 | } |
Line 75... | Line 77... | ||
75 | 77 | ||
76 | void |
78 | void |
77 | _cairo_font_options_init_copy (cairo_font_options_t *options, |
79 | _cairo_font_options_init_copy (cairo_font_options_t *options, |
Line 80... | Line 82... | ||
80 | options->antialias = other->antialias; |
82 | options->antialias = other->antialias; |
81 | options->subpixel_order = other->subpixel_order; |
83 | options->subpixel_order = other->subpixel_order; |
82 | options->lcd_filter = other->lcd_filter; |
84 | options->lcd_filter = other->lcd_filter; |
83 | options->hint_style = other->hint_style; |
85 | options->hint_style = other->hint_style; |
84 | options->hint_metrics = other->hint_metrics; |
86 | options->hint_metrics = other->hint_metrics; |
- | 87 | options->round_glyph_positions = other->round_glyph_positions; |
|
85 | } |
88 | } |
Line 86... | Line 89... | ||
86 | 89 | ||
87 | /** |
90 | /** |
88 | * cairo_font_options_create: |
91 | * cairo_font_options_create: |
Line 93... | Line 96... | ||
93 | * Return value: a newly allocated #cairo_font_options_t. Free with |
96 | * Return value: a newly allocated #cairo_font_options_t. Free with |
94 | * cairo_font_options_destroy(). This function always returns a |
97 | * cairo_font_options_destroy(). This function always returns a |
95 | * valid pointer; if memory cannot be allocated, then a special |
98 | * valid pointer; if memory cannot be allocated, then a special |
96 | * error object is returned where all operations on the object do nothing. |
99 | * error object is returned where all operations on the object do nothing. |
97 | * You can check for this with cairo_font_options_status(). |
100 | * You can check for this with cairo_font_options_status(). |
- | 101 | * |
|
- | 102 | * Since: 1.0 |
|
98 | **/ |
103 | **/ |
99 | cairo_font_options_t * |
104 | cairo_font_options_t * |
100 | cairo_font_options_create (void) |
105 | cairo_font_options_create (void) |
101 | { |
106 | { |
102 | cairo_font_options_t *options; |
107 | cairo_font_options_t *options; |
Line 122... | Line 127... | ||
122 | * Return value: a newly allocated #cairo_font_options_t. Free with |
127 | * Return value: a newly allocated #cairo_font_options_t. Free with |
123 | * cairo_font_options_destroy(). This function always returns a |
128 | * cairo_font_options_destroy(). This function always returns a |
124 | * valid pointer; if memory cannot be allocated, then a special |
129 | * valid pointer; if memory cannot be allocated, then a special |
125 | * error object is returned where all operations on the object do nothing. |
130 | * error object is returned where all operations on the object do nothing. |
126 | * You can check for this with cairo_font_options_status(). |
131 | * You can check for this with cairo_font_options_status(). |
- | 132 | * |
|
- | 133 | * Since: 1.0 |
|
127 | **/ |
134 | **/ |
128 | cairo_font_options_t * |
135 | cairo_font_options_t * |
129 | cairo_font_options_copy (const cairo_font_options_t *original) |
136 | cairo_font_options_copy (const cairo_font_options_t *original) |
130 | { |
137 | { |
131 | cairo_font_options_t *options; |
138 | cairo_font_options_t *options; |
Line 148... | Line 155... | ||
148 | * cairo_font_options_destroy: |
155 | * cairo_font_options_destroy: |
149 | * @options: a #cairo_font_options_t |
156 | * @options: a #cairo_font_options_t |
150 | * |
157 | * |
151 | * Destroys a #cairo_font_options_t object created with |
158 | * Destroys a #cairo_font_options_t object created with |
152 | * cairo_font_options_create() or cairo_font_options_copy(). |
159 | * cairo_font_options_create() or cairo_font_options_copy(). |
- | 160 | * |
|
- | 161 | * Since: 1.0 |
|
153 | **/ |
162 | **/ |
154 | void |
163 | void |
155 | cairo_font_options_destroy (cairo_font_options_t *options) |
164 | cairo_font_options_destroy (cairo_font_options_t *options) |
156 | { |
165 | { |
157 | if (cairo_font_options_status (options)) |
166 | if (cairo_font_options_status (options)) |
Line 166... | Line 175... | ||
166 | * |
175 | * |
167 | * Checks whether an error has previously occurred for this |
176 | * Checks whether an error has previously occurred for this |
168 | * font options object |
177 | * font options object |
169 | * |
178 | * |
170 | * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY |
179 | * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY |
- | 180 | * |
|
- | 181 | * Since: 1.0 |
|
171 | **/ |
182 | **/ |
172 | cairo_status_t |
183 | cairo_status_t |
173 | cairo_font_options_status (cairo_font_options_t *options) |
184 | cairo_font_options_status (cairo_font_options_t *options) |
174 | { |
185 | { |
175 | if (options == NULL) |
186 | if (options == NULL) |
Line 187... | Line 198... | ||
187 | * @other: another #cairo_font_options_t |
198 | * @other: another #cairo_font_options_t |
188 | * |
199 | * |
189 | * Merges non-default options from @other into @options, replacing |
200 | * Merges non-default options from @other into @options, replacing |
190 | * existing values. This operation can be thought of as somewhat |
201 | * existing values. This operation can be thought of as somewhat |
191 | * similar to compositing @other onto @options with the operation |
202 | * similar to compositing @other onto @options with the operation |
192 | * of %CAIRO_OPERATION_OVER. |
203 | * of %CAIRO_OPERATOR_OVER. |
- | 204 | * |
|
- | 205 | * Since: 1.0 |
|
193 | **/ |
206 | **/ |
194 | void |
207 | void |
195 | cairo_font_options_merge (cairo_font_options_t *options, |
208 | cairo_font_options_merge (cairo_font_options_t *options, |
196 | const cairo_font_options_t *other) |
209 | const cairo_font_options_t *other) |
197 | { |
210 | { |
Line 209... | Line 222... | ||
209 | options->lcd_filter = other->lcd_filter; |
222 | options->lcd_filter = other->lcd_filter; |
210 | if (other->hint_style != CAIRO_HINT_STYLE_DEFAULT) |
223 | if (other->hint_style != CAIRO_HINT_STYLE_DEFAULT) |
211 | options->hint_style = other->hint_style; |
224 | options->hint_style = other->hint_style; |
212 | if (other->hint_metrics != CAIRO_HINT_METRICS_DEFAULT) |
225 | if (other->hint_metrics != CAIRO_HINT_METRICS_DEFAULT) |
213 | options->hint_metrics = other->hint_metrics; |
226 | options->hint_metrics = other->hint_metrics; |
- | 227 | if (other->round_glyph_positions != CAIRO_ROUND_GLYPH_POS_DEFAULT) |
|
- | 228 | options->round_glyph_positions = other->round_glyph_positions; |
|
214 | } |
229 | } |
215 | slim_hidden_def (cairo_font_options_merge); |
230 | slim_hidden_def (cairo_font_options_merge); |
Line 216... | Line 231... | ||
216 | 231 | ||
217 | /** |
232 | /** |
Line 222... | Line 237... | ||
222 | * Compares two font options objects for equality. |
237 | * Compares two font options objects for equality. |
223 | * |
238 | * |
224 | * Return value: %TRUE if all fields of the two font options objects match. |
239 | * Return value: %TRUE if all fields of the two font options objects match. |
225 | * Note that this function will return %FALSE if either object is in |
240 | * Note that this function will return %FALSE if either object is in |
226 | * error. |
241 | * error. |
- | 242 | * |
|
- | 243 | * Since: 1.0 |
|
227 | **/ |
244 | **/ |
228 | cairo_bool_t |
245 | cairo_bool_t |
229 | cairo_font_options_equal (const cairo_font_options_t *options, |
246 | cairo_font_options_equal (const cairo_font_options_t *options, |
230 | const cairo_font_options_t *other) |
247 | const cairo_font_options_t *other) |
231 | { |
248 | { |
Line 239... | Line 256... | ||
239 | 256 | ||
240 | return (options->antialias == other->antialias && |
257 | return (options->antialias == other->antialias && |
241 | options->subpixel_order == other->subpixel_order && |
258 | options->subpixel_order == other->subpixel_order && |
242 | options->lcd_filter == other->lcd_filter && |
259 | options->lcd_filter == other->lcd_filter && |
243 | options->hint_style == other->hint_style && |
260 | options->hint_style == other->hint_style && |
- | 261 | options->hint_metrics == other->hint_metrics && |
|
244 | options->hint_metrics == other->hint_metrics); |
262 | options->round_glyph_positions == other->round_glyph_positions); |
245 | } |
263 | } |
Line 246... | Line 264... | ||
246 | slim_hidden_def (cairo_font_options_equal); |
264 | slim_hidden_def (cairo_font_options_equal); |
247 | 265 | ||
Line 254... | Line 272... | ||
254 | * in a hash table. |
272 | * in a hash table. |
255 | * |
273 | * |
256 | * Return value: the hash value for the font options object. |
274 | * Return value: the hash value for the font options object. |
257 | * The return value can be cast to a 32-bit type if a |
275 | * The return value can be cast to a 32-bit type if a |
258 | * 32-bit hash value is needed. |
276 | * 32-bit hash value is needed. |
- | 277 | * |
|
- | 278 | * Since: 1.0 |
|
259 | **/ |
279 | **/ |
260 | unsigned long |
280 | unsigned long |
261 | cairo_font_options_hash (const cairo_font_options_t *options) |
281 | cairo_font_options_hash (const cairo_font_options_t *options) |
262 | { |
282 | { |
263 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
283 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
Line 276... | Line 296... | ||
276 | * @options: a #cairo_font_options_t |
296 | * @options: a #cairo_font_options_t |
277 | * @antialias: the new antialiasing mode |
297 | * @antialias: the new antialiasing mode |
278 | * |
298 | * |
279 | * Sets the antialiasing mode for the font options object. This |
299 | * Sets the antialiasing mode for the font options object. This |
280 | * specifies the type of antialiasing to do when rendering text. |
300 | * specifies the type of antialiasing to do when rendering text. |
- | 301 | * |
|
- | 302 | * Since: 1.0 |
|
281 | **/ |
303 | **/ |
282 | void |
304 | void |
283 | cairo_font_options_set_antialias (cairo_font_options_t *options, |
305 | cairo_font_options_set_antialias (cairo_font_options_t *options, |
284 | cairo_antialias_t antialias) |
306 | cairo_antialias_t antialias) |
285 | { |
307 | { |
Line 295... | Line 317... | ||
295 | * @options: a #cairo_font_options_t |
317 | * @options: a #cairo_font_options_t |
296 | * |
318 | * |
297 | * Gets the antialiasing mode for the font options object. |
319 | * Gets the antialiasing mode for the font options object. |
298 | * |
320 | * |
299 | * Return value: the antialiasing mode |
321 | * Return value: the antialiasing mode |
- | 322 | * |
|
- | 323 | * Since: 1.0 |
|
300 | **/ |
324 | **/ |
301 | cairo_antialias_t |
325 | cairo_antialias_t |
302 | cairo_font_options_get_antialias (const cairo_font_options_t *options) |
326 | cairo_font_options_get_antialias (const cairo_font_options_t *options) |
303 | { |
327 | { |
304 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
328 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
Line 315... | Line 339... | ||
315 | * Sets the subpixel order for the font options object. The subpixel |
339 | * Sets the subpixel order for the font options object. The subpixel |
316 | * order specifies the order of color elements within each pixel on |
340 | * order specifies the order of color elements within each pixel on |
317 | * the display device when rendering with an antialiasing mode of |
341 | * the display device when rendering with an antialiasing mode of |
318 | * %CAIRO_ANTIALIAS_SUBPIXEL. See the documentation for |
342 | * %CAIRO_ANTIALIAS_SUBPIXEL. See the documentation for |
319 | * #cairo_subpixel_order_t for full details. |
343 | * #cairo_subpixel_order_t for full details. |
- | 344 | * |
|
- | 345 | * Since: 1.0 |
|
320 | **/ |
346 | **/ |
321 | void |
347 | void |
322 | cairo_font_options_set_subpixel_order (cairo_font_options_t *options, |
348 | cairo_font_options_set_subpixel_order (cairo_font_options_t *options, |
323 | cairo_subpixel_order_t subpixel_order) |
349 | cairo_subpixel_order_t subpixel_order) |
324 | { |
350 | { |
Line 335... | Line 361... | ||
335 | * |
361 | * |
336 | * Gets the subpixel order for the font options object. |
362 | * Gets the subpixel order for the font options object. |
337 | * See the documentation for #cairo_subpixel_order_t for full details. |
363 | * See the documentation for #cairo_subpixel_order_t for full details. |
338 | * |
364 | * |
339 | * Return value: the subpixel order for the font options object |
365 | * Return value: the subpixel order for the font options object |
- | 366 | * |
|
- | 367 | * Since: 1.0 |
|
340 | **/ |
368 | **/ |
341 | cairo_subpixel_order_t |
369 | cairo_subpixel_order_t |
342 | cairo_font_options_get_subpixel_order (const cairo_font_options_t *options) |
370 | cairo_font_options_get_subpixel_order (const cairo_font_options_t *options) |
343 | { |
371 | { |
344 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
372 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
Line 354... | Line 382... | ||
354 | * |
382 | * |
355 | * Sets the LCD filter for the font options object. The LCD filter |
383 | * Sets the LCD filter for the font options object. The LCD filter |
356 | * specifies how pixels are filtered when rendered with an antialiasing |
384 | * specifies how pixels are filtered when rendered with an antialiasing |
357 | * mode of %CAIRO_ANTIALIAS_SUBPIXEL. See the documentation for |
385 | * mode of %CAIRO_ANTIALIAS_SUBPIXEL. See the documentation for |
358 | * #cairo_lcd_filter_t for full details. |
386 | * #cairo_lcd_filter_t for full details. |
359 | * |
- | |
360 | * Since: 1.8 |
- | |
361 | **/ |
387 | **/ |
362 | void |
388 | void |
363 | _cairo_font_options_set_lcd_filter (cairo_font_options_t *options, |
389 | _cairo_font_options_set_lcd_filter (cairo_font_options_t *options, |
364 | cairo_lcd_filter_t lcd_filter) |
390 | cairo_lcd_filter_t lcd_filter) |
365 | { |
391 | { |
Line 375... | Line 401... | ||
375 | * |
401 | * |
376 | * Gets the LCD filter for the font options object. |
402 | * Gets the LCD filter for the font options object. |
377 | * See the documentation for #cairo_lcd_filter_t for full details. |
403 | * See the documentation for #cairo_lcd_filter_t for full details. |
378 | * |
404 | * |
379 | * Return value: the LCD filter for the font options object |
405 | * Return value: the LCD filter for the font options object |
380 | * |
- | |
381 | * Since: 1.8 |
- | |
382 | **/ |
406 | **/ |
383 | cairo_lcd_filter_t |
407 | cairo_lcd_filter_t |
384 | _cairo_font_options_get_lcd_filter (const cairo_font_options_t *options) |
408 | _cairo_font_options_get_lcd_filter (const cairo_font_options_t *options) |
385 | { |
409 | { |
386 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
410 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
Line 388... | Line 412... | ||
388 | 412 | ||
389 | return options->lcd_filter; |
413 | return options->lcd_filter; |
Line 390... | Line 414... | ||
390 | } |
414 | } |
- | 415 | ||
- | 416 | /** |
|
- | 417 | * _cairo_font_options_set_round_glyph_positions: |
|
- | 418 | * @options: a #cairo_font_options_t |
|
- | 419 | * @round: the new rounding value |
|
- | 420 | * |
|
- | 421 | * Sets the rounding options for the font options object. If rounding is set, a |
|
- | 422 | * glyph's position will be rounded to integer values. |
|
- | 423 | **/ |
|
- | 424 | void |
|
- | 425 | _cairo_font_options_set_round_glyph_positions (cairo_font_options_t *options, |
|
- | 426 | cairo_round_glyph_positions_t round) |
|
- | 427 | { |
|
- | 428 | if (cairo_font_options_status (options)) |
|
- | 429 | return; |
|
- | 430 | ||
- | 431 | options->round_glyph_positions = round; |
|
- | 432 | } |
|
- | 433 | ||
- | 434 | /** |
|
- | 435 | * _cairo_font_options_get_round_glyph_positions: |
|
- | 436 | * @options: a #cairo_font_options_t |
|
- | 437 | * |
|
- | 438 | * Gets the glyph position rounding option for the font options object. |
|
- | 439 | * |
|
- | 440 | * Return value: The round glyph posistions flag for the font options object. |
|
- | 441 | **/ |
|
- | 442 | cairo_round_glyph_positions_t |
|
- | 443 | _cairo_font_options_get_round_glyph_positions (const cairo_font_options_t *options) |
|
- | 444 | { |
|
- | 445 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
|
- | 446 | return CAIRO_ROUND_GLYPH_POS_DEFAULT; |
|
- | 447 | ||
- | 448 | return options->round_glyph_positions; |
|
- | 449 | } |
|
391 | 450 | ||
392 | /** |
451 | /** |
393 | * cairo_font_options_set_hint_style: |
452 | * cairo_font_options_set_hint_style: |
394 | * @options: a #cairo_font_options_t |
453 | * @options: a #cairo_font_options_t |
395 | * @hint_style: the new hint style |
454 | * @hint_style: the new hint style |
396 | * |
455 | * |
397 | * Sets the hint style for font outlines for the font options object. |
456 | * Sets the hint style for font outlines for the font options object. |
398 | * This controls whether to fit font outlines to the pixel grid, |
457 | * This controls whether to fit font outlines to the pixel grid, |
- | 458 | * and if so, whether to optimize for fidelity or contrast. |
|
- | 459 | * See the documentation for #cairo_hint_style_t for full details. |
|
399 | * and if so, whether to optimize for fidelity or contrast. |
460 | * |
400 | * See the documentation for #cairo_hint_style_t for full details. |
461 | * Since: 1.0 |
401 | **/ |
462 | **/ |
402 | void |
463 | void |
403 | cairo_font_options_set_hint_style (cairo_font_options_t *options, |
464 | cairo_font_options_set_hint_style (cairo_font_options_t *options, |
Line 416... | Line 477... | ||
416 | * |
477 | * |
417 | * Gets the hint style for font outlines for the font options object. |
478 | * Gets the hint style for font outlines for the font options object. |
418 | * See the documentation for #cairo_hint_style_t for full details. |
479 | * See the documentation for #cairo_hint_style_t for full details. |
419 | * |
480 | * |
420 | * Return value: the hint style for the font options object |
481 | * Return value: the hint style for the font options object |
- | 482 | * |
|
- | 483 | * Since: 1.0 |
|
421 | **/ |
484 | **/ |
422 | cairo_hint_style_t |
485 | cairo_hint_style_t |
423 | cairo_font_options_get_hint_style (const cairo_font_options_t *options) |
486 | cairo_font_options_get_hint_style (const cairo_font_options_t *options) |
424 | { |
487 | { |
425 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
488 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
Line 435... | Line 498... | ||
435 | * |
498 | * |
436 | * Sets the metrics hinting mode for the font options object. This |
499 | * Sets the metrics hinting mode for the font options object. This |
437 | * controls whether metrics are quantized to integer values in |
500 | * controls whether metrics are quantized to integer values in |
438 | * device units. |
501 | * device units. |
439 | * See the documentation for #cairo_hint_metrics_t for full details. |
502 | * See the documentation for #cairo_hint_metrics_t for full details. |
- | 503 | * |
|
- | 504 | * Since: 1.0 |
|
440 | **/ |
505 | **/ |
441 | void |
506 | void |
442 | cairo_font_options_set_hint_metrics (cairo_font_options_t *options, |
507 | cairo_font_options_set_hint_metrics (cairo_font_options_t *options, |
443 | cairo_hint_metrics_t hint_metrics) |
508 | cairo_hint_metrics_t hint_metrics) |
444 | { |
509 | { |
Line 455... | Line 520... | ||
455 | * |
520 | * |
456 | * Gets the metrics hinting mode for the font options object. |
521 | * Gets the metrics hinting mode for the font options object. |
457 | * See the documentation for #cairo_hint_metrics_t for full details. |
522 | * See the documentation for #cairo_hint_metrics_t for full details. |
458 | * |
523 | * |
459 | * Return value: the metrics hinting mode for the font options object |
524 | * Return value: the metrics hinting mode for the font options object |
- | 525 | * |
|
- | 526 | * Since: 1.0 |
|
460 | **/ |
527 | **/ |
461 | cairo_hint_metrics_t |
528 | cairo_hint_metrics_t |
462 | cairo_font_options_get_hint_metrics (const cairo_font_options_t *options) |
529 | cairo_font_options_get_hint_metrics (const cairo_font_options_t *options) |
463 | { |
530 | { |
464 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |
531 | if (cairo_font_options_status ((cairo_font_options_t *) options)) |